mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-22 07:20:05 +00:00
renamed cosmoV_makeObject
This commit is contained in:
parent
3a18d14a80
commit
e0d51c191f
@ -42,11 +42,16 @@ CValue cosmoB_dgetProto(CState *state, int nargs, CValue *args) {
|
||||
}
|
||||
|
||||
void cosmoB_loadDebug(CState *state) {
|
||||
cosmoV_pushString(state, "getProto");
|
||||
cosmoV_pushCFunction(state, cosmoB_dgetProto);
|
||||
cosmoV_pushString(state, "getProto"); // key
|
||||
cosmoV_pushCFunction(state, cosmoB_dgetProto); // value
|
||||
|
||||
// another key & value
|
||||
cosmoV_pushString(state, "setProto");
|
||||
cosmoV_pushCFunction(state, cosmoB_dsetProto);
|
||||
cosmoV_pushObject(state, 2);
|
||||
|
||||
// we call makeObject leting it know there are 2 sets of key & value pairs on the stack (4 values total)
|
||||
cosmoV_makeObject(state, 2);
|
||||
|
||||
// set debug proto to the debug object
|
||||
state->protoObj = cosmoV_readObject(*cosmoV_pop(state));
|
||||
}
|
@ -26,7 +26,6 @@ typedef struct CObjFunction CObjFunction;
|
||||
typedef struct CObjCFunction CObjCFunction;
|
||||
typedef struct CObjMethod CObjMethod;
|
||||
typedef struct CObjObject CObjObject;
|
||||
typedef struct CObjClass CObjClass;
|
||||
typedef struct CObjClosure CObjClosure;
|
||||
|
||||
typedef uint8_t INSTRUCTION;
|
||||
|
@ -182,7 +182,7 @@ COSMOVMRESULT cosmoV_call(CState *state, int args) {
|
||||
invokeMethod(state, method->obj, method->func, args);
|
||||
break;
|
||||
}
|
||||
case COBJ_OBJECT: {
|
||||
case COBJ_OBJECT: { // object is being instantiated, making another object
|
||||
CObjObject *protoObj = (CObjObject*)cosmoV_readObj(*val);
|
||||
CObjObject *newObj = cosmoO_newObject(state);
|
||||
newObj->proto = protoObj;
|
||||
@ -221,7 +221,7 @@ static inline bool isFalsey(StkPtr val) {
|
||||
return IS_NIL(*val) || (IS_BOOLEAN(*val) && !cosmoV_readBoolean(*val));
|
||||
}
|
||||
|
||||
COSMO_API void cosmoV_pushObject(CState *state, int pairs) {
|
||||
COSMO_API void cosmoV_makeObject(CState *state, int pairs) {
|
||||
StkPtr key, val;
|
||||
CObjObject *newObj = cosmoO_newObject(state);
|
||||
cosmoV_pushValue(state, cosmoV_newObj(newObj)); // so our GC doesn't free our new object
|
||||
@ -385,7 +385,7 @@ bool cosmoV_execute(CState *state) {
|
||||
}
|
||||
case OP_NEWOBJECT: {
|
||||
uint16_t pairs = READUINT();
|
||||
cosmoV_pushObject(state, pairs);
|
||||
cosmoV_makeObject(state, pairs);
|
||||
break;
|
||||
}
|
||||
case OP_GETOBJECT: {
|
||||
|
@ -14,7 +14,7 @@ typedef enum {
|
||||
|
||||
// args = # of pass parameters, nresults = # of expected results
|
||||
COSMO_API COSMOVMRESULT cosmoV_call(CState *state, int args);
|
||||
COSMO_API void cosmoV_pushObject(CState *state, int pairs);
|
||||
COSMO_API void cosmoV_makeObject(CState *state, int pairs);
|
||||
COSMO_API bool cosmoV_getObject(CState *state, CObjObject *object, CValue key, CValue *val);
|
||||
COSMO_API void cosmoV_error(CState *state, const char *format, ...);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user