Exemple #1
0
    private static ESIR_TypeNode TypeNode (ESIR_ValueNode ptr) {
        var node = ESIR_NodeCache.Shared.TryGetNode (ESIR_NodeKind.TypeNode, ptr, out var hash);
        if (node is not null)
            return (ESIR_TypeNode) node;

        var ret = new ESIR_TypeNode (ptr);
        if (hash >= 0)
            ESIR_NodeCache.Shared.AddNode (ret, hash);

        return ret;
    }
Exemple #2
0
        public int RentRegister(ESIR_TypeNode type)
        {
            var regType = type;

            var regsSpan = registers.Span;

            for (var i = 0; i < regCount; i++)
            {
                ref var reg = ref regsSpan [i];
                if (reg.Used || reg.Type.Pointer != regType.Pointer)
                {
                    continue;
                }

                reg.Used = true;
                return(i);
            }
Exemple #3
0
    public static ESIR_NewArrayExpression NewArrayExpression(ESIR_TypeNode elemType, ESIR_List <ESIR_Expression> indices)
    {
        var node = ESIR_NodeCache.Shared.TryGetNode(ESIR_NodeKind.NewArrayExpression, elemType, indices, out var hash);

        if (node is not null)
        {
            return((ESIR_NewArrayExpression)node);
        }

        var ret = new ESIR_NewArrayExpression(elemType, indices);

        if (hash >= 0)
        {
            ESIR_NodeCache.Shared.AddNode(ret, hash);
        }

        return(ret);
    }
Exemple #4
0
    public static ESIR_CastExpression CastExpression(ESIR_Expression expression, ESIR_TypeNode destType)
    {
        var node = ESIR_NodeCache.Shared.TryGetNode(ESIR_NodeKind.CastExpression, expression, destType, out var hash);

        if (node is not null)
        {
            return((ESIR_CastExpression)node);
        }

        var ret = new ESIR_CastExpression(expression, destType);

        if (hash >= 0)
        {
            ESIR_NodeCache.Shared.AddNode(ret, hash);
        }

        return(ret);
    }
Exemple #5
0
    public static ESIR_NewObjectExpression NewObjectExpression(ESIR_TypeNode type)
    {
        var node = ESIR_NodeCache.Shared.TryGetNode(ESIR_NodeKind.NewObjectExpression, type, out var hash);

        if (node is not null)
        {
            return((ESIR_NewObjectExpression)node);
        }

        var ret = new ESIR_NewObjectExpression(type);

        if (hash >= 0)
        {
            ESIR_NodeCache.Shared.AddNode(ret, hash);
        }

        return(ret);
    }
Exemple #6
0
    private static ESIR_ArgumentDefinition ArgumentDefinition(ESIR_ValueNode argType, ESIR_TypeNode valueType)
    {
        var node = ESIR_NodeCache.Shared.TryGetNode(ESIR_NodeKind.ArgumentDefinition, argType, valueType, out var hash);

        if (node is not null)
        {
            return((ESIR_ArgumentDefinition)node);
        }

        var ret = new ESIR_ArgumentDefinition(argType, valueType);

        if (hash >= 0)
        {
            ESIR_NodeCache.Shared.AddNode(ret, hash);
        }

        return(ret);
    }
Exemple #7
0
 public static ESIR_ArgumentDefinition ArgumentDefinition(ES_ArgumentType argType, ESIR_TypeNode valueType)
 => ArgumentDefinition(ValueNode((int)argType), valueType);
 private unsafe string GetLocalValueString(int i, ESIR_TypeNode valType) => $"{i} : {GetTypeName (valType)}";
 private unsafe string GetTypeName(ESIR_TypeNode type) => type is not null?GetTypeName(type.Pointer) : "[TYPE NODE NULL]";
Exemple #10
0
 private static ESIR_Field Field(ESIR_TypeNode type, ESIR_ValueNode offset, ESIR_ValueNode name)
 => new (type, offset, name);
Exemple #11
0
 private static ESIR_StaticVariable StaticVariable(ESIR_TypeNode type, ESIR_ValueNode id) => new (type, id);
Exemple #12
0
 public static ESIR_StaticVariable StaticVariable(ESIR_TypeNode type, ArrayPointer <byte> id)
 => StaticVariable(type, ValueNode(id));
Exemple #13
0
 public static ESIR_Field Field(ESIR_TypeNode type, int offset, ArrayPointer <byte> name)
 => Field(type, ValueNode(offset), ValueNode(name));
Exemple #14
0
 internal ESIR_CastExpression(ESIR_Expression expr, ESIR_TypeNode elemType)
 {
     destTypeNode = elemType;
     exprNode     = expr;
 }
Exemple #15
0
 internal ESIR_NewArrayExpression(ESIR_TypeNode elemType, ESIR_List <ESIR_Expression> ranks)
 {
     elemTypeNode = elemType;
     ranksNode    = ranks;
 }
Exemple #16
0
 internal ESIR_NewObjectExpression(ESIR_TypeNode type) => typeNode = type;
Exemple #17
0
 internal ESIR_DefaultValueExpression(ESIR_TypeNode type) => typeNode = type;
Exemple #18
0
 internal ESIR_NullLiteralExpression(ESIR_TypeNode type) => typeNode = type;