mirror of https://github.com/tbklang/tlang.git
Packaging
- Fixed module naming; autocomplete now works Typing - Added a TODO/NOTE comment Parser - Implemented range-based literal type encoding for integer literals Check - Switched from directly calling `isNumeric(string)` to our own `isNumericLiteral(string)` to check if a token is a `SymbolType.NUMBER_LITERAL` Test cases - Added new test case `simple_literals3.t`
This commit is contained in:
parent
18b784f861
commit
a884bfe441
|
@ -4,10 +4,10 @@
|
||||||
* This is the entry point for the TLP
|
* This is the entry point for the TLP
|
||||||
* reference compiler.
|
* reference compiler.
|
||||||
*/
|
*/
|
||||||
module tlang;
|
module tlang.app;
|
||||||
|
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import commandline.args;
|
import tlang.commandline.args;
|
||||||
|
|
||||||
void main(string[] args)
|
void main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module commandline.args;
|
module tlang.commandline.args;
|
||||||
|
|
||||||
import jcli.commandgraph.cli;
|
import jcli.commandgraph.cli;
|
||||||
|
|
||||||
void parseCommandLine(string[] arguments)
|
void parseCommandLine(string[] arguments)
|
||||||
{
|
{
|
||||||
/* Parse the command-line arguments */
|
/* Parse the command-line arguments */
|
||||||
matchAndExecuteAcrossModules!(commandline.commands)(arguments[1..arguments.length]);
|
matchAndExecuteAcrossModules!(tlang.commandline.commands)(arguments[1..arguments.length]);
|
||||||
}
|
}
|
|
@ -4,21 +4,21 @@
|
||||||
* All command-line arguments and their impementations
|
* All command-line arguments and their impementations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module commandline.commands;
|
module tlang.commandline.commands;
|
||||||
|
|
||||||
import jcli;
|
import jcli;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import misc.exceptions : TError;
|
import misc.exceptions : TError;
|
||||||
import std.exception : ErrnoException;
|
import std.exception : ErrnoException;
|
||||||
import compiler.lexer.core : Lexer;
|
import tlang.compiler.lexer.core : Lexer;
|
||||||
import compiler.lexer.tokens : Token;
|
import tlang.compiler.lexer.tokens : Token;
|
||||||
import compiler.parsing.core : Parser;
|
import tlang.compiler.parsing.core : Parser;
|
||||||
import compiler.typecheck.core : TypeChecker;
|
import tlang.compiler.typecheck.core : TypeChecker;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.core : Compiler, beginCompilation;
|
import tlang.compiler.core : Compiler, beginCompilation;
|
||||||
import compiler.configuration : ConfigEntry;
|
import tlang.compiler.configuration : ConfigEntry;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import compiler.codegen.mapper.core : SymbolMappingTechnique;
|
import tlang.compiler.codegen.mapper.core : SymbolMappingTechnique;
|
||||||
|
|
||||||
//TODO: Re-order the definitions below so that they appear with compile first, then lex, parse, ..., help
|
//TODO: Re-order the definitions below so that they appear with compile first, then lex, parse, ..., help
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
module compiler.codegen.emit.core;
|
module tlang.compiler.codegen.emit.core;
|
||||||
|
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import std.container.slist : SList;
|
import std.container.slist : SList;
|
||||||
import compiler.codegen.instruction;
|
import tlang.compiler.codegen.instruction;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.file;
|
import std.file;
|
||||||
import compiler.codegen.instruction : Instruction;
|
import tlang.compiler.codegen.instruction : Instruction;
|
||||||
import std.range : walkLength;
|
import std.range : walkLength;
|
||||||
import gogga;
|
import gogga;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import compiler.configuration : CompilerConfiguration;
|
import tlang.compiler.configuration : CompilerConfiguration;
|
||||||
import compiler.codegen.mapper.core : SymbolMapper;
|
import tlang.compiler.codegen.mapper.core : SymbolMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Perhaps have an interface that can emit(Context/Parent, Statement)
|
* TODO: Perhaps have an interface that can emit(Context/Parent, Statement)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module compiler.codegen.emit.dgen;
|
module tlang.compiler.codegen.emit.dgen;
|
||||||
|
|
||||||
import compiler.codegen.emit.core : CodeEmitter;
|
import tlang.compiler.codegen.emit.core : CodeEmitter;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import std.container.slist : SList;
|
import std.container.slist : SList;
|
||||||
import compiler.codegen.instruction;
|
import tlang.compiler.codegen.instruction;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
@ -12,13 +12,13 @@ import gogga;
|
||||||
import std.range : walkLength;
|
import std.range : walkLength;
|
||||||
import std.string : wrap;
|
import std.string : wrap;
|
||||||
import std.process : spawnProcess, Pid, ProcessException, wait;
|
import std.process : spawnProcess, Pid, ProcessException, wait;
|
||||||
import compiler.typecheck.dependency.core : Context, FunctionData, DNode;
|
import tlang.compiler.typecheck.dependency.core : Context, FunctionData, DNode;
|
||||||
import compiler.codegen.mapper.core : SymbolMapper;
|
import tlang.compiler.codegen.mapper.core : SymbolMapper;
|
||||||
import compiler.symbols.data : SymbolType, Variable, Function, VariableParameter;
|
import tlang.compiler.symbols.data : SymbolType, Variable, Function, VariableParameter;
|
||||||
import compiler.symbols.check : getCharacter;
|
import tlang.compiler.symbols.check : getCharacter;
|
||||||
import misc.utils : Stack;
|
import misc.utils : Stack;
|
||||||
import compiler.symbols.typing.core : Type, Primitive, Integer, Void, Pointer;
|
import tlang.compiler.symbols.typing.core : Type, Primitive, Integer, Void, Pointer;
|
||||||
import compiler.configuration : CompilerConfiguration;
|
import tlang.compiler.configuration : CompilerConfiguration;
|
||||||
|
|
||||||
public final class DCodeEmitter : CodeEmitter
|
public final class DCodeEmitter : CodeEmitter
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
module compiler.codegen.instruction;
|
module tlang.compiler.codegen.instruction;
|
||||||
|
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import compiler.typecheck.dependency.core : Context;
|
import tlang.compiler.typecheck.dependency.core : Context;
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
import compiler.symbols.data : SymbolType;
|
import tlang.compiler.symbols.data : SymbolType;
|
||||||
import compiler.symbols.check : getCharacter;
|
import tlang.compiler.symbols.check : getCharacter;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.symbols.typing.core : Type;
|
import tlang.compiler.symbols.typing.core : Type;
|
||||||
|
|
||||||
public class Instruction
|
public class Instruction
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module compiler.codegen.mapper.core;
|
module tlang.compiler.codegen.mapper.core;
|
||||||
|
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import gogga;
|
import gogga;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module compiler.codegen.mapper.hashmapper;
|
module tlang.compiler.codegen.mapper.hashmapper;
|
||||||
|
|
||||||
import compiler.codegen.mapper.core : SymbolMapper;
|
import tlang.compiler.codegen.mapper.core : SymbolMapper;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
|
|
||||||
public final class HashMapper : SymbolMapper
|
public final class HashMapper : SymbolMapper
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module compiler.codegen.mapper.lebanese;
|
module tlang.compiler.codegen.mapper.lebanese;
|
||||||
|
|
||||||
import compiler.codegen.mapper.core : SymbolMapper;
|
import tlang.compiler.codegen.mapper.core : SymbolMapper;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.string : replace;
|
import std.string : replace;
|
||||||
|
|
||||||
public final class LebaneseMapper : SymbolMapper
|
public final class LebaneseMapper : SymbolMapper
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module compiler.configuration;
|
module tlang.compiler.configuration;
|
||||||
|
|
||||||
import compiler.core : CompilerException, CompilerError;
|
import tlang.compiler.core : CompilerException, CompilerError;
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
|
|
||||||
private union ConfigValue
|
private union ConfigValue
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
module compiler.core;
|
module tlang.compiler.core;
|
||||||
|
|
||||||
import gogga;
|
import gogga;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.tokens : Token;
|
import tlang.compiler.lexer.tokens : Token;
|
||||||
import std.stdio : File;
|
import std.stdio : File;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import core.stdc.stdlib;
|
import core.stdc.stdlib;
|
||||||
import compiler.codegen.emit.core;
|
import tlang.compiler.codegen.emit.core;
|
||||||
import compiler.codegen.emit.dgen;
|
import tlang.compiler.codegen.emit.dgen;
|
||||||
import misc.exceptions : TError;
|
import misc.exceptions : TError;
|
||||||
import compiler.codegen.mapper.core : SymbolMapper;
|
import tlang.compiler.codegen.mapper.core : SymbolMapper;
|
||||||
import compiler.codegen.mapper.hashmapper : HashMapper;
|
import tlang.compiler.codegen.mapper.hashmapper : HashMapper;
|
||||||
import compiler.codegen.mapper.lebanese : LebaneseMapper;
|
import tlang.compiler.codegen.mapper.lebanese : LebaneseMapper;
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
import compiler.configuration : CompilerConfiguration, ConfigEntry;
|
import tlang.compiler.configuration : CompilerConfiguration, ConfigEntry;
|
||||||
|
|
||||||
// TODO: Add configentry unittests
|
// TODO: Add configentry unittests
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module compiler.docgen.core;
|
module tlang.compiler.docgen.core;
|
||||||
|
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
public final class DocumentGenerator
|
public final class DocumentGenerator
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
module compiler.lexer.core;
|
module tlang.compiler.lexer.core;
|
||||||
|
|
||||||
import std.container.slist;
|
import std.container.slist;
|
||||||
import gogga;
|
import gogga;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.ascii : isDigit;
|
import std.ascii : isDigit;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.lexer.tokens : Token;
|
import tlang.compiler.lexer.tokens : Token;
|
||||||
|
|
||||||
public final class Lexer
|
public final class Lexer
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ public final class Lexer
|
||||||
*/
|
*/
|
||||||
private bool isBuildUpValidIdent()
|
private bool isBuildUpValidIdent()
|
||||||
{
|
{
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
return isPathIdentifier(currentToken) || isIdentifier(currentToken);
|
return isPathIdentifier(currentToken) || isIdentifier(currentToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module compiler.lexer.exceptions;
|
module tlang.compiler.lexer.exceptions;
|
||||||
|
|
||||||
import misc.exceptions : TError;
|
import misc.exceptions : TError;
|
||||||
import compiler.lexer.core : Lexer;
|
import tlang.compiler.lexer.core : Lexer;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
||||||
public enum LexerError
|
public enum LexerError
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module compiler.lexer.tokens;
|
module tlang.compiler.lexer.tokens;
|
||||||
|
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
module compiler.parsing.core;
|
module tlang.compiler.parsing.core;
|
||||||
|
|
||||||
import gogga;
|
import gogga;
|
||||||
import std.conv : to, ConvException;
|
import std.conv : to, ConvException;
|
||||||
import std.string : isNumeric, cmp;
|
import std.string : isNumeric, cmp;
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import compiler.lexer.tokens : Token;
|
import tlang.compiler.lexer.tokens : Token;
|
||||||
import core.stdc.stdlib;
|
import core.stdc.stdlib;
|
||||||
import misc.exceptions : TError;
|
import misc.exceptions : TError;
|
||||||
import compiler.parsing.exceptions;
|
import tlang.compiler.parsing.exceptions;
|
||||||
|
|
||||||
// public final class ParserError : TError
|
// public final class ParserError : TError
|
||||||
// {
|
// {
|
||||||
|
@ -1142,37 +1142,78 @@ public final class Parser
|
||||||
// TODO: Issue #94, we should be checking the range here
|
// TODO: Issue #94, we should be checking the range here
|
||||||
// ... along with any explicit encoders and setting it
|
// ... along with any explicit encoders and setting it
|
||||||
// ... for now default to SIGNED_INTEGER.
|
// ... for now default to SIGNED_INTEGER.
|
||||||
|
IntegerLiteralEncoding chosenEncoding;
|
||||||
// TODO (X-platform): Use `size_t` here
|
// TODO (X-platform): Use `size_t` here
|
||||||
// TODO (Redundant-later): Since we check here, remove the conv check in the typechecker!
|
ulong literalValue;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Add a check for the `U`, `UL` stuff here
|
// TODO: Add a check for the `U`, `UL` stuff here
|
||||||
try
|
import std.algorithm.searching : canFind;
|
||||||
|
// Explicit integer encoding (unsigned long)
|
||||||
|
if(canFind(numberLiteralStr, "UL"))
|
||||||
{
|
{
|
||||||
ulong literalValue = to!(ulong)(numberLiteralStr);
|
chosenEncoding = IntegerLiteralEncoding.UNSIGNED_LONG;
|
||||||
IntegerLiteralEncoding chosenEncoding;
|
|
||||||
|
|
||||||
// Signed integer range [0, 2_147_483_647]
|
// Strip the `UL` away
|
||||||
if(literalValue >= 0 && literalValue <= 2_147_483_647)
|
numberLiteralStr = numberLiteralStr[0..numberLiteralStr.length-2];
|
||||||
{
|
|
||||||
chosenEncoding = IntegerLiteralEncoding.SIGNED_INTEGER;
|
|
||||||
}
|
|
||||||
// Signed long range [2_147_483_648, 9_223_372_036_854_775_807]
|
|
||||||
else if(literalValue >= 2_147_483_648 && literalValue <= 9_223_372_036_854_775_807)
|
|
||||||
{
|
|
||||||
chosenEncoding = IntegerLiteralEncoding.SIGNED_LONG;
|
|
||||||
}
|
|
||||||
// Unsigned long range [9_223_372_036_854_775_808, 18_446_744_073_709_551_615]
|
|
||||||
else
|
|
||||||
{
|
|
||||||
chosenEncoding = IntegerLiteralEncoding.UNSIGNED_LONG;
|
|
||||||
}
|
|
||||||
|
|
||||||
numberLiteral = new IntegerLiteral(getCurrentToken().getToken(), chosenEncoding);
|
|
||||||
}
|
}
|
||||||
catch(ConvException e)
|
// Explicit integer encoding (signed long)
|
||||||
|
else if(canFind(numberLiteralStr, "L"))
|
||||||
{
|
{
|
||||||
throw new ParserException(this, ParserException.ParserErrorType.LITERAL_OVERFLOW, "Literal '"~numberLiteralStr~"' would overflow");
|
chosenEncoding = IntegerLiteralEncoding.SIGNED_LONG;
|
||||||
|
|
||||||
|
// Strip the `L` away
|
||||||
|
numberLiteralStr = numberLiteralStr[0..numberLiteralStr.length-1];
|
||||||
}
|
}
|
||||||
|
// Explicit integer encoding (unsigned int)
|
||||||
|
else if(canFind(numberLiteralStr, "UI"))
|
||||||
|
{
|
||||||
|
chosenEncoding = IntegerLiteralEncoding.UNSIGNED_INTEGER;
|
||||||
|
|
||||||
|
// Strip the `UI` away
|
||||||
|
numberLiteralStr = numberLiteralStr[0..numberLiteralStr.length-2];
|
||||||
|
}
|
||||||
|
// Explicit integer encoding (signed int)
|
||||||
|
else if(canFind(numberLiteralStr, "I"))
|
||||||
|
{
|
||||||
|
chosenEncoding = IntegerLiteralEncoding.SIGNED_INTEGER;
|
||||||
|
|
||||||
|
// Strip the `I` away
|
||||||
|
numberLiteralStr = numberLiteralStr[0..numberLiteralStr.length-1];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// TODO (X-platform): Use `size_t` here
|
||||||
|
literalValue = to!(ulong)(numberLiteralStr);
|
||||||
|
|
||||||
|
|
||||||
|
// Signed integer range [0, 2_147_483_647]
|
||||||
|
if(literalValue >= 0 && literalValue <= 2_147_483_647)
|
||||||
|
{
|
||||||
|
chosenEncoding = IntegerLiteralEncoding.SIGNED_INTEGER;
|
||||||
|
}
|
||||||
|
// Signed long range [2_147_483_648, 9_223_372_036_854_775_807]
|
||||||
|
else if(literalValue >= 2_147_483_648 && literalValue <= 9_223_372_036_854_775_807)
|
||||||
|
{
|
||||||
|
chosenEncoding = IntegerLiteralEncoding.SIGNED_LONG;
|
||||||
|
}
|
||||||
|
// Unsigned long range [9_223_372_036_854_775_808, 18_446_744_073_709_551_615]
|
||||||
|
else
|
||||||
|
{
|
||||||
|
chosenEncoding = IntegerLiteralEncoding.UNSIGNED_LONG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(ConvException e)
|
||||||
|
{
|
||||||
|
throw new ParserException(this, ParserException.ParserErrorType.LITERAL_OVERFLOW, "Literal '"~numberLiteralStr~"' would overflow");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
numberLiteral = new IntegerLiteral(numberLiteralStr, chosenEncoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add expression to stack */
|
/* Add expression to stack */
|
||||||
|
@ -2049,9 +2090,9 @@ unittest
|
||||||
|
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.lexer.tokens;
|
import tlang.compiler.lexer.tokens;
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
module myModule;
|
module myModule;
|
||||||
|
@ -2090,9 +2131,9 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
module myModule;
|
module myModule;
|
||||||
|
@ -2258,9 +2299,9 @@ class myClass2
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
|
@ -2327,9 +2368,9 @@ void function()
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
|
@ -2410,9 +2451,9 @@ int myFunction(int i, int j)
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
|
@ -2513,9 +2554,9 @@ void function()
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
module simple_pointer;
|
module simple_pointer;
|
||||||
|
@ -2614,9 +2655,9 @@ int thing()
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
|
@ -2738,9 +2779,9 @@ void function()
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.lexer.exceptions;
|
import tlang.compiler.lexer.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
|
|
||||||
string sourceCode = `
|
string sourceCode = `
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
module compiler.parsing.exceptions;
|
module tlang.compiler.parsing.exceptions;
|
||||||
|
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import misc.exceptions;
|
import misc.exceptions;
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import compiler.lexer.tokens : Token;
|
import tlang.compiler.lexer.tokens : Token;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
||||||
public class ParserException : TError
|
public class ParserException : TError
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module compiler.symbols.check;
|
module tlang.compiler.symbols.check;
|
||||||
|
|
||||||
import compiler.lexer.tokens : Token;
|
import tlang.compiler.lexer.tokens : Token;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.string : isNumeric, cmp;
|
import std.string : isNumeric, cmp;
|
||||||
import misc.utils;
|
import misc.utils;
|
||||||
|
@ -205,6 +205,28 @@ public bool isIdentifier_Dot(Token tokenIn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isNumericLiteral(string token)
|
||||||
|
{
|
||||||
|
import std.algorithm.searching : canFind;
|
||||||
|
import tlang.compiler.lexer.core :Lexer;
|
||||||
|
if(canFind(token, "UL") || canFind(token, "UI"))
|
||||||
|
{
|
||||||
|
return isNumeric(token[0..$-2]);
|
||||||
|
}
|
||||||
|
else if(canFind(token, "L") || canFind(token, "I"))
|
||||||
|
{
|
||||||
|
return isNumeric(token[0..$-1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: Check if we would even get here in terms of what the lexer
|
||||||
|
// ... would be able to rpoduce.
|
||||||
|
// We would get ehre with `1` for example, however check if `1A`
|
||||||
|
// would even be possible (if not then remove isNumeric below, else keep)
|
||||||
|
return isNumeric(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SymbolType getSymbolType(Token tokenIn)
|
public SymbolType getSymbolType(Token tokenIn)
|
||||||
{
|
{
|
||||||
string token = tokenIn.getToken();
|
string token = tokenIn.getToken();
|
||||||
|
@ -226,7 +248,8 @@ public SymbolType getSymbolType(Token tokenIn)
|
||||||
return SymbolType.STRING_LITERAL;
|
return SymbolType.STRING_LITERAL;
|
||||||
}
|
}
|
||||||
/* Number literal check */
|
/* Number literal check */
|
||||||
else if (isNumeric(token))
|
// FIXME: Add support for 2UI and 2I (isNumeric checks via D's logic)
|
||||||
|
else if (isNumericLiteral(token))
|
||||||
{
|
{
|
||||||
return SymbolType.NUMBER_LITERAL;
|
return SymbolType.NUMBER_LITERAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module compiler.symbols.containers;
|
module tlang.compiler.symbols.containers;
|
||||||
|
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used so often that we may as well
|
* Used so often that we may as well
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module compiler.symbols.data;
|
module tlang.compiler.symbols.data;
|
||||||
|
|
||||||
public import compiler.symbols.check;
|
public import tlang.compiler.symbols.check;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import compiler.typecheck.dependency.core : Context;
|
import tlang.compiler.typecheck.dependency.core : Context;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,7 +232,7 @@ public class TypedEntity : Entity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public import compiler.symbols.containers;
|
public import tlang.compiler.symbols.containers;
|
||||||
|
|
||||||
public class ArgumentList
|
public class ArgumentList
|
||||||
{
|
{
|
||||||
|
@ -308,7 +308,7 @@ public class Function : TypedEntity, Container
|
||||||
|
|
||||||
public Statement[] getStatements()
|
public Statement[] getStatements()
|
||||||
{
|
{
|
||||||
import compiler.symbols.containers : weightReorder;
|
import tlang.compiler.symbols.containers : weightReorder;
|
||||||
return weightReorder(bodyStatements);
|
return weightReorder(bodyStatements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ public class Variable : TypedEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public import compiler.symbols.expressions;
|
public import tlang.compiler.symbols.expressions;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ public class VariableExpression : IdentExpression
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
public override string evaluateType(TypeChecker typeChecker, Container c)
|
public override string evaluateType(TypeChecker typeChecker, Container c)
|
||||||
{
|
{
|
||||||
string type;
|
string type;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module compiler.symbols.expressions;
|
module tlang.compiler.symbols.expressions;
|
||||||
|
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
||||||
/* TODO: Look into arrays later */
|
/* TODO: Look into arrays later */
|
||||||
|
@ -147,7 +147,7 @@ public abstract class NumberLiteral : Expression
|
||||||
|
|
||||||
public class Expression : Statement
|
public class Expression : Statement
|
||||||
{
|
{
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
/* TODO: Takes in symbol table? */
|
/* TODO: Takes in symbol table? */
|
||||||
public string evaluateType(TypeChecker typechecker, Container c)
|
public string evaluateType(TypeChecker typechecker, Container c)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module compiler.symbols.typing.builtins;
|
module tlang.compiler.symbols.typing.builtins;
|
||||||
|
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import std.string : cmp, indexOf, lastIndexOf;
|
import std.string : cmp, indexOf, lastIndexOf;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: We should write spec here like I want int and stuff of proper size so imma hard code em
|
* TODO: We should write spec here like I want int and stuff of proper size so imma hard code em
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
module compiler.symbols.typing.core;
|
module tlang.compiler.symbols.typing.core;
|
||||||
|
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
||||||
public import compiler.symbols.typing.builtins;
|
public import tlang.compiler.symbols.typing.builtins;
|
||||||
|
|
||||||
public class Type : Entity
|
public class Type : Entity
|
||||||
{
|
{
|
||||||
|
@ -20,6 +20,9 @@ public class Type : Entity
|
||||||
{
|
{
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: A comparator would be nice but I would have to then see
|
||||||
|
// ... where referene equality was used, hence I stear clear of that
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class Void : Primitive
|
public final class Void : Primitive
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
module compiler.typecheck.core;
|
module tlang.compiler.typecheck.core;
|
||||||
|
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to, ConvException;
|
import std.conv : to, ConvException;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import compiler.typecheck.dependency.core;
|
import tlang.compiler.typecheck.dependency.core;
|
||||||
import compiler.codegen.instruction;
|
import tlang.compiler.codegen.instruction;
|
||||||
import std.container.slist;
|
import std.container.slist;
|
||||||
import std.algorithm : reverse;
|
import std.algorithm : reverse;
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ public final class TypeChecker
|
||||||
}
|
}
|
||||||
else if(isSameType(toType, getType(null, "ulong")))
|
else if(isSameType(toType, getType(null, "ulong")))
|
||||||
{
|
{
|
||||||
if(literalValue >= 0 && literalValue <= 18446744073709551615)
|
if(literalValue >= 0 && literalValue <= 18_446_744_073_709_551_615)
|
||||||
{
|
{
|
||||||
// Valid coercion
|
// Valid coercion
|
||||||
return true;
|
return true;
|
||||||
|
@ -423,7 +423,7 @@ public final class TypeChecker
|
||||||
// LiteralValue (integer literal instructions)
|
// LiteralValue (integer literal instructions)
|
||||||
else if(cast(LiteralValueFloat)literalInstr)
|
else if(cast(LiteralValueFloat)literalInstr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
// Unary operator
|
// Unary operator
|
||||||
else
|
else
|
||||||
|
@ -547,9 +547,9 @@ public final class TypeChecker
|
||||||
gprintln("typeCheckThing(): "~dnode.toString());
|
gprintln("typeCheckThing(): "~dnode.toString());
|
||||||
|
|
||||||
/* ExpressionDNodes */
|
/* ExpressionDNodes */
|
||||||
if(cast(compiler.typecheck.dependency.expression.ExpressionDNode)dnode)
|
if(cast(tlang.compiler.typecheck.dependency.expression.ExpressionDNode)dnode)
|
||||||
{
|
{
|
||||||
compiler.typecheck.dependency.expression.ExpressionDNode expDNode = cast(compiler.typecheck.dependency.expression.ExpressionDNode)dnode;
|
tlang.compiler.typecheck.dependency.expression.ExpressionDNode expDNode = cast(tlang.compiler.typecheck.dependency.expression.ExpressionDNode)dnode;
|
||||||
|
|
||||||
Statement statement = expDNode.getEntity();
|
Statement statement = expDNode.getEntity();
|
||||||
gprintln("Hdfsfdjfds"~to!(string)(statement));
|
gprintln("Hdfsfdjfds"~to!(string)(statement));
|
||||||
|
@ -959,13 +959,13 @@ public final class TypeChecker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* VariableAssigbmentDNode */
|
/* VariableAssigbmentDNode */
|
||||||
else if(cast(compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode)
|
else if(cast(tlang.compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode)
|
||||||
{
|
{
|
||||||
import compiler.typecheck.dependency.variables;
|
import tlang.compiler.typecheck.dependency.variables;
|
||||||
|
|
||||||
/* Get the variable's name */
|
/* Get the variable's name */
|
||||||
string variableName;
|
string variableName;
|
||||||
VariableAssignmentNode varAssignDNode = cast(compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode;
|
VariableAssignmentNode varAssignDNode = cast(tlang.compiler.typecheck.dependency.variables.VariableAssignmentNode)dnode;
|
||||||
Variable assignTo = (cast(VariableAssignment)varAssignDNode.getEntity()).getVariable();
|
Variable assignTo = (cast(VariableAssignment)varAssignDNode.getEntity()).getVariable();
|
||||||
variableName = resolver.generateName(modulle, assignTo);
|
variableName = resolver.generateName(modulle, assignTo);
|
||||||
gprintln("VariableAssignmentNode: "~to!(string)(variableName));
|
gprintln("VariableAssignmentNode: "~to!(string)(variableName));
|
||||||
|
@ -1013,7 +1013,7 @@ public final class TypeChecker
|
||||||
* TODO: We need to emit different code dependeing on variable declaration TYPE
|
* TODO: We need to emit different code dependeing on variable declaration TYPE
|
||||||
* We could use context for this, ClassVariableDec vs ModuleVariableDec
|
* We could use context for this, ClassVariableDec vs ModuleVariableDec
|
||||||
*/
|
*/
|
||||||
else if(cast(compiler.typecheck.dependency.variables.StaticVariableDeclaration)dnode)
|
else if(cast(tlang.compiler.typecheck.dependency.variables.StaticVariableDeclaration)dnode)
|
||||||
{
|
{
|
||||||
/* TODO: Add skipping if context is within a class */
|
/* TODO: Add skipping if context is within a class */
|
||||||
/* We need to wait for class static node, to do an InitInstruction (static init) */
|
/* We need to wait for class static node, to do an InitInstruction (static init) */
|
||||||
|
@ -1069,7 +1069,7 @@ public final class TypeChecker
|
||||||
addInstrB(varDecInstr);
|
addInstrB(varDecInstr);
|
||||||
}
|
}
|
||||||
/* TODO: Add class init, see #8 */
|
/* TODO: Add class init, see #8 */
|
||||||
else if(cast(compiler.typecheck.dependency.classes.classStaticDep.ClassStaticNode)dnode)
|
else if(cast(tlang.compiler.typecheck.dependency.classes.classStaticDep.ClassStaticNode)dnode)
|
||||||
{
|
{
|
||||||
/* Extract the class node and create a static allocation instruction out of it */
|
/* Extract the class node and create a static allocation instruction out of it */
|
||||||
Clazz clazzPNode = cast(Clazz)dnode.getEntity();
|
Clazz clazzPNode = cast(Clazz)dnode.getEntity();
|
||||||
|
@ -1081,7 +1081,7 @@ public final class TypeChecker
|
||||||
}
|
}
|
||||||
/* It will pop a bunch of shiiit */
|
/* It will pop a bunch of shiiit */
|
||||||
/* TODO: ANy statement */
|
/* TODO: ANy statement */
|
||||||
else if(cast(compiler.typecheck.dependency.core.DNode)dnode)
|
else if(cast(tlang.compiler.typecheck.dependency.core.DNode)dnode)
|
||||||
{
|
{
|
||||||
/* TODO: Get the STatement */
|
/* TODO: Get the STatement */
|
||||||
Statement statement = dnode.getEntity();
|
Statement statement = dnode.getEntity();
|
||||||
|
@ -1962,8 +1962,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/collide_container_module1.t";
|
string sourceFile = "source/tlang/testing/collide_container_module1.t";
|
||||||
|
|
||||||
|
@ -2009,8 +2009,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/collide_container_module2.t";
|
string sourceFile = "source/tlang/testing/collide_container_module2.t";
|
||||||
|
|
||||||
|
@ -2054,8 +2054,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/collide_container_non_module.t";
|
string sourceFile = "source/tlang/testing/collide_container_non_module.t";
|
||||||
|
|
||||||
|
@ -2099,8 +2099,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/collide_member.t";
|
string sourceFile = "source/tlang/testing/collide_member.t";
|
||||||
|
|
||||||
|
@ -2143,8 +2143,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/precedence_collision_test.t";
|
string sourceFile = "source/tlang/testing/precedence_collision_test.t";
|
||||||
|
|
||||||
|
@ -2189,8 +2189,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/collide_container.t";
|
string sourceFile = "source/tlang/testing/collide_container.t";
|
||||||
|
|
||||||
|
@ -2274,8 +2274,8 @@ unittest
|
||||||
{
|
{
|
||||||
import std.file;
|
import std.file;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import compiler.lexer.core;
|
import tlang.compiler.lexer.core;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
|
|
||||||
string sourceFile = "source/tlang/testing/typecheck/simple_function_call.t";
|
string sourceFile = "source/tlang/testing/typecheck/simple_function_call.t";
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
module compiler.typecheck.dependency.classes.classObject;
|
module tlang.compiler.typecheck.dependency.classes.classObject;
|
||||||
|
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import compiler.symbols.typing.builtins;
|
import tlang.compiler.symbols.typing.builtins;
|
||||||
import compiler.typecheck.dependency.core;
|
import tlang.compiler.typecheck.dependency.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (TODO) We don't init class in here, we do that when we see the type
|
* (TODO) We don't init class in here, we do that when we see the type
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
module compiler.typecheck.dependency.classes.classStaticDep;
|
module tlang.compiler.typecheck.dependency.classes.classStaticDep;
|
||||||
|
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import compiler.symbols.typing.builtins;
|
import tlang.compiler.symbols.typing.builtins;
|
||||||
import compiler.typecheck.dependency.core;
|
import tlang.compiler.typecheck.dependency.core;
|
||||||
|
|
||||||
public class ClassStaticNode : DNode
|
public class ClassStaticNode : DNode
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
module compiler.typecheck.dependency.classes.classVirtualInit;
|
module tlang.compiler.typecheck.dependency.classes.classVirtualInit;
|
||||||
|
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import compiler.symbols.typing.builtins;
|
import tlang.compiler.symbols.typing.builtins;
|
||||||
import compiler.typecheck.dependency.core;
|
import tlang.compiler.typecheck.dependency.core;
|
||||||
|
|
||||||
public class ClassVirtualInit : DNode
|
public class ClassVirtualInit : DNode
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
module compiler.typecheck.dependency.core;
|
module tlang.compiler.typecheck.dependency.core;
|
||||||
|
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import compiler.symbols.typing.builtins;
|
import tlang.compiler.symbols.typing.builtins;
|
||||||
import compiler.typecheck.dependency.exceptions : DependencyException, DependencyError;
|
import tlang.compiler.typecheck.dependency.exceptions : DependencyException, DependencyError;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -547,9 +547,9 @@ public class DNodeGenerator
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import compiler.typecheck.dependency.expression;
|
import tlang.compiler.typecheck.dependency.expression;
|
||||||
import compiler.typecheck.dependency.classes.classObject;
|
import tlang.compiler.typecheck.dependency.classes.classObject;
|
||||||
import compiler.typecheck.dependency.classes.classVirtualInit;
|
import tlang.compiler.typecheck.dependency.classes.classVirtualInit;
|
||||||
|
|
||||||
/* TODO: As mentioned in classObject.d we should static init the class type here */
|
/* TODO: As mentioned in classObject.d we should static init the class type here */
|
||||||
private ClassVirtualInit virtualInit(Clazz clazz)
|
private ClassVirtualInit virtualInit(Clazz clazz)
|
||||||
|
@ -1173,7 +1173,7 @@ public class DNodeGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
import compiler.typecheck.dependency.variables;
|
import tlang.compiler.typecheck.dependency.variables;
|
||||||
private ModuleVariableDeclaration pool_module_vardec(Variable entity)
|
private ModuleVariableDeclaration pool_module_vardec(Variable entity)
|
||||||
{
|
{
|
||||||
foreach(DNode dnode; nodePool)
|
foreach(DNode dnode; nodePool)
|
||||||
|
@ -1669,7 +1669,7 @@ public class DNodeGenerator
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
import compiler.typecheck.dependency.classes.classStaticDep;
|
import tlang.compiler.typecheck.dependency.classes.classStaticDep;
|
||||||
private ClassStaticNode poolClassStatic(Clazz clazz)
|
private ClassStaticNode poolClassStatic(Clazz clazz)
|
||||||
{
|
{
|
||||||
/* Sanity check */
|
/* Sanity check */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module compiler.typecheck.dependency.exceptions;
|
module tlang.compiler.typecheck.dependency.exceptions;
|
||||||
|
|
||||||
import misc.exceptions : TError;
|
import misc.exceptions : TError;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
module compiler.typecheck.dependency.expression;
|
module tlang.compiler.typecheck.dependency.expression;
|
||||||
|
|
||||||
import compiler.symbols.check;
|
import tlang.compiler.symbols.check;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.parsing.core;
|
import tlang.compiler.parsing.core;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import compiler.typecheck.exceptions;
|
import tlang.compiler.typecheck.exceptions;
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
import compiler.symbols.typing.builtins;
|
import tlang.compiler.symbols.typing.builtins;
|
||||||
import compiler.typecheck.dependency.core;
|
import tlang.compiler.typecheck.dependency.core;
|
||||||
|
|
||||||
public class ExpressionDNode : DNode
|
public class ExpressionDNode : DNode
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module compiler.typecheck.dependency.variables;
|
module tlang.compiler.typecheck.dependency.variables;
|
||||||
|
|
||||||
import compiler.typecheck.dependency.core;
|
import tlang.compiler.typecheck.dependency.core;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This module holds types related to variable declarations
|
* This module holds types related to variable declarations
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
module compiler.typecheck.exceptions;
|
module tlang.compiler.typecheck.exceptions;
|
||||||
|
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import compiler.typecheck.resolution;
|
import tlang.compiler.typecheck.resolution;
|
||||||
import std.string : cmp;
|
import std.string : cmp;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import misc.exceptions: TError;
|
import misc.exceptions: TError;
|
||||||
import compiler.symbols.typing.core;
|
import tlang.compiler.symbols.typing.core;
|
||||||
|
|
||||||
public class TypeCheckerException : TError
|
public class TypeCheckerException : TError
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module compiler.typecheck.resolution;
|
module tlang.compiler.typecheck.resolution;
|
||||||
|
|
||||||
import compiler.typecheck.core;
|
import tlang.compiler.typecheck.core;
|
||||||
import gogga;
|
import gogga;
|
||||||
import compiler.symbols.data;
|
import tlang.compiler.symbols.data;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
module simple_literals3;
|
||||||
|
|
||||||
|
ubyte var = 1UL;
|
||||||
|
|
||||||
|
void test()
|
||||||
|
{
|
||||||
|
var = 2L;
|
||||||
|
var = 2UI;
|
||||||
|
var = 2I;
|
||||||
|
}
|
Loading…
Reference in New Issue