databuffer.h

changeset 45
e1d3b7ea975c
parent 43
1b35c9985989
child 48
976c57f153b3
equal deleted inserted replaced
44:6bbaebc472b5 45:e1d3b7ea975c
143 // Merge its marks and references 143 // Merge its marks and references
144 unsigned int u = 0; 144 unsigned int u = 0;
145 for (u = 0; u < MAX_MARKS; u++) { 145 for (u = 0; u < MAX_MARKS; u++) {
146 if (other->marks[u]) { 146 if (other->marks[u]) {
147 // Add the mark and offset its position. 147 // Add the mark and offset its position.
148 unsigned int u = AddMark (other->marks[u]->type, other->marks[u]->name); 148 unsigned int u = AddMark (other->marks[u]->name);
149 marks[u]->pos += other->writesize; 149 marks[u]->pos += other->writesize;
150 } 150 }
151 151
152 if (other->refs[u]) { 152 if (other->refs[u]) {
153 // Same for references 153 // Same for references
170 // ==================================================================== 170 // ====================================================================
171 // Adds a mark to the buffer. A mark is a "pointer" to a particular 171 // Adds a mark to the buffer. A mark is a "pointer" to a particular
172 // position in the bytecode. The actual permanent position cannot 172 // position in the bytecode. The actual permanent position cannot
173 // be predicted in any way or form, thus these things will be used 173 // be predicted in any way or form, thus these things will be used
174 // to "mark" a position like that for future use. 174 // to "mark" a position like that for future use.
175 unsigned int AddMark (int type, str name) { 175 unsigned int AddMark (str name) {
176 // Find a free slot for the mark 176 // Find a free slot for the mark
177 unsigned int u; 177 unsigned int u;
178 for (u = 0; u < MAX_MARKS; u++) 178 for (u = 0; u < MAX_MARKS; u++)
179 if (!marks[u]) 179 if (!marks[u])
180 break; 180 break;
182 if (u >= MAX_MARKS) 182 if (u >= MAX_MARKS)
183 error ("mark quota exceeded, all labels, if-structs and loops add marks\n"); 183 error ("mark quota exceeded, all labels, if-structs and loops add marks\n");
184 184
185 ScriptMark* m = new ScriptMark; 185 ScriptMark* m = new ScriptMark;
186 m->name = name; 186 m->name = name;
187 m->type = type;
188 m->pos = writesize; 187 m->pos = writesize;
189 marks[u] = m; 188 marks[u] = m;
190 return u; 189 return u;
191 } 190 }
192 191

mercurial