mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-10-15 05:30:09 +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:
@@ -97,6 +97,11 @@ void blackenObject(CState *state, CObj *obj) {
|
||||
markObject(state, (CObj*)cobj->proto);
|
||||
break;
|
||||
}
|
||||
case COBJ_DICT: { // dictionaries are just wrappers for CTable
|
||||
CObjDict *dict = (CObjDict*)obj;
|
||||
markTable(state, &dict->tbl);
|
||||
break;
|
||||
}
|
||||
case COBJ_UPVALUE: {
|
||||
markValue(state, ((CObjUpval*)obj)->closed);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user