mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-05 08:10: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) {
|
void cosmoB_loadDebug(CState *state) {
|
||||||
cosmoV_pushString(state, "getProto");
|
cosmoV_pushString(state, "getProto"); // key
|
||||||
cosmoV_pushCFunction(state, cosmoB_dgetProto);
|
cosmoV_pushCFunction(state, cosmoB_dgetProto); // value
|
||||||
|
|
||||||
|
// another key & value
|
||||||
cosmoV_pushString(state, "setProto");
|
cosmoV_pushString(state, "setProto");
|
||||||
cosmoV_pushCFunction(state, cosmoB_dsetProto);
|
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));
|
state->protoObj = cosmoV_readObject(*cosmoV_pop(state));
|
||||||
}
|
}
|
@ -26,7 +26,6 @@ typedef struct CObjFunction CObjFunction;
|
|||||||
typedef struct CObjCFunction CObjCFunction;
|
typedef struct CObjCFunction CObjCFunction;
|
||||||
typedef struct CObjMethod CObjMethod;
|
typedef struct CObjMethod CObjMethod;
|
||||||
typedef struct CObjObject CObjObject;
|
typedef struct CObjObject CObjObject;
|
||||||
typedef struct CObjClass CObjClass;
|
|
||||||
typedef struct CObjClosure CObjClosure;
|
typedef struct CObjClosure CObjClosure;
|
||||||
|
|
||||||
typedef uint8_t INSTRUCTION;
|
typedef uint8_t INSTRUCTION;
|
||||||
|
@ -182,7 +182,7 @@ COSMOVMRESULT cosmoV_call(CState *state, int args) {
|
|||||||
invokeMethod(state, method->obj, method->func, args);
|
invokeMethod(state, method->obj, method->func, args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COBJ_OBJECT: {
|
case COBJ_OBJECT: { // object is being instantiated, making another object
|
||||||
CObjObject *protoObj = (CObjObject*)cosmoV_readObj(*val);
|
CObjObject *protoObj = (CObjObject*)cosmoV_readObj(*val);
|
||||||
CObjObject *newObj = cosmoO_newObject(state);
|
CObjObject *newObj = cosmoO_newObject(state);
|
||||||
newObj->proto = protoObj;
|
newObj->proto = protoObj;
|
||||||
@ -221,7 +221,7 @@ static inline bool isFalsey(StkPtr val) {
|
|||||||
return IS_NIL(*val) || (IS_BOOLEAN(*val) && !cosmoV_readBoolean(*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;
|
StkPtr key, val;
|
||||||
CObjObject *newObj = cosmoO_newObject(state);
|
CObjObject *newObj = cosmoO_newObject(state);
|
||||||
cosmoV_pushValue(state, cosmoV_newObj(newObj)); // so our GC doesn't free our new object
|
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: {
|
case OP_NEWOBJECT: {
|
||||||
uint16_t pairs = READUINT();
|
uint16_t pairs = READUINT();
|
||||||
cosmoV_pushObject(state, pairs);
|
cosmoV_makeObject(state, pairs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_GETOBJECT: {
|
case OP_GETOBJECT: {
|
||||||
|
@ -14,7 +14,7 @@ typedef enum {
|
|||||||
|
|
||||||
// args = # of pass parameters, nresults = # of expected results
|
// args = # of pass parameters, nresults = # of expected results
|
||||||
COSMO_API COSMOVMRESULT cosmoV_call(CState *state, int args);
|
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 bool cosmoV_getObject(CState *state, CObjObject *object, CValue key, CValue *val);
|
||||||
COSMO_API void cosmoV_error(CState *state, const char *format, ...);
|
COSMO_API void cosmoV_error(CState *state, const char *format, ...);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user