mirror of
http://deavmi.assigned.network/git/tlang/tlang
synced 2025-01-02 22:42:03 +00:00
Merge branch 'vardec_varass_dependency'
This commit is contained in:
commit
45579b859f
13
.github/workflows/d.yml
vendored
13
.github/workflows/d.yml
vendored
@ -63,9 +63,22 @@ jobs:
|
||||
uses: dlang-community/setup-dlang@v1
|
||||
with:
|
||||
compiler: ${{ matrix.dc }}
|
||||
|
||||
- name: Install Doveralls (code coverage tool)
|
||||
run: |
|
||||
# wget -O doveralls "https://github.com/ColdenCullen/doveralls/releases/download/v1.1.5/doveralls_linux_travis"
|
||||
# mv doveralls_linux_travis doveralls
|
||||
# chmod +x doveralls
|
||||
dub fetch doveralls
|
||||
sudo apt install libcurl4-openssl-dev
|
||||
|
||||
- name: DUB unit tests with coverage
|
||||
run: dub test --coverage
|
||||
|
||||
- name: Coverage upload
|
||||
run: |
|
||||
export CI_BRANCH=$(git branch --show-current)
|
||||
dub run doveralls -- -t ${{secrets.COVERALLS_REPO_TOKEN}}
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
@ -1,7 +1,7 @@
|
||||
tlang
|
||||
=====
|
||||
|
||||
[![D](https://github.com/tbklang/tlang/actions/workflows/d.yml/badge.svg)](https://github.com/tbklang/tlang/actions/workflows/d.yml)
|
||||
[![D](https://github.com/tbklang/tlang/actions/workflows/d.yml/badge.svg?branch=vardec_varass_dependency)](https://github.com/tbklang/tlang/actions/workflows/d.yml) [![Coverage Status](https://coveralls.io/repos/github/tbklang/tlang/badge.svg?branch=vardec_varass_dependency)](https://coveralls.io/github/tbklang/tlang?branch=vardec_varass_dependency)
|
||||
|
||||
Official Tristan Language project compiler
|
||||
|
||||
|
@ -59,13 +59,17 @@ mixin template EmitBase()
|
||||
{
|
||||
@ArgGroup("Emit", "Options pertaining to the code emitter")
|
||||
{
|
||||
@ArgNamed("symbol-mapper|sm", "The symbol mapping technique to use")
|
||||
@ArgNamed("symbol-mapper|sm", "The symbol mapping technique to use for DGen (C emitter)")
|
||||
@(ArgConfig.optional)
|
||||
SymbolMappingTechnique symbolTechnique = SymbolMappingTechnique.HASHMAPPER;
|
||||
|
||||
@ArgNamed("prettygen|pg", "Generate pretty-printed code")
|
||||
@(ArgConfig.optional)
|
||||
bool prettyPrintCodeGen = true;
|
||||
|
||||
@ArgNamed("ccompiler|cc", "The system C compiler to use for DGne (C emitter)")
|
||||
@(ArgConfig.optional)
|
||||
string systemCC = "clang";
|
||||
|
||||
@ArgNamed("output|o", "Filename of generated object file")
|
||||
@(ArgConfig.optional)
|
||||
@ -75,6 +79,10 @@ mixin template EmitBase()
|
||||
@(ArgConfig.optional)
|
||||
bool entrypointTestEmit = true; // TODO: Change this later to `false` of course
|
||||
|
||||
@ArgNamed("preinlineArguments|pia", "Whether or not to preinline function call arguments in DGen (C emitter)")
|
||||
@(ArgConfig.optional)
|
||||
bool preinlineArguments = false; // TODO: Change this later to `true` of course
|
||||
|
||||
@ArgNamed("library-link|ll", "Paths to any object files to ,ink in during the linking phase")
|
||||
@(ArgConfig.optional)
|
||||
@(ArgConfig.aggregate)
|
||||
@ -84,7 +92,7 @@ mixin template EmitBase()
|
||||
void EmitBaseInit(Compiler compiler)
|
||||
{
|
||||
// Set the symbol mapper technique
|
||||
compiler.getConfig().addConfig(ConfigEntry("emit:mapper", symbolTechnique));
|
||||
compiler.getConfig().addConfig(ConfigEntry("dgen:mapper", symbolTechnique));
|
||||
|
||||
// Set whether pretty-printed code should be generated
|
||||
compiler.getConfig().addConfig(ConfigEntry("dgen:pretty_code", prettyPrintCodeGen));
|
||||
@ -92,6 +100,12 @@ mixin template EmitBase()
|
||||
// Set whether or not to enable the entry point testing code
|
||||
compiler.getConfig().addConfig(ConfigEntry("dgen:emit_entrypoint_test", entrypointTestEmit));
|
||||
|
||||
// Set whether or not to enable pre-inlining of function call arguments in DGen
|
||||
compiler.getConfig().addConfig(ConfigEntry("dgen:preinline_args", preinlineArguments));
|
||||
|
||||
// Set the C compiler to use for DGen
|
||||
compiler.getConfig().addConfig(ConfigEntry("dgen:compiler", systemCC));
|
||||
|
||||
// Set the paths to the object files to link in
|
||||
compiler.getConfig().addConfig(ConfigEntry("linker:link_files", bruh));
|
||||
}
|
||||
|
@ -141,6 +141,9 @@ public final class DCodeEmitter : CodeEmitter
|
||||
gprintln("transform(): "~to!(string)(instruction));
|
||||
transformDepth++;
|
||||
|
||||
// The data to emit
|
||||
string emmmmit;
|
||||
|
||||
// At any return decrement the depth
|
||||
scope(exit)
|
||||
{
|
||||
@ -172,12 +175,12 @@ public final class DCodeEmitter : CodeEmitter
|
||||
{
|
||||
string renamedSymbol = mapper.symbolLookup(typedEntityVariable);
|
||||
|
||||
return renamedSymbol~" = "~transform(varAs.data)~";";
|
||||
emmmmit = renamedSymbol~" = "~transform(varAs.data)~";";
|
||||
}
|
||||
/* If it is external */
|
||||
else
|
||||
{
|
||||
return typedEntityVariable.getName()~" = "~transform(varAs.data)~";";
|
||||
emmmmit = typedEntityVariable.getName()~" = "~transform(varAs.data)~";";
|
||||
}
|
||||
}
|
||||
/* VariableDeclaration */
|
||||
@ -218,17 +221,18 @@ public final class DCodeEmitter : CodeEmitter
|
||||
gprintln("VarDec(with assignment): My assignment type is: "~varAssInstr.getInstrType().getName());
|
||||
|
||||
// Generate the code to emit
|
||||
return typeTransform(cast(Type)varDecInstr.varType)~" "~renamedSymbol~" = "~transform(varAssInstr)~";";
|
||||
emmmmit = typeTransform(cast(Type)varDecInstr.varType)~" "~renamedSymbol~" = "~transform(varAssInstr)~";";
|
||||
}
|
||||
else
|
||||
{
|
||||
emmmmit = typeTransform(cast(Type)varDecInstr.varType)~" "~renamedSymbol~";";
|
||||
}
|
||||
|
||||
return typeTransform(cast(Type)varDecInstr.varType)~" "~renamedSymbol~";";
|
||||
}
|
||||
/* If the variable is external */
|
||||
else
|
||||
{
|
||||
return "extern "~typeTransform(cast(Type)varDecInstr.varType)~" "~typedEntityVariable.getName()~";";
|
||||
emmmmit = "extern "~typeTransform(cast(Type)varDecInstr.varType)~" "~typedEntityVariable.getName()~";";
|
||||
}
|
||||
|
||||
}
|
||||
/* LiteralValue */
|
||||
else if(cast(LiteralValue)instruction)
|
||||
@ -237,7 +241,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
|
||||
LiteralValue literalValueInstr = cast(LiteralValue)instruction;
|
||||
|
||||
return to!(string)(literalValueInstr.getLiteralValue());
|
||||
emmmmit = to!(string)(literalValueInstr.getLiteralValue());
|
||||
}
|
||||
/* FetchValueVar */
|
||||
else if(cast(FetchValueVar)instruction)
|
||||
@ -257,12 +261,12 @@ public final class DCodeEmitter : CodeEmitter
|
||||
|
||||
string renamedSymbol = mapper.symbolLookup(typedEntityVariable);
|
||||
|
||||
return renamedSymbol;
|
||||
emmmmit = renamedSymbol;
|
||||
}
|
||||
/* If it is external */
|
||||
else
|
||||
{
|
||||
return typedEntityVariable.getName();
|
||||
emmmmit = typedEntityVariable.getName();
|
||||
}
|
||||
}
|
||||
/* BinOpInstr */
|
||||
@ -320,7 +324,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
cvInstr.setRelax(true);
|
||||
}
|
||||
|
||||
return transform(binOpInstr.lhs)~to!(string)(getCharacter(binOpInstr.operator))~transform(binOpInstr.rhs);
|
||||
emmmmit = transform(binOpInstr.lhs)~to!(string)(getCharacter(binOpInstr.operator))~transform(binOpInstr.rhs);
|
||||
}
|
||||
/* FuncCallInstr */
|
||||
else if(cast(FuncCallInstr)instruction)
|
||||
@ -370,7 +374,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
emit ~= ";";
|
||||
}
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/* ReturnInstruction */
|
||||
else if(cast(ReturnInstruction)instruction)
|
||||
@ -384,7 +388,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
/* Get the return expression instruction */
|
||||
Value returnExpressionInstr = returnInstruction.getReturnExpInstr();
|
||||
|
||||
return "return "~transform(returnExpressionInstr)~";";
|
||||
emmmmit = "return "~transform(returnExpressionInstr)~";";
|
||||
}
|
||||
/**
|
||||
* If statements (IfStatementInstruction)
|
||||
@ -434,7 +438,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
}
|
||||
}
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* While loops (WhileLoopInstruction)
|
||||
@ -464,7 +468,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
/* Closing curly brace */
|
||||
emit~=genTabs(transformDepth)~"}";
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* For loops (ForLoopInstruction)
|
||||
@ -502,7 +506,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
// Close curly (body end)
|
||||
emit~=genTabs(transformDepth)~"}";
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Unary operators (UnaryOpInstr)
|
||||
@ -521,7 +525,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
/* Transform the operand */
|
||||
emit ~= transform(operandInstruction);
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Pointer dereference assignment (PointerDereferenceAssignmentInstruction)
|
||||
@ -551,7 +555,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
emit ~= transform(rhsAssExprInstr)~";";
|
||||
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Discard instruction (DiscardInstruction)
|
||||
@ -566,7 +570,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
/* Transform the expression */
|
||||
emit ~= transform(valueInstruction)~";";
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Type casting instruction (CastedValueInstruction)
|
||||
@ -593,29 +597,27 @@ public final class DCodeEmitter : CodeEmitter
|
||||
{
|
||||
/* The original expression */
|
||||
emit ~= transform(uncastedInstruction);
|
||||
return emit;
|
||||
}
|
||||
|
||||
/* Handling of primitive types */
|
||||
if(cast(Primitive)castingTo)
|
||||
{
|
||||
/* Add the actual cast */
|
||||
emit ~= "("~typeTransform(castingTo)~")";
|
||||
|
||||
/* The expression being casted */
|
||||
emit ~= transform(uncastedInstruction);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Implement this
|
||||
gprintln("Non-primitive type casting not yet implemented", DebugType.ERROR);
|
||||
assert(false);
|
||||
/* Handling of primitive types */
|
||||
if(cast(Primitive)castingTo)
|
||||
{
|
||||
/* Add the actual cast */
|
||||
emit ~= "("~typeTransform(castingTo)~")";
|
||||
|
||||
/* The expression being casted */
|
||||
emit ~= transform(uncastedInstruction);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Implement this
|
||||
gprintln("Non-primitive type casting not yet implemented", DebugType.ERROR);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Array indexing (pointer-based arrays)
|
||||
@ -655,7 +657,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
|
||||
|
||||
// return "*("~transform(indexed)~"+"~transform(index)~")";
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Array assignments (pointer-based arrays)
|
||||
@ -701,7 +703,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
emit ~= ";";
|
||||
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Array indexing (stack-based arrays)
|
||||
@ -741,7 +743,7 @@ public final class DCodeEmitter : CodeEmitter
|
||||
|
||||
|
||||
// return "(TODO: Stack-array index emit)";
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
/**
|
||||
* Array assignments (stack-based arrays)
|
||||
@ -785,12 +787,23 @@ public final class DCodeEmitter : CodeEmitter
|
||||
|
||||
// return "(StackArrAssignmentInstr: TODO)";
|
||||
|
||||
return emit;
|
||||
emmmmit = emit;
|
||||
}
|
||||
// TODO: MAAAAN we don't even have this yet
|
||||
// else if(cast(StringExpression))
|
||||
/**
|
||||
* Unsupported instruction
|
||||
*
|
||||
* If you get here then normally it's because
|
||||
* you didn't implement a transformation for
|
||||
* an instruction yet.
|
||||
*/
|
||||
else
|
||||
{
|
||||
emmmmit = "<TODO: Base emit: "~to!(string)(instruction)~">";
|
||||
}
|
||||
|
||||
return "<TODO: Base emit: "~to!(string)(instruction)~">";
|
||||
return emmmmit;
|
||||
}
|
||||
|
||||
|
||||
@ -1272,8 +1285,10 @@ int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
//NOTE: Change to system compiler (maybe, we need to choose a good C compiler)
|
||||
string[] compileArgs = ["clang", "-o", "tlang.out", file.name()];
|
||||
string systemCompiler = config.getConfig("dgen:compiler").getText();
|
||||
gprintln("Using system C compiler '"~systemCompiler~"' for compilation");
|
||||
|
||||
string[] compileArgs = [systemCompiler, "-o", "tlang.out", file.name()];
|
||||
|
||||
// Check for object files to be linked in
|
||||
string[] objectFilesLink;
|
||||
|
@ -200,8 +200,8 @@ public final class CompilerConfiguration
|
||||
/* Generate a fresh new config */
|
||||
CompilerConfiguration config = new CompilerConfiguration();
|
||||
|
||||
/* Enable Behaviour-C fixes */
|
||||
config.addConfig(ConfigEntry("behavec:preinline_args", true));
|
||||
/* Enable Behaviour-C fixes (TODO: This should be changed to true before release) */
|
||||
config.addConfig(ConfigEntry("dgen:preinline_args", false));
|
||||
|
||||
/* Enable pretty code generation for DGen */
|
||||
config.addConfig(ConfigEntry("dgen:pretty_code", true));
|
||||
@ -209,8 +209,11 @@ public final class CompilerConfiguration
|
||||
/* Enable entry point test generation for DGen */
|
||||
config.addConfig(ConfigEntry("dgen:emit_entrypoint_test", true));
|
||||
|
||||
/* Set the mapping to hashing of entity names (TODO: This should be changed before release) */
|
||||
config.addConfig(ConfigEntry("emit:mapper", "hashmapper"));
|
||||
/* Set the mapping to hashing of entity names for DGen (TODO: This should be changed before release) */
|
||||
config.addConfig(ConfigEntry("dgen:mapper", "hashmapper"));
|
||||
|
||||
/* Set the system C compiler for DGen to clang */
|
||||
config.addConfig(ConfigEntry("dgen:compiler", "clang"));
|
||||
|
||||
/**
|
||||
* Configure, at compile time, the system type aliases
|
||||
|
@ -204,13 +204,13 @@ public class Compiler
|
||||
throw new CompilerException(CompilerError.TYPECHECK_NOT_YET_PERFORMED);
|
||||
}
|
||||
|
||||
if(!config.hasConfig("emit:mapper"))
|
||||
if(!config.hasConfig("dgen:mapper"))
|
||||
{
|
||||
throw new CompilerException(CompilerError.CONFIG_ERROR, "Missing a symbol mapper");
|
||||
}
|
||||
|
||||
SymbolMapper mapper;
|
||||
string mapperType = config.getConfig("emit:mapper").getText();
|
||||
string mapperType = config.getConfig("dgen:mapper").getText();
|
||||
|
||||
if(cmp(mapperType, "hashmapper") == 0)
|
||||
{
|
||||
|
@ -718,7 +718,7 @@ public class DNodeGenerator
|
||||
expect("Only class-type may be used with `new`");
|
||||
assert(false);
|
||||
}
|
||||
gprintln("Poe naais");
|
||||
gprintln("King of the castle");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -981,8 +981,6 @@ public class DNodeGenerator
|
||||
*/
|
||||
else if(cast(ArrayIndex)exp)
|
||||
{
|
||||
gprintln("Working on expressionPass'ing of ArrayIndex", DebugType.ERROR);
|
||||
|
||||
ArrayIndex arrayIndex = cast(ArrayIndex)exp;
|
||||
|
||||
// Set the context as we need to grab it later in the typechecker
|
||||
@ -997,9 +995,6 @@ public class DNodeGenerator
|
||||
Expression indexedExp = arrayIndex.getIndexed();
|
||||
DNode indexedExpDNode = expressionPass(indexedExp, context);
|
||||
dnode.needs(indexedExpDNode);
|
||||
|
||||
|
||||
// assert(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -219,7 +219,7 @@ public final class Resolver
|
||||
/* Try find the Entity within the current Contaier */
|
||||
gprintln("resolveUp("~to!(string)(currentContainer)~", "~name~")");
|
||||
Entity entity = resolveWithin(currentContainer, name);
|
||||
gprintln("Poes");
|
||||
gprintln("Certified 2008 financial crisis moment");
|
||||
gprintln(entity);
|
||||
|
||||
/* If we found it return it */
|
||||
|
Loading…
Reference in New Issue
Block a user