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

48 lines
1.3 KiB
D
Raw Normal View History

module compiler.codegen.mapper;
import compiler.typecheck.core;
import compiler.symbols.data;
App - Added newline to release info print - Fixed module docstring Commands - Added new command-line options: `syntaxcheck`, `typecheck` - Added todo to `help` command - Re-ordered commands for order of appearance in help text Compiler - Added docstring to `beginCompilation(string[])` function Mapper - Added debug print of the Container being used for the symbol lookup CodeEmitter - Re-worked CodeEmitter class to use a single so-called "selected queue" - Added methods to move back and forth between said "selected queue", get the length, etc. - Remove old queue-specific methods DGen - Use the new CodeEmitter "selected-queue" functionality - Emit function definitions now supported Exceptions - Added this keyword Check - Added support for SymbolTYpe.OCURLY and SymbolType.CCURLY to `getCharacter(SymbolType)` Data - Added a `hasParams()` method to the Function entity type TypeChecker - Added support for emitting function definitions (required DNode.poes = [] (cleaning), codeQueue cleaning etc.) - Added `getInitQueue()` method to make a copy of the current "scratchpad" `codeQueue` - Build up a copy of the global queue now (make a copy similiar to what we did for `getInitQueue()` but inline) - Added a debug print Dependency - Added a FIXME note for issue #46 - Added a TODO relating to `static DNode[] poes` Test cases - Added test case `simple_function_decls.t` to test function definition code emit - Updated test case `simple_variables.t` to note that the T code generates invalid C code README - Build instructions now generate coverage files (`.lst`s) - Updated link to documentation
2022-12-14 17:49:08 +00:00
import std.conv : to;
import gogga;
/**
* SymbolMapper
*
* Maps Entity's to consistent but unique symbol
* names (strings)
*/
public final class SymbolMapper
{
// Used to map names to entities
public static TypeChecker tc;
// Entity map
// private string[Entity] symbolMap;
// this(TypeChecker tc)
// {
// this.tc = tc;
// }
public static string symbolLookup(Container container, string entityNameIn)
{
// Firstly translate the entity name to the full absolute path
auto entity = tc.getResolver().resolveBest(container, entityNameIn); //TODO: Remove `auto`
string entityNameAbsolute = tc.getResolver().generateName(tc.getModule(), entity);
App - Added newline to release info print - Fixed module docstring Commands - Added new command-line options: `syntaxcheck`, `typecheck` - Added todo to `help` command - Re-ordered commands for order of appearance in help text Compiler - Added docstring to `beginCompilation(string[])` function Mapper - Added debug print of the Container being used for the symbol lookup CodeEmitter - Re-worked CodeEmitter class to use a single so-called "selected queue" - Added methods to move back and forth between said "selected queue", get the length, etc. - Remove old queue-specific methods DGen - Use the new CodeEmitter "selected-queue" functionality - Emit function definitions now supported Exceptions - Added this keyword Check - Added support for SymbolTYpe.OCURLY and SymbolType.CCURLY to `getCharacter(SymbolType)` Data - Added a `hasParams()` method to the Function entity type TypeChecker - Added support for emitting function definitions (required DNode.poes = [] (cleaning), codeQueue cleaning etc.) - Added `getInitQueue()` method to make a copy of the current "scratchpad" `codeQueue` - Build up a copy of the global queue now (make a copy similiar to what we did for `getInitQueue()` but inline) - Added a debug print Dependency - Added a FIXME note for issue #46 - Added a TODO relating to `static DNode[] poes` Test cases - Added test case `simple_function_decls.t` to test function definition code emit - Updated test case `simple_variables.t` to note that the T code generates invalid C code README - Build instructions now generate coverage files (`.lst`s) - Updated link to documentation
2022-12-14 17:49:08 +00:00
gprintln("symbolLookup(): "~to!(string)(container));
// Hash the absolute path name
// FIXME: Ensure these hashes are unique (use the smbyol table!)
import std.digest : toHexString, LetterCase;
import std.digest.md : md5Of;
// Generate the name as `_<hexOfAbsPath>`
string symbolName = toHexString!(LetterCase.lower)(md5Of(entityNameAbsolute));
symbolName="t_"~symbolName;
return symbolName;
}
}