Sun, 29 Jul 2012 16:55:32 +0300
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * botc source code |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2012 Santeri `Dusk` Piippo |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * All rights reserved. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright notice, |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * this list of conditions and the following disclaimer. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * this list of conditions and the following disclaimer in the documentation |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * and/or other materials provided with the distribution. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * 3. Neither the name of the developer nor the names of its contributors may |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * be used to endorse or promote products derived from this software without |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * specific prior written permission. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | * 4. Redistributions in any form must be accompanied by information on how to |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | * obtain complete source code for the software and any accompanying |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | * software that uses the software. The source code must either be included |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | * in the distribution or be available for no more than the cost of |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | * distribution plus a nominal fee, and must be freely redistributable |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | * under reasonable conditions. For an executable file, complete source |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | * code means the source code for all modules it contains. It does not |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | * include source code for modules or files that typically accompany the |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | * major components of the operating system on which the executable file |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | * runs. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | * |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | * POSSIBILITY OF SUCH DAMAGE. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | */ |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | #ifndef __DATABUFFER_H__ |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | #define __DATABUFFER_H__ |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | #include <stdio.h> |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | #include <string.h> |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | #include "common.h" |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
47 | #define MAX_MARKS 256 |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
48 | |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | // ============================================================================ |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | // DataBuffer: A dynamic data buffer. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | class DataBuffer { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | public: |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | // The actual buffer |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | unsigned char* buffer; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | // Allocated size of the buffer |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | unsigned int allocsize; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | // Written size of the buffer |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | unsigned int writesize; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
62 | // Marks and references |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
63 | ScriptMark* marks[MAX_MARKS]; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
64 | ScriptMarkReference* refs[MAX_MARKS]; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
65 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
66 | // ==================================================================== |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | // METHODS |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
68 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
69 | // ==================================================================== |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
70 | // Constructor |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | DataBuffer (unsigned int size=128) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | writesize = 0; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | buffer = new unsigned char[size]; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | allocsize = size; |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
76 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
77 | // Clear the marks table out |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
78 | for (unsigned int u = 0; u < MAX_MARKS; u++) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
79 | marks[u] = NULL; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
80 | refs[u] = NULL; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
81 | } |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
84 | // ==================================================================== |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | ~DataBuffer () { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | delete buffer; |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
87 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
88 | // Delete any marks and references |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
89 | for (unsigned int u = 0; u < MAX_MARKS; u++) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
90 | if (marks[u]) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
91 | delete marks[u]; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
92 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
93 | if (refs[u]) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
94 | delete refs[u]; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
95 | } |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
98 | // ==================================================================== |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
99 | // Write stuff to the buffer |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | template<class T> void Write(T stuff) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | if (sizeof (char) != 1) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | error ("DataBuffer: sizeof(char) must be 1!\n"); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | // Out of space, must resize |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | if (writesize + sizeof(T) >= allocsize) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | // First, store the old buffer temporarily |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | char* copy = new char[allocsize]; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | memcpy (copy, buffer, allocsize); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | // Remake the buffer with the new size. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | // Have a bit of leeway so we don't have to |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | // resize immediately again. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | size_t newsize = allocsize + sizeof (T) + 128; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | delete buffer; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | buffer = new unsigned char[newsize]; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | allocsize = newsize; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | // Now, copy the new stuff over. |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | memcpy (buffer, copy, allocsize); |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | // Nuke the copy now as it's no longer needed |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | delete copy; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | // Write the new stuff one byte at a time |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | for (unsigned int x = 0; x < sizeof (T); x++) { |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | if (writesize >= allocsize) |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | error ("DataBuffer: written size exceeds allocated size!\n"); |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
130 | buffer[writesize] = GetByteIndex<T> (stuff, x); |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | writesize++; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
135 | // ==================================================================== |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
136 | // Merge another data buffer into this one. |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
137 | void Merge (DataBuffer* other) { |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
138 | if (!other) |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
139 | return; |
36
a8838b5f1213
Parser can now read expressions 100% properly and can perform variable assignment. I'd call this a milestone!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
34
diff
changeset
|
140 | |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
141 | for (unsigned int x = 0; x < other->writesize; x++) { |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
142 | unsigned char c = *(other->buffer+x); |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
143 | Write<unsigned char> (c); |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
144 | } |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
145 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
146 | // Merge its marks and references |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
147 | unsigned int u = 0; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
148 | for (u = 0; u < MAX_MARKS; u++) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
149 | if (other->marks[u]) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
150 | // Add the mark and offset its position. |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
151 | unsigned int u = AddMark (other->marks[u]->type, other->marks[u]->name); |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
152 | marks[u]->pos += other->writesize; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
153 | } |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
154 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
155 | if (other->refs[u]) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
156 | // Same for references |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
157 | unsigned int r = AddMarkReference (other->refs[u]->num); |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
158 | refs[r]->pos += other->writesize; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
159 | } |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
160 | } |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
161 | |
34
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
162 | delete other; |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
163 | } |
0a9a5902beaa
Expression parser mostly up and running!! Still work to do on it though.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
164 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
165 | // ==================================================================== |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
166 | // Adds a mark to the buffer. A mark is a reference to a particular |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
167 | // position in the bytecode. The actual permanent position cannot |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
168 | // be predicted in any way or form, thus these things will be used |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
169 | // to "mark" a position like that for future use. |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
170 | unsigned int AddMark (int type, str name) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
171 | // Find a free slot for the mark |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
172 | unsigned int u; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
173 | for (u = 0; u < MAX_MARKS; u++) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
174 | if (!marks[u]) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
175 | break; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
176 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
177 | if (u >= MAX_MARKS) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
178 | error ("mark quota exceeded, all labels, if-structs and loops add marks\n"); |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
179 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
180 | ScriptMark* m = new ScriptMark; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
181 | m->name = name; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
182 | m->type = type; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
183 | m->pos = writesize; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
184 | marks[u] = m; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
185 | return u; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
186 | } |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
187 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
188 | unsigned int AddMarkReference (unsigned int marknum) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
189 | unsigned int u; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
190 | for (u = 0; u < MAX_MARKS; u++) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
191 | if (!refs[u]) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
192 | break; |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
194 | if (u == MAX_MARKS) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
195 | error ("mark reference quota exceeded, all goto-statements, if-structs and loops add refs\n"); |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
196 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
197 | // NOTE: Do not check if the mark actually exists here since a |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
198 | // reference may come in the code earlier than the actual mark |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
199 | // and the new mark number can be predicted. |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
200 | ScriptMarkReference* r = new ScriptMarkReference; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
201 | r->num = marknum; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
202 | r->pos = writesize; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
203 | refs[u] = r; |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
205 | return u; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
206 | } |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
207 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
208 | // Delete a mark and all references to it. |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
209 | void DeleteMark (unsigned int marknum) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
210 | if (!marks[marknum]) |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
211 | return; |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | |
37
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
213 | // Delete the mark |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
214 | delete marks[marknum]; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
215 | marks[marknum] = NULL; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
216 | |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
217 | // Delete its references |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
218 | for (unsigned int u = 0; u < MAX_MARKS; u++) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
219 | if (refs[u]->num == marknum) { |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
220 | delete refs[u]; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
221 | refs[u] = NULL; |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
222 | } |
c349dca807f9
Added mark/reference system to be able to refer to positions in the buffered bytecode. Labels and go-to support.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
36
diff
changeset
|
223 | } |
32
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | } |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | }; |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | |
d11a034aabfd
- The output cmd-line argument is now optional - one is generated from the input file if not given.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | #endif // __DATABUFFER_H__ |