-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from ademyro/feature/strings
Feature/strings
- Loading branch information
Showing
30 changed files
with
744 additions
and
619 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ typedef enum { | |
OP_SUB, | ||
OP_MUL, | ||
OP_DIV, | ||
OP_CONCAT, | ||
// OP_INTERPOL, | ||
OP_SHL, | ||
OP_SHR, | ||
OP_BIT_AND, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef OBJ_H | ||
#define OBJ_H | ||
|
||
#include "common.h" | ||
#include "val.h" | ||
#include "vm.h" | ||
|
||
#define OBJ_TYPE(val) (VAL_AS_OBJ(val)->type) | ||
|
||
#define VAL_AS_STR(val) ((ObjStr *)VAL_AS_OBJ(val)) | ||
#define VAL_AS_CSTR(val) (((ObjStr *)VAL_AS_OBJ(val))->chars) | ||
|
||
typedef enum { | ||
OBJ_STR | ||
} ObjType; | ||
|
||
struct Obj { | ||
ObjType type; | ||
|
||
struct Obj *next; | ||
}; | ||
|
||
struct ObjStr { | ||
Obj obj; | ||
|
||
bool ownsStr; | ||
size_t length; | ||
const char *chars; | ||
}; | ||
|
||
/* | ||
we don’t need this function thanks to type checking, but if it | ||
ends up being absolutely necessary... let’s just keep it in | ||
here for now. | ||
static inline bool isObjType(Val val, ObjType type) { | ||
return IS_VAL_OBJ(val) && OBJ_TYPE(val) == type; | ||
} | ||
*/ | ||
|
||
ObjStr *allocStr(VM *vm, bool ownsStr, const char *chars, size_t length); | ||
|
||
void printObj(Val val); | ||
|
||
void freeObj(Obj *obj); | ||
|
||
size_t objAsStr(const char *buffer, Obj *obj); | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,6 @@ Tok emptyTok(); | |
|
||
char *copyLexeme(Tok tok); | ||
|
||
void trimStrTokQuotes(Tok *tok); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ typedef struct { | |
|
||
Val stack[STACK_MAX]; | ||
Val *stackTop; | ||
|
||
Obj *objs; | ||
} VM; | ||
|
||
typedef enum { | ||
|
Oops, something went wrong.