DGen works, D code can be generated
This commit is contained in:
parent
d8f82e17de
commit
4b13c88c51
|
@ -17,6 +17,11 @@ public class CodeGenerator
|
|||
{
|
||||
this.modulle = modulle;
|
||||
}
|
||||
|
||||
public string build()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public import compiler.codegen.dgen;
|
||||
|
|
|
@ -15,7 +15,7 @@ public class DCodeGenerator : CodeGenerator
|
|||
super(modulle);
|
||||
}
|
||||
|
||||
public void build()
|
||||
public override string build()
|
||||
{
|
||||
Statement[] statements = modulle.getStatements();
|
||||
|
||||
|
@ -31,5 +31,7 @@ public class DCodeGenerator : CodeGenerator
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -64,7 +64,8 @@ void beginCompilation(string[] sourceFiles)
|
|||
}
|
||||
|
||||
import compiler.codegen.core;
|
||||
CodeGenerator codegen = new CodeGenerator(modulle);
|
||||
CodeGenerator codegen = new DCodeGenerator(modulle);
|
||||
codegen.build();
|
||||
|
||||
// typeChecker.check();
|
||||
}
|
||||
|
|
|
@ -228,7 +228,9 @@ public class Function : TypedEntity
|
|||
}
|
||||
}
|
||||
|
||||
public class Variable : TypedEntity
|
||||
import compiler.codegen.core;
|
||||
|
||||
public class Variable : TypedEntity, Emittable
|
||||
{
|
||||
/* TODO: Just make this an Expression */
|
||||
private VariableAssignment assignment;
|
||||
|
@ -254,6 +256,22 @@ public class Variable : TypedEntity
|
|||
}
|
||||
|
||||
/* Code gen */
|
||||
public string emit()
|
||||
{
|
||||
string emittedCode;
|
||||
|
||||
/* TODO: So far only emitting for non assignment */
|
||||
if(!assignment)
|
||||
{
|
||||
/* TODO: Let's hope only primitive types */
|
||||
emittedCode = type;
|
||||
emittedCode ~= " ";
|
||||
emittedCode ~= getName();
|
||||
emittedCode ~= ";";
|
||||
}
|
||||
|
||||
return emittedCode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue