Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
HeronErin committed May 21, 2024
2 parents 14be985 + 4aafd61 commit edb0680
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 150 deletions.
28 changes: 28 additions & 0 deletions source/arbore/cache.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module arbore.cache;

import fnc.symbols;
import std.stdio;

public:
void store()
{
string[Module] caches;
foreach (symbol; glob.symbols.byValue)
{
if (!symbol.evaluated)
continue;

if (symbol._module !in caches)
caches[symbol._module] = null;

if (!symbol.isAliasSeq)
caches[symbol._module] ~= "alias "~symbol.identifier~" = "~(cast(Alias)symbol).single.identifier~";";
else
{
caches[symbol._module] ~= "alias[] "~symbol.identifier~" = [";
foreach (sym; (cast(Alias)symbol).many)
caches[symbol._module] ~= sym.identifier~", ";
caches[symbol._module] = caches[symbol._module][0..$-2]~"];";
}
}
}
42 changes: 41 additions & 1 deletion source/fnc/emission/ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,48 @@ final:
return true;
}

this(OpCode opcode, Symbol[] operands...)
this(ARGS...)(OpCode opcode, ARGS args)
{
Symbol[] operands;
foreach (arg; args)
{
static if (is(Unqual!(typeof(arg)) == Symbol))
operands ~= cast(Symbol)arg;
else
{
SymAttr attr = SymAttr.LITERAL;
// We don't check for if its a vector, but this shouldn't matter.
static if (is(typeof(arg) == string))
attr |= SymAttr.STRING;
else static if (is(typeof(arg) == ubyte) || is(typeof(arg) == byte))
attr |= SymAttr.BYTE;
else static if (is(typeof(arg) == ushort) || is(typeof(arg) == short))
attr |= SymAttr.WORD;
else static if (is(typeof(arg) == uint) || is(typeof(arg) == int))
attr |= SymAttr.DWORD;
else static if (is(typeof(arg) == ulong) || is(typeof(arg) == long))
attr |= SymAttr.QWORD;
else static if (is(typeof(arg) == float))
attr |= SymAttr.FLOAT;
else static if (is(typeof(arg) == double))
attr |= SymAttr.DOUBLE;
else static if (isArray!(typeof(arg)))
attr |= SymAttr.ARRAY;

static if (isStaticArray!(typeof(arg)))
attr |= SymAttr.FIXARRAY;
else static if (isAssociativeArray!(typeof(arg)))
attr |= SymAttr.ASOARRAY;
else static if (isDynamicArray!(typeof(arg)))
attr |= SymAttr.DYNARRAY;

static if (isSigned!(typeof(arg)))
attr |= SymAttr.SIGNED;

operands ~= new Symbol(glob, attr, null, null, null, null, Marker(arg));
}
}

Details detail(string fmt) pure
{
Details ret;
Expand Down
Loading

0 comments on commit edb0680

Please sign in to comment.