From 3da50e9eab6bbbe7ad9a03be8d2b7508bc16d51a Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Wed, 10 Nov 2021 17:15:27 +0200 Subject: [PATCH] Got some sort of class allocator node created, now to re-order it by using Context to be able to know when the StaticVariableDeclaration is within class. This then generates code to allocate space for the class, once done we can be assured the declarations (placed after it now) will be assigning to properly allocated space (paged and maped for example) --- source/tlang/compiler/codegen/instruction.d | 8 ++++++++ source/tlang/compiler/typecheck/core.d | 12 ++++++++++++ .../tlang/compiler/typecheck/dependency/variables.d | 2 ++ 3 files changed, 22 insertions(+) diff --git a/source/tlang/compiler/codegen/instruction.d b/source/tlang/compiler/codegen/instruction.d index b9429ea9..a293653d 100644 --- a/source/tlang/compiler/codegen/instruction.d +++ b/source/tlang/compiler/codegen/instruction.d @@ -36,6 +36,14 @@ public class StorageDeclaratio : Instruction } +public class ClassStaticInitAllocate : Instruction +{ + this(string className) + { + addInfo = "classStaticInitAllocate: "~className; + } +} + public class VariableAssignmentInstr : Instruction { /* Name of variable being declared */ diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index 1eb9b88a..8945bcd8 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -284,6 +284,10 @@ public final class TypeChecker */ else if(cast(compiler.typecheck.dependency.variables.StaticVariableDeclaration)dnode) { + /* TODO: Add skipping if context is within a class */ + /* We need to wait for class static node, to do an InitInstruction (static init) */ + /* It probably makes sense , IDK, we need to allocate both classes */ + /** * Codegen * @@ -334,6 +338,14 @@ public final class TypeChecker } /* TODO: Add class init */ + else if(cast(compiler.typecheck.dependency.classes.classStaticDep.ClassStaticNode)dnode) + { + Clazz clazzPNode = cast(Clazz)dnode.getEntity(); + string clazzName = resolver.generateName(modulle, clazzPNode); + + /* TODO: I am rushing so idk which quantum op to use */ + addInstrB(new ClassStaticInitAllocate(clazzName)); + } /* It will pop a bunch of shiiit */ /* TODO: ANy statement */ else if(cast(compiler.typecheck.dependency.core.DNode)dnode) diff --git a/source/tlang/compiler/typecheck/dependency/variables.d b/source/tlang/compiler/typecheck/dependency/variables.d index 2f0a5939..3ba4b9ab 100644 --- a/source/tlang/compiler/typecheck/dependency/variables.d +++ b/source/tlang/compiler/typecheck/dependency/variables.d @@ -26,6 +26,8 @@ public class VariableNode : DNode { name = resolver.generateName(cast(Container)dnodegen.root.getEntity(), cast(Entity)entity); } + + } public class ModuleVariableDeclaration : VariableNode