|
15 | 15 | along with LiveCode. If not see <http://www.gnu.org/licenses/>. */ |
16 | 16 |
|
17 | 17 | #include <foundation.h> |
| 18 | +#include <foundation-auto.h> |
18 | 19 |
|
19 | 20 | #include "libscript/script.h" |
20 | 21 | #include "script-private.h" |
@@ -64,6 +65,7 @@ struct MCScriptModuleBuilder |
64 | 65 | uindex_t current_line; |
65 | 66 |
|
66 | 67 | MCProperListRef current_list_value; |
| 68 | + MCArrayRef current_array_value; |
67 | 69 | }; |
68 | 70 |
|
69 | 71 | //////////////////////////////////////////////////////////////////////////////// |
@@ -125,6 +127,7 @@ void MCScriptBeginModule(MCScriptModuleKind p_kind, MCNameRef p_name, MCScriptMo |
125 | 127 | self -> current_line = 0; |
126 | 128 |
|
127 | 129 | self -> current_list_value = nil; |
| 130 | + self -> current_array_value = nil; |
128 | 131 |
|
129 | 132 | r_builder = self; |
130 | 133 | } |
@@ -164,6 +167,7 @@ bool MCScriptEndModule(MCScriptModuleBuilderRef self, MCStreamRef p_stream) |
164 | 167 | MCMemoryDeleteArray(self -> operands); |
165 | 168 |
|
166 | 169 | MCValueRelease(self -> current_list_value); |
| 170 | + MCValueRelease(self -> current_array_value); |
167 | 171 |
|
168 | 172 | MCMemoryDelete(self); |
169 | 173 |
|
@@ -325,6 +329,49 @@ void MCScriptEndListValueInModule(MCScriptModuleBuilderRef self, uindex_t& r_ind |
325 | 329 | self -> current_list_value = nil; |
326 | 330 | } |
327 | 331 |
|
| 332 | +void MCScriptBeginArrayValueInModule(MCScriptModuleBuilderRef self) |
| 333 | +{ |
| 334 | + if (self == nil || !self -> valid) |
| 335 | + return; |
| 336 | + |
| 337 | + if (self -> current_array_value != nil || |
| 338 | + !MCArrayCreateMutable(self -> current_array_value)) |
| 339 | + { |
| 340 | + self -> valid = false; |
| 341 | + return; |
| 342 | + } |
| 343 | +} |
| 344 | + |
| 345 | +void MCScriptContinueArrayValueInModule(MCScriptModuleBuilderRef self, |
| 346 | + uindex_t p_key_idx, |
| 347 | + uindex_t p_value_idx) |
| 348 | +{ |
| 349 | + MCNewAutoNameRef t_key; |
| 350 | + |
| 351 | + if (self == nil || !self -> valid) |
| 352 | + return; |
| 353 | + |
| 354 | + if (self -> current_array_value == nil || |
| 355 | + !MCNameCreate(reinterpret_cast<MCStringRef>(self->module.values[p_key_idx]), &t_key) || |
| 356 | + !MCArrayStoreValue(self -> current_array_value, false, |
| 357 | + *t_key, self -> module . values[p_value_idx])) |
| 358 | + { |
| 359 | + self -> valid = false; |
| 360 | + return; |
| 361 | + } |
| 362 | +} |
| 363 | + |
| 364 | +void MCScriptEndArrayValueInModule(MCScriptModuleBuilderRef self, uindex_t& r_index) |
| 365 | +{ |
| 366 | + if (self == nil || !self -> valid) |
| 367 | + return; |
| 368 | + |
| 369 | + MCScriptAddValueToModule(self, self -> current_array_value, r_index); |
| 370 | + |
| 371 | + MCValueRelease(self -> current_array_value); |
| 372 | + self -> current_array_value = nil; |
| 373 | +} |
| 374 | + |
328 | 375 | void MCScriptAddTypeToModule(MCScriptModuleBuilderRef self, MCNameRef p_name, uindex_t p_type, uindex_t p_index) |
329 | 376 | { |
330 | 377 | if (self == nil || !self -> valid) |
@@ -1394,6 +1441,31 @@ void MCScriptEmitEndAssignListInModule(MCScriptModuleBuilderRef self) |
1394 | 1441 | __end_instruction(self); |
1395 | 1442 | } |
1396 | 1443 |
|
| 1444 | +void MCScriptEmitBeginAssignArrayInModule(MCScriptModuleBuilderRef self, uindex_t p_reg) |
| 1445 | +{ |
| 1446 | + if (self == nil || !self -> valid) |
| 1447 | + return; |
| 1448 | + |
| 1449 | + __begin_instruction(self, kMCScriptBytecodeOpAssignArray); |
| 1450 | + __continue_instruction(self, p_reg); |
| 1451 | +} |
| 1452 | + |
| 1453 | +void MCScriptEmitContinueAssignArrayInModule(MCScriptModuleBuilderRef self, uindex_t p_reg) |
| 1454 | +{ |
| 1455 | + if (self == nil || !self -> valid) |
| 1456 | + return; |
| 1457 | + |
| 1458 | + __continue_instruction(self, p_reg); |
| 1459 | +} |
| 1460 | + |
| 1461 | +void MCScriptEmitEndAssignArrayInModule(MCScriptModuleBuilderRef self) |
| 1462 | +{ |
| 1463 | + if (self == nil || !self -> valid) |
| 1464 | + return; |
| 1465 | + |
| 1466 | + __end_instruction(self); |
| 1467 | +} |
| 1468 | + |
1397 | 1469 | void MCScriptEmitAssignInModule(MCScriptModuleBuilderRef self, uindex_t p_dst_reg, uindex_t p_src_reg) |
1398 | 1470 | { |
1399 | 1471 | if (self == nil || !self -> valid) |
|
0 commit comments