mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-05 08:10:05 +00:00
OP_NEWOBJECT uses long operand
This commit is contained in:
parent
4c4b5eae8d
commit
3727d6bb7c
@ -109,7 +109,7 @@ int disasmInstr(CChunk *chunk, int offset, int indent) {
|
|||||||
case OP_CLOSE:
|
case OP_CLOSE:
|
||||||
return simpleInstruction("OP_CLOSE", offset);
|
return simpleInstruction("OP_CLOSE", offset);
|
||||||
case OP_NEWOBJECT:
|
case OP_NEWOBJECT:
|
||||||
return shortOperandInstruction("OP_NEWOBJECT", chunk, offset);
|
return longOperandInstruction("OP_NEWOBJECT", chunk, offset);
|
||||||
case OP_GETOBJECT:
|
case OP_GETOBJECT:
|
||||||
return simpleInstruction("OP_GETOBJECT", offset);
|
return simpleInstruction("OP_GETOBJECT", offset);
|
||||||
case OP_SETOBJECT:
|
case OP_SETOBJECT:
|
||||||
|
@ -13,14 +13,14 @@ typedef enum {
|
|||||||
// instructions
|
// instructions
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
// STACK MANIPULATION
|
// STACK/STATE MANIPULATION
|
||||||
OP_LOADCONST,
|
OP_LOADCONST, // pushes const[uint8_t] to the stack
|
||||||
OP_SETGLOBAL,
|
OP_SETGLOBAL, // pops and sets global[const[uint16_t]]
|
||||||
OP_GETGLOBAL,
|
OP_GETGLOBAL, // pushes global[const[uint16_t]]
|
||||||
OP_SETLOCAL,
|
OP_SETLOCAL, // pops and sets base[uint8_t]
|
||||||
OP_GETLOCAL,
|
OP_GETLOCAL, // pushes base[uint8_t]
|
||||||
OP_GETUPVAL,
|
OP_GETUPVAL, // pushes closure->upvals[uint8_t]
|
||||||
OP_SETUPVAL,
|
OP_SETUPVAL, // pops and sets closure->upvals[uint8_t]
|
||||||
OP_PEJMP, // pops, if false jumps uint16_t
|
OP_PEJMP, // pops, if false jumps uint16_t
|
||||||
OP_EJMP, // if peek(0) is falsey jumps uint16_t
|
OP_EJMP, // if peek(0) is falsey jumps uint16_t
|
||||||
OP_JMP, // always jumps uint16_t
|
OP_JMP, // always jumps uint16_t
|
||||||
@ -29,7 +29,7 @@ typedef enum {
|
|||||||
OP_CALL, // calls top[-uint8_t]
|
OP_CALL, // calls top[-uint8_t]
|
||||||
OP_CLOSURE,
|
OP_CLOSURE,
|
||||||
OP_CLOSE,
|
OP_CLOSE,
|
||||||
OP_NEWOBJECT,
|
OP_NEWOBJECT, //
|
||||||
OP_GETOBJECT,
|
OP_GETOBJECT,
|
||||||
OP_SETOBJECT,
|
OP_SETOBJECT,
|
||||||
OP_INVOKE,
|
OP_INVOKE,
|
||||||
@ -55,9 +55,8 @@ typedef enum {
|
|||||||
OP_FALSE,
|
OP_FALSE,
|
||||||
OP_NIL,
|
OP_NIL,
|
||||||
|
|
||||||
OP_RETURN,
|
OP_RETURN
|
||||||
|
|
||||||
OP_NONE // used as an error result
|
|
||||||
} COPCODE;
|
} COPCODE;
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -570,7 +570,7 @@ static void object(CParseState *pstate, bool canAssign) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeu8(pstate, OP_NEWOBJECT);
|
writeu8(pstate, OP_NEWOBJECT);
|
||||||
writeu8(pstate, entries);
|
writeu16(pstate, entries);
|
||||||
valuePushed(pstate, 1);
|
valuePushed(pstate, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -753,7 +753,7 @@ static void _class(CParseState *pstate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeu8(pstate, OP_NEWOBJECT);
|
writeu8(pstate, OP_NEWOBJECT);
|
||||||
writeu8(pstate, entries);
|
writeu16(pstate, entries);
|
||||||
valuePushed(pstate, 1);
|
valuePushed(pstate, 1);
|
||||||
defineVariable(pstate, var, false);
|
defineVariable(pstate, var, false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user