mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Added simple assignment, read more
I was coding earlier this week, but my brain was so foggy I ended up not knowing what I was doing. After a few days break, I've cleaned up the mess, which took hours. Changes: * Variables can be assigned * Added new value types as placeholders * Added 'compare' and 'assign' to the AST * Added duplicate opcode * Added functions to copy and free values * Max name length is 255 chars * Compound assigns are squeezed into one word To be completed: * Tests for this commit's changes * Compound assignments * Variable access
This commit is contained in:
@@ -12,11 +12,12 @@ typedef enum Toy_ValueType {
|
||||
TOY_VALUE_FLOAT,
|
||||
TOY_VALUE_STRING,
|
||||
TOY_VALUE_ARRAY,
|
||||
TOY_VALUE_DICTIONARY,
|
||||
TOY_VALUE_TABLE,
|
||||
TOY_VALUE_FUNCTION,
|
||||
TOY_VALUE_OPAQUE,
|
||||
|
||||
//TODO: type, any, consider 'stack' as a possible addition
|
||||
TOY_VALUE_TYPE,
|
||||
TOY_VALUE_ANY,
|
||||
TOY_VALUE_UNKNOWN, //The correct value is unknown, but will be determined later
|
||||
} Toy_ValueType;
|
||||
|
||||
//8 bytes in size
|
||||
@@ -26,10 +27,8 @@ typedef struct Toy_Value { //32 | 64 BITNESS
|
||||
int integer; //4 | 4
|
||||
float number; //4 | 4
|
||||
struct Toy_String* string; //4 | 8
|
||||
//TODO: arrays
|
||||
//TODO: dictonaries
|
||||
//TODO: functions
|
||||
//TODO: opaque
|
||||
//TODO: more types go here
|
||||
//TODO: consider 'stack' as a possible addition
|
||||
} as; //4 | 8
|
||||
|
||||
Toy_ValueType type; //4 | 4
|
||||
@@ -41,7 +40,7 @@ typedef struct Toy_Value { //32 | 64 BITNESS
|
||||
#define TOY_VALUE_IS_FLOAT(value) ((value).type == TOY_VALUE_FLOAT)
|
||||
#define TOY_VALUE_IS_STRING(value) ((value).type == TOY_VALUE_STRING)
|
||||
#define TOY_VALUE_IS_ARRAY(value) ((value).type == TOY_VALUE_ARRAY)
|
||||
#define TOY_VALUE_IS_DICTIONARY(value) ((value).type == TOY_VALUE_DICTIONARY)
|
||||
#define TOY_VALUE_IS_TABLE(value) ((value).type == TOY_VALUE_TABLE)
|
||||
#define TOY_VALUE_IS_FUNCTION(value) ((value).type == TOY_VALUE_FUNCTION)
|
||||
#define TOY_VALUE_IS_OPAQUE(value) ((value).type == TOY_VALUE_OPAQUE)
|
||||
|
||||
@@ -66,3 +65,5 @@ TOY_API bool Toy_private_isEqual(Toy_Value left, Toy_Value right);
|
||||
|
||||
unsigned int Toy_hashValue(Toy_Value value);
|
||||
|
||||
TOY_API Toy_Value Toy_copyValue(Toy_Value value);
|
||||
TOY_API void Toy_freeValue(Toy_Value value);
|
||||
|
||||
Reference in New Issue
Block a user