mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-05 08:10:05 +00:00
minor refactoring and typos
This commit is contained in:
parent
2836de090b
commit
3efee51224
@ -705,7 +705,7 @@ void printObject(CObj *o)
|
|||||||
switch (o->type) {
|
switch (o->type) {
|
||||||
case COBJ_STRING: {
|
case COBJ_STRING: {
|
||||||
CObjString *objStr = (CObjString *)o;
|
CObjString *objStr = (CObjString *)o;
|
||||||
printf("%.*s", objStr->length, objStr->str);
|
printf("<string> \"%.*s\"", objStr->length, objStr->str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COBJ_OBJECT: {
|
case COBJ_OBJECT: {
|
||||||
|
@ -41,7 +41,7 @@ struct CObj
|
|||||||
struct CObjString
|
struct CObjString
|
||||||
{
|
{
|
||||||
CommonHeader; // "is a" CObj
|
CommonHeader; // "is a" CObj
|
||||||
char *str; // NULL termincated string
|
char *str; // NULL terminated string
|
||||||
uint32_t hash; // for hashtable lookup
|
uint32_t hash; // for hashtable lookup
|
||||||
int length;
|
int length;
|
||||||
bool isIString;
|
bool isIString;
|
||||||
@ -138,6 +138,7 @@ struct CObjUpval
|
|||||||
#define cosmoV_readClosure(x) ((CObjClosure *)cosmoV_readRef(x))
|
#define cosmoV_readClosure(x) ((CObjClosure *)cosmoV_readRef(x))
|
||||||
|
|
||||||
#define cosmoO_readCString(x) ((CObjString *)x)->str
|
#define cosmoO_readCString(x) ((CObjString *)x)->str
|
||||||
|
#define cosmoO_readType(x) ((CObj *)x)->type
|
||||||
|
|
||||||
static inline bool isObjType(CValue val, CObjType type)
|
static inline bool isObjType(CValue val, CObjType type)
|
||||||
{
|
{
|
||||||
|
@ -59,10 +59,10 @@ typedef struct CCompilerState
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
CState *state;
|
||||||
CLexState *lex;
|
CLexState *lex;
|
||||||
CCompilerState *compiler;
|
CCompilerState *compiler;
|
||||||
CObjString *module; // name of the module
|
CObjString *module; // name of the module
|
||||||
CState *state;
|
|
||||||
CToken current;
|
CToken current;
|
||||||
CToken previous; // token right after the current token
|
CToken previous; // token right after the current token
|
||||||
bool hadError;
|
bool hadError;
|
||||||
|
@ -123,7 +123,6 @@ void printValue(CValue val);
|
|||||||
COSMO_API bool cosmoV_equal(CState *state, CValue valA, CValue valB);
|
COSMO_API bool cosmoV_equal(CState *state, CValue valA, CValue valB);
|
||||||
COSMO_API CObjString *cosmoV_toString(CState *state, CValue val);
|
COSMO_API CObjString *cosmoV_toString(CState *state, CValue val);
|
||||||
COSMO_API cosmo_Number cosmoV_toNumber(CState *state, CValue val);
|
COSMO_API cosmo_Number cosmoV_toNumber(CState *state, CValue val);
|
||||||
COSMO_API const char *
|
COSMO_API const char *cosmoV_typeStr(CValue val);
|
||||||
cosmoV_typeStr(CValue val); // return constant char array for corresponding type
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -229,11 +229,7 @@ static bool callCFunction(CState *state, CosmoCFunction cfunc, int args, int nre
|
|||||||
{
|
{
|
||||||
StkPtr savedBase = cosmoV_getTop(state, args);
|
StkPtr savedBase = cosmoV_getTop(state, args);
|
||||||
|
|
||||||
// we don't want a GC event during c api because we don't actually trust the user to know how to
|
|
||||||
// evade the GC
|
|
||||||
cosmoM_freezeGC(state);
|
|
||||||
int nres = cfunc(state, args, savedBase + 1);
|
int nres = cfunc(state, args, savedBase + 1);
|
||||||
cosmoM_unfreezeGC(state);
|
|
||||||
|
|
||||||
// caller function wasn't expecting this many return values, cap it
|
// caller function wasn't expecting this many return values, cap it
|
||||||
if (nres > nresults)
|
if (nres > nresults)
|
||||||
|
Loading…
Reference in New Issue
Block a user