mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-09-28 14:17:37 +00:00
Added dictionaries {}
Objects are now separate from {} dictionaries the . operator now only indexes fields on objects, the [] operator can only be used on objects if the __index or __newindex functions are defined Additionally 4 new instructions have been added to the VM: OP_NEWDICT, OP_INDEX, OP_INCINDEX, and OP_NEWINDEX. The syntax to create a dictionary is as follows { <key> : <value>, <otherkey> : <othervalue> } eg. { "hello" : "world", "foo" : 1337 } The Lexer & Parser was extended to add the TOKEN_COLON ':' token.
This commit is contained in:
@@ -29,9 +29,12 @@ typedef enum {
|
||||
OP_CALL, // calls top[-uint8_t]
|
||||
OP_CLOSURE,
|
||||
OP_CLOSE,
|
||||
OP_NEWDICT,
|
||||
OP_INDEX,
|
||||
OP_NEWINDEX,
|
||||
OP_NEWOBJECT,
|
||||
OP_GETOBJECT,
|
||||
OP_SETOBJECT,
|
||||
OP_GETOBJECT,
|
||||
OP_INVOKE,
|
||||
|
||||
// ARITHMETIC
|
||||
@@ -46,6 +49,7 @@ typedef enum {
|
||||
OP_INCLOCAL, // pushes old value to stack, adds (uint8_t-128) to local[uint8_t]
|
||||
OP_INCGLOBAL, // pushes old value to stack, adds (uint8_t-128) to globals[const[uint16_t]]
|
||||
OP_INCUPVAL, // pushes old value to stack, adds (uint8_t-128) to closure->upval[uint8_t]
|
||||
OP_INCINDEX, // pushes old value to stack, adds (uint8_t-128) to dict[pop()]
|
||||
OP_INCOBJECT, // pushes old value to stack, adds (uint8_t-128) to obj[const[uint16_t]]
|
||||
|
||||
// EQUALITY
|
||||
|
Reference in New Issue
Block a user