tlang/source/tlang/compiler/codegen/mapper/core.d

31 lines
554 B
D
Raw Normal View History

Command-line - All compilation stages now make use of the `Compiler` object Compiler - Added new exception type `CompilerException` complete with a sub-type enum, `CompilerError` - `getConfig()` will now throw a `CompilerException` when a key is not found, rather than return false (which didn't work under different template types anyways) - Implemented `hasConfig()` to check for the existence of a key in the configuration sub-system's key-value store - The `Compiler` object now stores the `Token[] tokens` generated from the call to `doLex()` - The `Compiler` object now stores the resulting container (`Module`) generated from the call to `doParse()` - Set default symbol mapping technique to the hashmapper technique - Implemented `dolex()` for performing tokenization, it will create and store a `Lexer` instance and the produced `Token[] tokens` into the `Compiler` object - Added `getTokens()` to fetch the tokens generated by `doLex()` - Implemented `doParse()`, `doTypeCheck()` and `doEmit()` in a similiar fashion to `doLex()` - Implemented `getMdoule()` to get the container (`Module`) generated by `doParse()` - Implemented `compile()` which calls `doLex()`, then `doParse()`, then `doTypeCheck()` and finally `doEmit()` CodeEmitter - The `CodeEmitter` constructor now takes in an instance of the chosen `SymbolMapper` DGen - Switched to the instance of the `mapper` inheited from the `CodeMapper` parent class for any `symbolMap` calls required - Use the inherited `TypeChecker` instance and not an instance of it provided by `Context` SymbolMapper - Reworked this class into an abstract class which must have its children implement a `symbolMap(Entity)` interface, this provides us pluggable mapping techniques HashMapper - Moved hashing symbol-mapping technique into `HashMapper` Lebanese - Created a kind-of `SymbolMapper` which, unlike `HashMapper`, produces human-redable-yet-valid C symbols (by replacing the `.`'s with `_`'s) TypeChecker - Removed code for setting now-nonexistent `SymbolMapper.tc` - Removed code for setting now-nonexistent `Context.tc` Context - Removed `static TypeChecker tc` field
2023-01-23 18:44:35 +00:00
module compiler.codegen.mapper.core;
import compiler.typecheck.core;
import compiler.symbols.data;
import std.conv : to;
import gogga;
/**
* SymbolMapper
*
* Maps Entity's to consistent but unique symbol
* names (strings)
*/
public class SymbolMapper
{
// Used to map names to entities
protected TypeChecker tc;
this(TypeChecker tc)
{
this.tc = tc;
}
public abstract string symbolLookup(Entity entityIn);
}
public enum SymbolMappingTechnique : string
{
HASHMAPPER = "hashmapper",
LEBANESE = "lebanese"
Command-line - All compilation stages now make use of the `Compiler` object Compiler - Added new exception type `CompilerException` complete with a sub-type enum, `CompilerError` - `getConfig()` will now throw a `CompilerException` when a key is not found, rather than return false (which didn't work under different template types anyways) - Implemented `hasConfig()` to check for the existence of a key in the configuration sub-system's key-value store - The `Compiler` object now stores the `Token[] tokens` generated from the call to `doLex()` - The `Compiler` object now stores the resulting container (`Module`) generated from the call to `doParse()` - Set default symbol mapping technique to the hashmapper technique - Implemented `dolex()` for performing tokenization, it will create and store a `Lexer` instance and the produced `Token[] tokens` into the `Compiler` object - Added `getTokens()` to fetch the tokens generated by `doLex()` - Implemented `doParse()`, `doTypeCheck()` and `doEmit()` in a similiar fashion to `doLex()` - Implemented `getMdoule()` to get the container (`Module`) generated by `doParse()` - Implemented `compile()` which calls `doLex()`, then `doParse()`, then `doTypeCheck()` and finally `doEmit()` CodeEmitter - The `CodeEmitter` constructor now takes in an instance of the chosen `SymbolMapper` DGen - Switched to the instance of the `mapper` inheited from the `CodeMapper` parent class for any `symbolMap` calls required - Use the inherited `TypeChecker` instance and not an instance of it provided by `Context` SymbolMapper - Reworked this class into an abstract class which must have its children implement a `symbolMap(Entity)` interface, this provides us pluggable mapping techniques HashMapper - Moved hashing symbol-mapping technique into `HashMapper` Lebanese - Created a kind-of `SymbolMapper` which, unlike `HashMapper`, produces human-redable-yet-valid C symbols (by replacing the `.`'s with `_`'s) TypeChecker - Removed code for setting now-nonexistent `SymbolMapper.tc` - Removed code for setting now-nonexistent `Context.tc` Context - Removed `static TypeChecker tc` field
2023-01-23 18:44:35 +00:00
}