Start work on type checker (uh oh)
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
#include "codegen.h"
|
||||
|
||||
#include "SolsScope.h"
|
||||
|
||||
#include <groundvm.h>
|
||||
|
||||
#include "../parser/SolsNode.h"
|
||||
#include "../include/estr.h"
|
||||
#include "../include/uthash.h"
|
||||
|
||||
// FIXME add proper erroring function
|
||||
char* createCodegenError(char* what) {
|
||||
@@ -11,12 +15,12 @@ char* createCodegenError(char* what) {
|
||||
return estr.str;
|
||||
}
|
||||
|
||||
static inline ResultType(GroundProgram, charptr) generateLiteralNode(SolsNode* node) {
|
||||
static inline ResultType(GroundProgram, charptr) generateLiteralNode(SolsNode* node, SolsScope* scope) {
|
||||
// We don't even need to do anything lmao
|
||||
return Success(GroundProgram, charptr, groundCreateProgram());
|
||||
}
|
||||
|
||||
static inline ResultType(GroundProgram, charptr) generatePutsNode(SolsNode* node) {
|
||||
static inline ResultType(GroundProgram, charptr) generatePutsNode(SolsNode* node, SolsScope* scope) {
|
||||
if (node->children.count < 1) {
|
||||
return Error(GroundProgram, charptr, "puts requires arguments");
|
||||
}
|
||||
@@ -29,13 +33,13 @@ static inline ResultType(GroundProgram, charptr) generatePutsNode(SolsNode* node
|
||||
return Success(GroundProgram, charptr, program);
|
||||
}
|
||||
|
||||
ResultType(GroundProgram, charptr) generateCode(SolsNode* node) {
|
||||
ResultType(GroundProgram, charptr) generateCode(SolsNode* node, SolsScope* scope) {
|
||||
|
||||
GroundProgram program = groundCreateProgram();
|
||||
|
||||
// Generate code for all children before generating this node's code
|
||||
for (size_t i = 0; i < node->children.count; i++) {
|
||||
ResultType(GroundProgram, charptr) generated = generateCode(&node->children.at[i]);
|
||||
ResultType(GroundProgram, charptr) generated = generateCode(&node->children.at[i], scope);
|
||||
if (generated.error) {
|
||||
return Error(GroundProgram, charptr, createCodegenError(generated.as.error));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user