mirror of
https://github.com/CPunch/Cosmo.git
synced 2026-06-24 18:30:05 +00:00
Major refactoring, added classes, many bug fixes
This commit is contained in:
29
src/cparse.h
29
src/cparse.h
@@ -4,35 +4,6 @@
|
||||
#include "cosmo.h"
|
||||
#include "clex.h"
|
||||
|
||||
typedef struct {
|
||||
CToken name;
|
||||
int depth;
|
||||
bool isCaptured; // is the Local referenced in an upvalue?
|
||||
} Local;
|
||||
|
||||
typedef struct {
|
||||
uint8_t index;
|
||||
bool isLocal;
|
||||
} Upvalue;
|
||||
|
||||
typedef enum {
|
||||
FTYPE_FUNCTION,
|
||||
FTYPE_SCRIPT
|
||||
} FunctionType;
|
||||
|
||||
typedef struct CCompilerState {
|
||||
CObjFunction *function;
|
||||
FunctionType type;
|
||||
|
||||
Local locals[256];
|
||||
Upvalue upvalues[256];
|
||||
int localCount;
|
||||
int scopeDepth;
|
||||
int pushedValues;
|
||||
int savedPushed;
|
||||
struct CCompilerState* enclosing;
|
||||
} CCompilerState;
|
||||
|
||||
// compiles source into CChunk, if NULL is returned, a syntaxical error has occured and pushed onto the stack
|
||||
CObjFunction* cosmoP_compileString(CState *state, const char *source);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user