-* Optimize variable initialization to use constants
+# Doing
+
+* Cleanup the lexer
+
+# Up Next
+
+* Fix array access in structs
+* Implement module scoped identifiers
+* Implement an SSA backend
+* Implement pointers
+ * Ownership semantics: Ownership you can count on
+ * Concurrency: Biased reference counting
+
+# Backlog
+
+* Implement record extension
+* Implement logical operators: and, or, not
+* Implement string types
+* Implement while, for, do/repeat loops
+* Track uninitialized variables/globals
+* Nested procedure definitions
+* check that module name matches filename
+
+# Order of Operations for Implementing Memory Management
+
+* Implement new operator
+* Enforce single owner pointers
+* Implement borrowed pointers
+* Implement biased refcounting for borrowed pointers
+
+
+
}
else if (a->mode == ITEM_FIELD)
{
- snprintf(name, sizeof(name), "*((%s)(_T%d + %d))", typetoptr(a->type), a->reg, a->offset);
+ snprintf(name, sizeof(name), "*((%s)(_T%d + %lld))", typetoptr(a->type), a->reg, a->imm.i);
}
else
{
{
printf(" = %c%s;\n", (isref ? '&' : ' '), item->imm.s);
}
+ item->imm.i = 0;
break;
case ITEM_MVAR:
{
printf(" = %c%s_%s;\n", (isref ? '&' : ' '), p->name, item->imm.s);
}
+ item->imm.i = 0;
break;
default:
Field* f = get_field(p, record->type, name);
record->mode = ITEM_FIELD;
record->type = f->type;
- record->offset += f->offset;
+ record->imm.i += f->offset;
}
Symbol* sym;
Type* type;
int reg;
- int offset;
ImmValue imm;
} Item;
void codegen_index(Parser* p, Item* array, Item* index);
void codegen_field(Parser* p, Item* record, char* name);
+typedef union {
+ struct {
+ char* name;
+ long version;
+ } var;
+ ImmValue imm;
+} Operand;
+
+typedef struct {
+ int opcode;
+ Operand dest;
+ Operand arg1;
+ Operand arg2;
+} Operation;
+
+typedef struct {
+ size_t nops;
+ size_t mops;
+ Operation** ops;
+} Block;
+
/*
typedef struct AnfNode {
#include <fcntl.h>
#include <sys/stat.h>
-/* TODO
- * Implement logical operators: and, or, not
- * Implement module scoped identifiers
- * Implement strings types
- * Implement records and record access
- * Implement while, for, do/repeat loops
- * Track uninitialized variables/globals
- * Implement pointers
- * Ownership semantics: Ownership you can count on
- * Concurrency: Biased reference counting
- * Nested procedure definitions
- * Implement record extension
- * Cleanup the lexer
-*/
-
-/* Order of Operations for Implementing Memory Management
-
- * Implement new operator
- * Enforce single owner pointers
- * Implement borrowed pointers
- * Implement biased refcounting for borrowed pointers
-
-*/
-
//#define TRACE
#ifdef TRACE
static int Indent = 0;
# c = e[1][c];
# c = f.dim.w;
f.dim.h = 0;
-# f.label[0] = 42;
+ f.label[0] = 42;
end