mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Renamed Toy_ModuleBuilder to Toy_ModuleCompiler
I also noticed that Toy_ModuleBundle isn't being used right now.
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "toy_lexer.h"
|
#include "toy_lexer.h"
|
||||||
#include "toy_parser.h"
|
#include "toy_parser.h"
|
||||||
#include "toy_module_builder.h"
|
#include "toy_module_compiler.h"
|
||||||
#include "toy_vm.h"
|
#include "toy_vm.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -332,7 +332,7 @@ int repl(const char* filepath) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buffer = Toy_compileModuleBuilder(ast);
|
void* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
Toy_bindVM(&vm, &module, runCount++ > 0);
|
Toy_bindVM(&vm, &module, runCount++ > 0);
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ int main(int argc, const char* argv[]) {
|
|||||||
|
|
||||||
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
Toy_Ast* ast = Toy_scanParser(&bucket, &parser);
|
Toy_Ast* ast = Toy_scanParser(&bucket, &parser);
|
||||||
void* buffer = Toy_compileModuleBuilder(ast);
|
void* buffer = Toy_compileModule(ast);
|
||||||
Toy_freeBucket(&bucket);
|
Toy_freeBucket(&bucket);
|
||||||
free(source);
|
free(source);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "toy_module_bundle.h"
|
#include "toy_module_bundle.h"
|
||||||
#include "toy_console_colors.h"
|
#include "toy_console_colors.h"
|
||||||
|
|
||||||
#include "toy_module_builder.h"
|
#include "toy_module_compiler.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -87,7 +87,7 @@ void Toy_appendModuleBundle(Toy_ModuleBundle* bundle, Toy_Ast* ast) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* module = Toy_compileModuleBuilder(ast);
|
void* module = Toy_compileModule(ast);
|
||||||
|
|
||||||
//don't try writing an empty module
|
//don't try writing an empty module
|
||||||
if (module == NULL) {
|
if (module == NULL) {
|
||||||
|
|||||||
@@ -18,3 +18,5 @@ TOY_API void Toy_freeModuleBundle(Toy_ModuleBundle* bundle);
|
|||||||
//load module bundle with external data (makes an internal copy)
|
//load module bundle with external data (makes an internal copy)
|
||||||
TOY_API void Toy_bindModuleBundle(Toy_ModuleBundle* bundle, unsigned char* ptr, unsigned int size);
|
TOY_API void Toy_bindModuleBundle(Toy_ModuleBundle* bundle, unsigned char* ptr, unsigned int size);
|
||||||
TOY_API Toy_Module Toy_extractModuleFromBundle(Toy_ModuleBundle* bundle, unsigned char index);
|
TOY_API Toy_Module Toy_extractModuleFromBundle(Toy_ModuleBundle* bundle, unsigned char index);
|
||||||
|
|
||||||
|
//NOTE: 'Toy_ModuleBundle' isn't used anywhere?
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "toy_module_builder.h"
|
#include "toy_module_compiler.h"
|
||||||
#include "toy_console_colors.h"
|
#include "toy_console_colors.h"
|
||||||
|
|
||||||
#include "toy_opcodes.h"
|
#include "toy_opcodes.h"
|
||||||
@@ -43,7 +43,7 @@ void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int c
|
|||||||
ptr = (Toy_private_EscapeArray*)realloc(ptr, capacity * sizeof(Toy_private_EscapeEntry_t) + sizeof(Toy_private_EscapeArray));
|
ptr = (Toy_private_EscapeArray*)realloc(ptr, capacity * sizeof(Toy_private_EscapeEntry_t) + sizeof(Toy_private_EscapeArray));
|
||||||
|
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: Failed to resize an escape array within 'Toy_ModuleBuilder' from %d to %d capacity\n" TOY_CC_RESET, (int)originalCapacity, (int)capacity);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: Failed to resize an escape array within 'Toy_ModuleCompiler' from %d to %d capacity\n" TOY_CC_RESET, (int)originalCapacity, (int)capacity);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ static void expand(unsigned char** handle, unsigned int* capacity, unsigned int*
|
|||||||
(*handle) = realloc((*handle), (*capacity));
|
(*handle) = realloc((*handle), (*capacity));
|
||||||
|
|
||||||
if ((*handle) == NULL) {
|
if ((*handle) == NULL) {
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: Failed to allocate %d space for a part of 'Toy_ModuleBuilder'\n" TOY_CC_RESET, (int)(*capacity));
|
fprintf(stderr, TOY_CC_ERROR "ERROR: Failed to allocate %d space for a part of 'Toy_ModuleCompiler'\n" TOY_CC_RESET, (int)(*capacity));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,12 +108,12 @@ static void emitFloat(unsigned char** handle, unsigned int* capacity, unsigned i
|
|||||||
//simply get the address (always an integer)
|
//simply get the address (always an integer)
|
||||||
#define CURRENT_ADDRESS(mb, part) ((*mb)->part##Count)
|
#define CURRENT_ADDRESS(mb, part) ((*mb)->part##Count)
|
||||||
|
|
||||||
static void emitToJumpTable(Toy_ModuleBuilder** mb, unsigned int startAddr) {
|
static void emitToJumpTable(Toy_ModuleCompiler** mb, unsigned int startAddr) {
|
||||||
EMIT_INT(mb, code, (*mb)->jumpsCount); //mark the jump index in the code
|
EMIT_INT(mb, code, (*mb)->jumpsCount); //mark the jump index in the code
|
||||||
EMIT_INT(mb, jumps, startAddr); //save address at the jump index
|
EMIT_INT(mb, jumps, startAddr); //save address at the jump index
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int emitString(Toy_ModuleBuilder** mb, Toy_String* str) {
|
static unsigned int emitString(Toy_ModuleCompiler** mb, Toy_String* str) {
|
||||||
//4-byte alignment
|
//4-byte alignment
|
||||||
unsigned int length = str->info.length + 1;
|
unsigned int length = str->info.length + 1;
|
||||||
if (length % 4 != 0) {
|
if (length % 4 != 0) {
|
||||||
@@ -146,10 +146,10 @@ static unsigned int emitString(Toy_ModuleBuilder** mb, Toy_String* str) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeModuleBuilderCode(Toy_ModuleBuilder** mb, Toy_Ast* ast); //forward declare for recursion
|
static unsigned int writeModuleCompilerCode(Toy_ModuleCompiler** mb, Toy_Ast* ast); //forward declare for recursion
|
||||||
static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAssign ast, bool chainedAssignment); //forward declare for chaining of var declarations
|
static unsigned int writeInstructionAssign(Toy_ModuleCompiler** mb, Toy_AstVarAssign ast, bool chainedAssignment); //forward declare for chaining of var declarations
|
||||||
|
|
||||||
static unsigned int writeInstructionValue(Toy_ModuleBuilder** mb, Toy_AstValue ast) {
|
static unsigned int writeInstructionValue(Toy_ModuleCompiler** mb, Toy_AstValue ast) {
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_READ);
|
EMIT_BYTE(mb, code, TOY_OPCODE_READ);
|
||||||
EMIT_BYTE(mb, code, ast.value.type);
|
EMIT_BYTE(mb, code, ast.value.type);
|
||||||
|
|
||||||
@@ -196,11 +196,11 @@ static unsigned int writeInstructionValue(Toy_ModuleBuilder** mb, Toy_AstValue a
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionUnary(Toy_ModuleBuilder** mb, Toy_AstUnary ast) {
|
static unsigned int writeInstructionUnary(Toy_ModuleCompiler** mb, Toy_AstUnary ast) {
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
|
|
||||||
if (ast.flag == TOY_AST_FLAG_NEGATE) {
|
if (ast.flag == TOY_AST_FLAG_NEGATE) {
|
||||||
result = writeModuleBuilderCode(mb, ast.child);
|
result = writeModuleCompilerCode(mb, ast.child);
|
||||||
|
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_NEGATE);
|
EMIT_BYTE(mb, code, TOY_OPCODE_NEGATE);
|
||||||
|
|
||||||
@@ -304,10 +304,10 @@ static unsigned int writeInstructionUnary(Toy_ModuleBuilder** mb, Toy_AstUnary a
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionBinary(Toy_ModuleBuilder** mb, Toy_AstBinary ast) {
|
static unsigned int writeInstructionBinary(Toy_ModuleCompiler** mb, Toy_AstBinary ast) {
|
||||||
//left, then right, then the binary's operation
|
//left, then right, then the binary's operation
|
||||||
writeModuleBuilderCode(mb, ast.left);
|
writeModuleCompilerCode(mb, ast.left);
|
||||||
writeModuleBuilderCode(mb, ast.right);
|
writeModuleCompilerCode(mb, ast.right);
|
||||||
|
|
||||||
if (ast.flag == TOY_AST_FLAG_ADD) {
|
if (ast.flag == TOY_AST_FLAG_ADD) {
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_ADD);
|
EMIT_BYTE(mb, code,TOY_OPCODE_ADD);
|
||||||
@@ -341,9 +341,9 @@ static unsigned int writeInstructionBinary(Toy_ModuleBuilder** mb, Toy_AstBinary
|
|||||||
return 1; //leaves only 1 value on the stack
|
return 1; //leaves only 1 value on the stack
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionBinaryShortCircuit(Toy_ModuleBuilder** mb, Toy_AstBinaryShortCircuit ast) {
|
static unsigned int writeInstructionBinaryShortCircuit(Toy_ModuleCompiler** mb, Toy_AstBinaryShortCircuit ast) {
|
||||||
//lhs
|
//lhs
|
||||||
writeModuleBuilderCode(mb, ast.left);
|
writeModuleCompilerCode(mb, ast.left);
|
||||||
|
|
||||||
//duplicate the top (so the lhs can be 'returned' by this expression, if needed)
|
//duplicate the top (so the lhs can be 'returned' by this expression, if needed)
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_DUPLICATE);
|
EMIT_BYTE(mb, code,TOY_OPCODE_DUPLICATE);
|
||||||
@@ -382,7 +382,7 @@ static unsigned int writeInstructionBinaryShortCircuit(Toy_ModuleBuilder** mb, T
|
|||||||
EMIT_BYTE(mb, code, 0);
|
EMIT_BYTE(mb, code, 0);
|
||||||
|
|
||||||
//rhs
|
//rhs
|
||||||
writeModuleBuilderCode(mb, ast.right);
|
writeModuleCompilerCode(mb, ast.right);
|
||||||
|
|
||||||
//set the parameter
|
//set the parameter
|
||||||
OVERWRITE_INT(mb, code, paramAddr, CURRENT_ADDRESS(mb, code) - (paramAddr + 4));
|
OVERWRITE_INT(mb, code, paramAddr, CURRENT_ADDRESS(mb, code) - (paramAddr + 4));
|
||||||
@@ -390,10 +390,10 @@ static unsigned int writeInstructionBinaryShortCircuit(Toy_ModuleBuilder** mb, T
|
|||||||
return 1; //leaves only 1 value on the stack
|
return 1; //leaves only 1 value on the stack
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionCompare(Toy_ModuleBuilder** mb, Toy_AstCompare ast) {
|
static unsigned int writeInstructionCompare(Toy_ModuleCompiler** mb, Toy_AstCompare ast) {
|
||||||
//left, then right, then the compare's operation
|
//left, then right, then the compare's operation
|
||||||
writeModuleBuilderCode(mb, ast.left);
|
writeModuleCompilerCode(mb, ast.left);
|
||||||
writeModuleBuilderCode(mb, ast.right);
|
writeModuleCompilerCode(mb, ast.right);
|
||||||
|
|
||||||
if (ast.flag == TOY_AST_FLAG_COMPARE_EQUAL) {
|
if (ast.flag == TOY_AST_FLAG_COMPARE_EQUAL) {
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_COMPARE_EQUAL);
|
EMIT_BYTE(mb, code,TOY_OPCODE_COMPARE_EQUAL);
|
||||||
@@ -432,13 +432,13 @@ static unsigned int writeInstructionCompare(Toy_ModuleBuilder** mb, Toy_AstCompa
|
|||||||
return 1; //leaves only 1 value on the stack
|
return 1; //leaves only 1 value on the stack
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionGroup(Toy_ModuleBuilder** mb, Toy_AstGroup ast) {
|
static unsigned int writeInstructionGroup(Toy_ModuleCompiler** mb, Toy_AstGroup ast) {
|
||||||
//not certain what this leaves
|
//not certain what this leaves
|
||||||
return writeModuleBuilderCode(mb, ast.child);
|
return writeModuleCompilerCode(mb, ast.child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionCompound(Toy_ModuleBuilder** mb, Toy_AstCompound ast) {
|
static unsigned int writeInstructionCompound(Toy_ModuleCompiler** mb, Toy_AstCompound ast) {
|
||||||
unsigned int result = writeModuleBuilderCode(mb, ast.child);
|
unsigned int result = writeModuleCompilerCode(mb, ast.child);
|
||||||
|
|
||||||
if (ast.flag == TOY_AST_FLAG_COMPOUND_ARRAY) {
|
if (ast.flag == TOY_AST_FLAG_COMPOUND_ARRAY) {
|
||||||
//signal how many values to read in as array elements
|
//signal how many values to read in as array elements
|
||||||
@@ -475,12 +475,12 @@ static unsigned int writeInstructionCompound(Toy_ModuleBuilder** mb, Toy_AstComp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionAggregate(Toy_ModuleBuilder** mb, Toy_AstAggregate ast) {
|
static unsigned int writeInstructionAggregate(Toy_ModuleCompiler** mb, Toy_AstAggregate ast) {
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
|
|
||||||
//left, then right
|
//left, then right
|
||||||
result += writeModuleBuilderCode(mb, ast.left);
|
result += writeModuleCompilerCode(mb, ast.left);
|
||||||
result += writeModuleBuilderCode(mb, ast.right);
|
result += writeModuleCompilerCode(mb, ast.right);
|
||||||
|
|
||||||
if (ast.flag == TOY_AST_FLAG_COLLECTION) {
|
if (ast.flag == TOY_AST_FLAG_COLLECTION) {
|
||||||
//collections are handled above
|
//collections are handled above
|
||||||
@@ -508,10 +508,10 @@ static unsigned int writeInstructionAggregate(Toy_ModuleBuilder** mb, Toy_AstAgg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionAssert(Toy_ModuleBuilder** mb, Toy_AstAssert ast) {
|
static unsigned int writeInstructionAssert(Toy_ModuleCompiler** mb, Toy_AstAssert ast) {
|
||||||
//the thing to print
|
//the thing to print
|
||||||
writeModuleBuilderCode(mb, ast.child);
|
writeModuleCompilerCode(mb, ast.child);
|
||||||
writeModuleBuilderCode(mb, ast.message);
|
writeModuleCompilerCode(mb, ast.message);
|
||||||
|
|
||||||
//output the print opcode
|
//output the print opcode
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_ASSERT);
|
EMIT_BYTE(mb, code, TOY_OPCODE_ASSERT);
|
||||||
@@ -524,9 +524,9 @@ static unsigned int writeInstructionAssert(Toy_ModuleBuilder** mb, Toy_AstAssert
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionIfThenElse(Toy_ModuleBuilder** mb, Toy_AstIfThenElse ast) {
|
static unsigned int writeInstructionIfThenElse(Toy_ModuleCompiler** mb, Toy_AstIfThenElse ast) {
|
||||||
//cond-branch
|
//cond-branch
|
||||||
writeModuleBuilderCode(mb, ast.condBranch);
|
writeModuleCompilerCode(mb, ast.condBranch);
|
||||||
|
|
||||||
//emit the jump word (opcode, type, condition, padding)
|
//emit the jump word (opcode, type, condition, padding)
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_JUMP);
|
EMIT_BYTE(mb, code, TOY_OPCODE_JUMP);
|
||||||
@@ -537,7 +537,7 @@ static unsigned int writeInstructionIfThenElse(Toy_ModuleBuilder** mb, Toy_AstIf
|
|||||||
unsigned int thenParamAddr = SKIP_INT(mb, code); //parameter to be written later
|
unsigned int thenParamAddr = SKIP_INT(mb, code); //parameter to be written later
|
||||||
|
|
||||||
//emit then-branch
|
//emit then-branch
|
||||||
writeModuleBuilderCode(mb, ast.thenBranch);
|
writeModuleCompilerCode(mb, ast.thenBranch);
|
||||||
|
|
||||||
if (ast.elseBranch != NULL) {
|
if (ast.elseBranch != NULL) {
|
||||||
//emit the jump-to-end (opcode, type, condition, padding)
|
//emit the jump-to-end (opcode, type, condition, padding)
|
||||||
@@ -552,7 +552,7 @@ static unsigned int writeInstructionIfThenElse(Toy_ModuleBuilder** mb, Toy_AstIf
|
|||||||
OVERWRITE_INT(mb, code, thenParamAddr, CURRENT_ADDRESS(mb, code) - (thenParamAddr + 4));
|
OVERWRITE_INT(mb, code, thenParamAddr, CURRENT_ADDRESS(mb, code) - (thenParamAddr + 4));
|
||||||
|
|
||||||
//emit the else branch
|
//emit the else branch
|
||||||
writeModuleBuilderCode(mb, ast.elseBranch);
|
writeModuleCompilerCode(mb, ast.elseBranch);
|
||||||
|
|
||||||
//specify the ending position for the else branch
|
//specify the ending position for the else branch
|
||||||
OVERWRITE_INT(mb, code, elseParamAddr, CURRENT_ADDRESS(mb, code) - (elseParamAddr + 4));
|
OVERWRITE_INT(mb, code, elseParamAddr, CURRENT_ADDRESS(mb, code) - (elseParamAddr + 4));
|
||||||
@@ -566,12 +566,12 @@ static unsigned int writeInstructionIfThenElse(Toy_ModuleBuilder** mb, Toy_AstIf
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionWhileThen(Toy_ModuleBuilder** mb, Toy_AstWhileThen ast) {
|
static unsigned int writeInstructionWhileThen(Toy_ModuleCompiler** mb, Toy_AstWhileThen ast) {
|
||||||
//begin
|
//begin
|
||||||
unsigned int beginAddr = CURRENT_ADDRESS(mb, code);
|
unsigned int beginAddr = CURRENT_ADDRESS(mb, code);
|
||||||
|
|
||||||
//cond-branch
|
//cond-branch
|
||||||
writeModuleBuilderCode(mb, ast.condBranch);
|
writeModuleCompilerCode(mb, ast.condBranch);
|
||||||
|
|
||||||
//emit the jump word (opcode, type, condition, padding)
|
//emit the jump word (opcode, type, condition, padding)
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_JUMP);
|
EMIT_BYTE(mb, code, TOY_OPCODE_JUMP);
|
||||||
@@ -582,7 +582,7 @@ static unsigned int writeInstructionWhileThen(Toy_ModuleBuilder** mb, Toy_AstWhi
|
|||||||
unsigned int paramAddr = SKIP_INT(mb, code); //parameter to be written later
|
unsigned int paramAddr = SKIP_INT(mb, code); //parameter to be written later
|
||||||
|
|
||||||
//emit then-branch
|
//emit then-branch
|
||||||
writeModuleBuilderCode(mb, ast.thenBranch);
|
writeModuleCompilerCode(mb, ast.thenBranch);
|
||||||
|
|
||||||
//jump to begin to repeat the conditional test
|
//jump to begin to repeat the conditional test
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_JUMP);
|
EMIT_BYTE(mb, code, TOY_OPCODE_JUMP);
|
||||||
@@ -627,7 +627,7 @@ static unsigned int writeInstructionWhileThen(Toy_ModuleBuilder** mb, Toy_AstWhi
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionBreak(Toy_ModuleBuilder** mb, Toy_AstBreak ast) {
|
static unsigned int writeInstructionBreak(Toy_ModuleCompiler** mb, Toy_AstBreak ast) {
|
||||||
//unused
|
//unused
|
||||||
(void)ast;
|
(void)ast;
|
||||||
|
|
||||||
@@ -651,7 +651,7 @@ static unsigned int writeInstructionBreak(Toy_ModuleBuilder** mb, Toy_AstBreak a
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionContinue(Toy_ModuleBuilder** mb, Toy_AstContinue ast) {
|
static unsigned int writeInstructionContinue(Toy_ModuleCompiler** mb, Toy_AstContinue ast) {
|
||||||
//unused
|
//unused
|
||||||
(void)ast;
|
(void)ast;
|
||||||
|
|
||||||
@@ -675,9 +675,9 @@ static unsigned int writeInstructionContinue(Toy_ModuleBuilder** mb, Toy_AstCont
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionPrint(Toy_ModuleBuilder** mb, Toy_AstPrint ast) {
|
static unsigned int writeInstructionPrint(Toy_ModuleCompiler** mb, Toy_AstPrint ast) {
|
||||||
//the thing to print
|
//the thing to print
|
||||||
writeModuleBuilderCode(mb, ast.child);
|
writeModuleCompilerCode(mb, ast.child);
|
||||||
|
|
||||||
//output the print opcode
|
//output the print opcode
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_PRINT);
|
EMIT_BYTE(mb, code,TOY_OPCODE_PRINT);
|
||||||
@@ -690,13 +690,13 @@ static unsigned int writeInstructionPrint(Toy_ModuleBuilder** mb, Toy_AstPrint a
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionVarDeclare(Toy_ModuleBuilder** mb, Toy_AstVarDeclare ast) {
|
static unsigned int writeInstructionVarDeclare(Toy_ModuleCompiler** mb, Toy_AstVarDeclare ast) {
|
||||||
//if we're dealing with chained assignments, hijack the next assignment with 'chainedAssignment' set to true
|
//if we're dealing with chained assignments, hijack the next assignment with 'chainedAssignment' set to true
|
||||||
if (checkForChaining(ast.expr)) {
|
if (checkForChaining(ast.expr)) {
|
||||||
writeInstructionAssign(mb, ast.expr->varAssign, true);
|
writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
writeModuleBuilderCode(mb, ast.expr); //default value
|
writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
//delcare with the given name string
|
//delcare with the given name string
|
||||||
@@ -710,7 +710,7 @@ static unsigned int writeInstructionVarDeclare(Toy_ModuleBuilder** mb, Toy_AstVa
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAssign ast, bool chainedAssignment) {
|
static unsigned int writeInstructionAssign(Toy_ModuleCompiler** mb, Toy_AstVarAssign ast, bool chainedAssignment) {
|
||||||
unsigned int result = 0;
|
unsigned int result = 0;
|
||||||
|
|
||||||
//target is a name string
|
//target is a name string
|
||||||
@@ -729,15 +729,15 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
|
|
||||||
//target is an indexing of some compound value
|
//target is an indexing of some compound value
|
||||||
else if (ast.target->type == TOY_AST_AGGREGATE && ast.target->aggregate.flag == TOY_AST_FLAG_INDEX) {
|
else if (ast.target->type == TOY_AST_AGGREGATE && ast.target->aggregate.flag == TOY_AST_FLAG_INDEX) {
|
||||||
writeModuleBuilderCode(mb, ast.target->aggregate.left); //any deeper indexing will just work, using reference values
|
writeModuleCompilerCode(mb, ast.target->aggregate.left); //any deeper indexing will just work, using reference values
|
||||||
writeModuleBuilderCode(mb, ast.target->aggregate.right); //key
|
writeModuleCompilerCode(mb, ast.target->aggregate.right); //key
|
||||||
|
|
||||||
//if we're dealing with chained assignments, hijack the next assignment with 'chainedAssignment' set to true
|
//if we're dealing with chained assignments, hijack the next assignment with 'chainedAssignment' set to true
|
||||||
if (checkForChaining(ast.expr)) {
|
if (checkForChaining(ast.expr)) {
|
||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_ASSIGN_COMPOUND); //uses the top three values on the stack
|
EMIT_BYTE(mb, code, TOY_OPCODE_ASSIGN_COMPOUND); //uses the top three values on the stack
|
||||||
@@ -762,7 +762,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_ASSIGN);
|
EMIT_BYTE(mb, code, TOY_OPCODE_ASSIGN);
|
||||||
@@ -781,7 +781,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_ADD);
|
EMIT_BYTE(mb, code,TOY_OPCODE_ADD);
|
||||||
@@ -800,7 +800,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_SUBTRACT);
|
EMIT_BYTE(mb, code,TOY_OPCODE_SUBTRACT);
|
||||||
@@ -819,7 +819,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_MULTIPLY);
|
EMIT_BYTE(mb, code,TOY_OPCODE_MULTIPLY);
|
||||||
@@ -838,7 +838,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_DIVIDE);
|
EMIT_BYTE(mb, code,TOY_OPCODE_DIVIDE);
|
||||||
@@ -857,7 +857,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
result += writeInstructionAssign(mb, ast.expr->varAssign, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result += writeModuleBuilderCode(mb, ast.expr); //default value
|
result += writeModuleCompilerCode(mb, ast.expr); //default value
|
||||||
}
|
}
|
||||||
|
|
||||||
EMIT_BYTE(mb, code,TOY_OPCODE_MODULO);
|
EMIT_BYTE(mb, code,TOY_OPCODE_MODULO);
|
||||||
@@ -874,7 +874,7 @@ static unsigned int writeInstructionAssign(Toy_ModuleBuilder** mb, Toy_AstVarAss
|
|||||||
return result + (chainedAssignment ? 1 : 0);
|
return result + (chainedAssignment ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionAccess(Toy_ModuleBuilder** mb, Toy_AstVarAccess ast) {
|
static unsigned int writeInstructionAccess(Toy_ModuleCompiler** mb, Toy_AstVarAccess ast) {
|
||||||
if (!(ast.child->type == TOY_AST_VALUE && TOY_VALUE_IS_STRING(ast.child->value.value) && TOY_VALUE_AS_STRING(ast.child->value.value)->info.type == TOY_STRING_NAME)) {
|
if (!(ast.child->type == TOY_AST_VALUE && TOY_VALUE_IS_STRING(ast.child->value.value) && TOY_VALUE_AS_STRING(ast.child->value.value)->info.type == TOY_STRING_NAME)) {
|
||||||
fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Found a non-name-string in a value node when trying to write access\n" TOY_CC_RESET);
|
fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Found a non-name-string in a value node when trying to write access\n" TOY_CC_RESET);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@@ -899,13 +899,14 @@ static unsigned int writeInstructionAccess(Toy_ModuleBuilder** mb, Toy_AstVarAcc
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeInstructionFnDeclare(Toy_ModuleBuilder** mb, Toy_AstFnDeclare ast) {
|
static unsigned int writeInstructionFnDeclare(Toy_ModuleCompiler** mb, Toy_AstFnDeclare ast) {
|
||||||
|
//URGENT: currently a no-op
|
||||||
(void)mb;
|
(void)mb;
|
||||||
(void)ast;
|
(void)ast;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int writeModuleBuilderCode(Toy_ModuleBuilder** mb, Toy_Ast* ast) {
|
static unsigned int writeModuleCompilerCode(Toy_ModuleCompiler** mb, Toy_Ast* ast) {
|
||||||
if (ast == NULL) {
|
if (ast == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -930,8 +931,8 @@ static unsigned int writeModuleBuilderCode(Toy_ModuleBuilder** mb, Toy_Ast* ast)
|
|||||||
(*mb)->currentScopeDepth++;
|
(*mb)->currentScopeDepth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
result += writeModuleBuilderCode(mb, ast->block.child);
|
result += writeModuleCompilerCode(mb, ast->block.child);
|
||||||
result += writeModuleBuilderCode(mb, ast->block.next);
|
result += writeModuleCompilerCode(mb, ast->block.next);
|
||||||
|
|
||||||
if (ast->block.innerScope) {
|
if (ast->block.innerScope) {
|
||||||
EMIT_BYTE(mb, code, TOY_OPCODE_SCOPE_POP);
|
EMIT_BYTE(mb, code, TOY_OPCODE_SCOPE_POP);
|
||||||
@@ -1034,9 +1035,9 @@ static unsigned int writeModuleBuilderCode(Toy_ModuleBuilder** mb, Toy_Ast* ast)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* writeModuleBuilder(Toy_ModuleBuilder* mb, Toy_Ast* ast) {
|
static void* writeModuleCompiler(Toy_ModuleCompiler* mb, Toy_Ast* ast) {
|
||||||
//code
|
//code
|
||||||
writeModuleBuilderCode(&mb, ast);
|
writeModuleCompilerCode(&mb, ast);
|
||||||
|
|
||||||
EMIT_BYTE(&mb, code, TOY_OPCODE_RETURN); //end terminator
|
EMIT_BYTE(&mb, code, TOY_OPCODE_RETURN); //end terminator
|
||||||
EMIT_BYTE(&mb, code, 0); //4-byte alignment
|
EMIT_BYTE(&mb, code, 0); //4-byte alignment
|
||||||
@@ -1121,48 +1122,48 @@ static void* writeModuleBuilder(Toy_ModuleBuilder* mb, Toy_Ast* ast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//exposed functions
|
//exposed functions
|
||||||
void* Toy_compileModuleBuilder(Toy_Ast* ast) {
|
void* Toy_compileModule(Toy_Ast* ast) {
|
||||||
//setup
|
//setup
|
||||||
Toy_ModuleBuilder builder;
|
Toy_ModuleCompiler compiler;
|
||||||
|
|
||||||
builder.code = NULL;
|
compiler.code = NULL;
|
||||||
builder.codeCapacity = 0;
|
compiler.codeCapacity = 0;
|
||||||
builder.codeCount = 0;
|
compiler.codeCount = 0;
|
||||||
|
|
||||||
builder.jumps = NULL;
|
compiler.jumps = NULL;
|
||||||
builder.jumpsCapacity = 0;
|
compiler.jumpsCapacity = 0;
|
||||||
builder.jumpsCount = 0;
|
compiler.jumpsCount = 0;
|
||||||
|
|
||||||
builder.param = NULL;
|
compiler.param = NULL;
|
||||||
builder.paramCapacity = 0;
|
compiler.paramCapacity = 0;
|
||||||
builder.paramCount = 0;
|
compiler.paramCount = 0;
|
||||||
|
|
||||||
builder.data = NULL;
|
compiler.data = NULL;
|
||||||
builder.dataCapacity = 0;
|
compiler.dataCapacity = 0;
|
||||||
builder.dataCount = 0;
|
compiler.dataCount = 0;
|
||||||
|
|
||||||
builder.subs = NULL;
|
compiler.subs = NULL;
|
||||||
builder.subsCapacity = 0;
|
compiler.subsCapacity = 0;
|
||||||
builder.subsCount = 0;
|
compiler.subsCount = 0;
|
||||||
|
|
||||||
builder.currentScopeDepth = 0;
|
compiler.currentScopeDepth = 0;
|
||||||
builder.breakEscapes = Toy_private_resizeEscapeArray(NULL, TOY_ESCAPE_INITIAL_CAPACITY);
|
compiler.breakEscapes = Toy_private_resizeEscapeArray(NULL, TOY_ESCAPE_INITIAL_CAPACITY);
|
||||||
builder.continueEscapes = Toy_private_resizeEscapeArray(NULL, TOY_ESCAPE_INITIAL_CAPACITY);
|
compiler.continueEscapes = Toy_private_resizeEscapeArray(NULL, TOY_ESCAPE_INITIAL_CAPACITY);
|
||||||
|
|
||||||
builder.panic = false;
|
compiler.panic = false;
|
||||||
|
|
||||||
//build
|
//compile the ast to memory
|
||||||
void * buffer = writeModuleBuilder(&builder, ast);
|
void * buffer = writeModuleCompiler(&compiler, ast);
|
||||||
|
|
||||||
//cleanup
|
//cleanup
|
||||||
Toy_private_resizeEscapeArray(builder.breakEscapes, 0);
|
Toy_private_resizeEscapeArray(compiler.breakEscapes, 0);
|
||||||
Toy_private_resizeEscapeArray(builder.continueEscapes, 0);
|
Toy_private_resizeEscapeArray(compiler.continueEscapes, 0);
|
||||||
|
|
||||||
free(builder.param);
|
free(compiler.param);
|
||||||
free(builder.code);
|
free(compiler.code);
|
||||||
free(builder.jumps);
|
free(compiler.jumps);
|
||||||
free(builder.data);
|
free(compiler.data);
|
||||||
free(builder.subs);
|
free(compiler.subs);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ typedef struct Toy_private_EscapeArray {
|
|||||||
TOY_API void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity);
|
TOY_API void* Toy_private_resizeEscapeArray(Toy_private_EscapeArray* ptr, unsigned int capacity);
|
||||||
|
|
||||||
//structure for holding the module as it is built
|
//structure for holding the module as it is built
|
||||||
typedef struct Toy_ModuleBuilder {
|
typedef struct Toy_ModuleCompiler {
|
||||||
unsigned char* code; //the instruction set
|
unsigned char* code; //the instruction set
|
||||||
unsigned int codeCapacity;
|
unsigned int codeCapacity;
|
||||||
unsigned int codeCount;
|
unsigned int codeCount;
|
||||||
@@ -57,6 +57,6 @@ typedef struct Toy_ModuleBuilder {
|
|||||||
|
|
||||||
//compilation errors
|
//compilation errors
|
||||||
bool panic;
|
bool panic;
|
||||||
} Toy_ModuleBuilder;
|
} Toy_ModuleCompiler;
|
||||||
|
|
||||||
TOY_API void* Toy_compileModuleBuilder(Toy_Ast* ast);
|
TOY_API void* Toy_compileModule(Toy_Ast* ast);
|
||||||
@@ -206,7 +206,7 @@ char* Toy_getStringRawBuffer(Toy_String* str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int deepCompareUtil(Toy_String* left, Toy_String* right, const char** leftHead, const char** rightHead) {
|
static int deepCompareUtil(Toy_String* left, Toy_String* right, const char** leftHead, const char** rightHead) {
|
||||||
//WARNING: this function can't handle strings of zero length
|
//NOTE: this function can't handle strings of zero length
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
//if it's the same object, of course they match
|
//if it's the same object, of course they match
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "toy_module_builder.h"
|
#include "toy_module_compiler.h"
|
||||||
#include "toy_console_colors.h"
|
#include "toy_console_colors.h"
|
||||||
|
|
||||||
#include "toy_opcodes.h"
|
#include "toy_opcodes.h"
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
//NOTE: This set of tests also covers 'Toy_Module'
|
//NOTE: This set of tests also covers 'Toy_Module'
|
||||||
|
|
||||||
//tests
|
//tests
|
||||||
int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
int test_compiler_expressions(Toy_Bucket** bucketHandle) {
|
||||||
//simple test to ensure the header looks right with an empty ast
|
//simple test to ensure the header looks right with an empty ast
|
||||||
{
|
{
|
||||||
//setup
|
//setup
|
||||||
@@ -20,7 +20,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_private_emitAstPass(bucketHandle, &ast);
|
Toy_private_emitAstPass(bucketHandle, &ast);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -31,7 +31,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, ast: PASS\n" TOY_CC_RESET);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, ast: PASS\n" TOY_CC_RESET);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -45,7 +45,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 27)) != 0
|
*((unsigned char*)(buffer + 27)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, ast: PASS\n" TOY_CC_RESET);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, ast: PASS\n" TOY_CC_RESET);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -68,7 +68,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -79,7 +79,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -93,7 +93,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 27)) != 0
|
*((unsigned char*)(buffer + 27)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -116,7 +116,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -127,7 +127,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -145,7 +145,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 31)) != 0
|
*((unsigned char*)(buffer + 31)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -168,7 +168,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -179,7 +179,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -197,7 +197,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 31)) != 0
|
*((unsigned char*)(buffer + 31)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -220,7 +220,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -231,7 +231,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -250,7 +250,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 35)) != 0
|
*((unsigned char*)(buffer + 35)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -273,7 +273,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -284,7 +284,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -303,7 +303,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 35)) != 0
|
*((unsigned char*)(buffer + 35)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -326,7 +326,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* header = (int*)buffer;
|
int* header = (int*)buffer;
|
||||||
@@ -345,7 +345,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -369,7 +369,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -385,7 +385,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder jumps, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module jumps, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -401,7 +401,7 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder data, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module data, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -415,11 +415,11 @@ int test_builder_expressions(Toy_Bucket** bucketHandle) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// int test_builder_unary(Toy_Bucket** bucketHandle) {
|
// int test_compiler_unary(Toy_Bucket** bucketHandle) {
|
||||||
// //Nothing produces a unary instruction yet
|
// //Nothing produces a unary instruction yet
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int test_builder_binary(Toy_Bucket** bucketHandle) {
|
int test_compiler_binary(Toy_Bucket** bucketHandle) {
|
||||||
//produce a simple algorithm
|
//produce a simple algorithm
|
||||||
{
|
{
|
||||||
//setup
|
//setup
|
||||||
@@ -432,7 +432,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -443,7 +443,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -474,7 +474,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 47)) != 0
|
*((unsigned char*)(buffer + 47)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -497,7 +497,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -508,7 +508,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -539,7 +539,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 47)) != 0
|
*((unsigned char*)(buffer + 47)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -562,7 +562,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -573,7 +573,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -604,7 +604,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 47)) != 0
|
*((unsigned char*)(buffer + 47)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -627,7 +627,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -638,7 +638,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -695,7 +695,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 71)) != 0
|
*((unsigned char*)(buffer + 71)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -709,7 +709,7 @@ int test_builder_binary(Toy_Bucket** bucketHandle) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
int test_compiler_keywords(Toy_Bucket** bucketHandle) {
|
||||||
//assert
|
//assert
|
||||||
{
|
{
|
||||||
//setup
|
//setup
|
||||||
@@ -722,7 +722,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -733,7 +733,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -757,7 +757,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 35)) != 0
|
*((unsigned char*)(buffer + 35)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -780,7 +780,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -791,7 +791,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -820,7 +820,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 39)) != 0
|
*((unsigned char*)(buffer + 39)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -843,7 +843,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -862,7 +862,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -910,7 +910,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -933,7 +933,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -952,7 +952,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1024,7 +1024,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1047,7 +1047,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* ptr = (int*)buffer;
|
int* ptr = (int*)buffer;
|
||||||
@@ -1058,7 +1058,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
(ptr++)[0] != 0 || //data count
|
(ptr++)[0] != 0 || //data count
|
||||||
(ptr++)[0] != 0) //subs count
|
(ptr++)[0] != 0) //subs count
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1081,7 +1081,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
*((unsigned char*)(buffer + 39)) != 0
|
*((unsigned char*)(buffer + 39)) != 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1104,7 +1104,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* header = (int*)buffer;
|
int* header = (int*)buffer;
|
||||||
@@ -1123,7 +1123,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1156,7 +1156,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1172,7 +1172,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder jumps, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module jumps, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1188,7 +1188,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder data, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module data, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1211,7 +1211,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
|
|
||||||
//run
|
//run
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
|
|
||||||
//check header
|
//check header
|
||||||
int* header = (int*)buffer;
|
int* header = (int*)buffer;
|
||||||
@@ -1230,7 +1230,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder header, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module header, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1263,7 +1263,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder code, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module code, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1279,7 +1279,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder jumps, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module jumps, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1295,7 +1295,7 @@ int test_builder_keywords(Toy_Bucket** bucketHandle) {
|
|||||||
|
|
||||||
false)
|
false)
|
||||||
{
|
{
|
||||||
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module builder data, source: %s\n" TOY_CC_RESET, source);
|
fprintf(stderr, TOY_CC_ERROR "ERROR: failed to produce the expected module data, source: %s\n" TOY_CC_RESET, source);
|
||||||
|
|
||||||
//cleanup and return
|
//cleanup and return
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -1315,7 +1315,7 @@ int main(void) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
res = test_builder_expressions(&bucket);
|
res = test_compiler_expressions(&bucket);
|
||||||
Toy_freeBucket(&bucket);
|
Toy_freeBucket(&bucket);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
||||||
@@ -1325,7 +1325,7 @@ int main(void) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
res = test_builder_binary(&bucket);
|
res = test_compiler_binary(&bucket);
|
||||||
Toy_freeBucket(&bucket);
|
Toy_freeBucket(&bucket);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
||||||
@@ -1335,7 +1335,7 @@ int main(void) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
Toy_Bucket* bucket = Toy_allocateBucket(TOY_BUCKET_IDEAL);
|
||||||
res = test_builder_keywords(&bucket);
|
res = test_compiler_keywords(&bucket);
|
||||||
Toy_freeBucket(&bucket);
|
Toy_freeBucket(&bucket);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "toy_lexer.h"
|
#include "toy_lexer.h"
|
||||||
#include "toy_parser.h"
|
#include "toy_parser.h"
|
||||||
#include "toy_module_builder.h"
|
#include "toy_module_compiler.h"
|
||||||
#include "toy_print.h"
|
#include "toy_print.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -19,7 +19,7 @@ unsigned char* makeCodeFromSource(Toy_Bucket** bucketHandle, const char* source)
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
return Toy_compileModuleBuilder(ast);
|
return Toy_compileModule(ast);
|
||||||
}
|
}
|
||||||
|
|
||||||
//tests
|
//tests
|
||||||
@@ -36,7 +36,7 @@ int test_setup_and_teardown(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -82,7 +82,7 @@ int test_simple_execution(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -129,7 +129,7 @@ int test_opcode_not_equal(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -186,7 +186,7 @@ int test_keyword_assert(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -231,7 +231,7 @@ int test_keyword_assert(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -277,7 +277,7 @@ int test_keyword_assert(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -327,7 +327,7 @@ int test_keyword_print(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -373,7 +373,7 @@ int test_keyword_print(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -419,7 +419,7 @@ int test_keyword_print(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -469,7 +469,7 @@ int test_keyword_ifThenElse(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -515,7 +515,7 @@ int test_keyword_ifThenElse(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -560,7 +560,7 @@ int test_keyword_ifThenElse(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -606,7 +606,7 @@ int test_keyword_ifThenElse(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -655,7 +655,7 @@ int test_scope(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
@@ -704,7 +704,7 @@ int test_scope(Toy_Bucket** bucketHandle) {
|
|||||||
Toy_bindParser(&parser, &lexer);
|
Toy_bindParser(&parser, &lexer);
|
||||||
|
|
||||||
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
Toy_Ast* ast = Toy_scanParser(bucketHandle, &parser);
|
||||||
unsigned char* buffer = Toy_compileModuleBuilder(ast);
|
unsigned char* buffer = Toy_compileModule(ast);
|
||||||
Toy_Module module = Toy_parseModule(buffer);
|
Toy_Module module = Toy_parseModule(buffer);
|
||||||
|
|
||||||
//run the setup
|
//run the setup
|
||||||
|
|||||||
Reference in New Issue
Block a user