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; }
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); }
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); }
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); }
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); }
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); }
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]";
private static ESIR_Field Field(ESIR_TypeNode type, ESIR_ValueNode offset, ESIR_ValueNode name) => new (type, offset, name);
private static ESIR_StaticVariable StaticVariable(ESIR_TypeNode type, ESIR_ValueNode id) => new (type, id);
public static ESIR_StaticVariable StaticVariable(ESIR_TypeNode type, ArrayPointer <byte> id) => StaticVariable(type, ValueNode(id));
public static ESIR_Field Field(ESIR_TypeNode type, int offset, ArrayPointer <byte> name) => Field(type, ValueNode(offset), ValueNode(name));
internal ESIR_CastExpression(ESIR_Expression expr, ESIR_TypeNode elemType) { destTypeNode = elemType; exprNode = expr; }
internal ESIR_NewArrayExpression(ESIR_TypeNode elemType, ESIR_List <ESIR_Expression> ranks) { elemTypeNode = elemType; ranksNode = ranks; }
internal ESIR_NewObjectExpression(ESIR_TypeNode type) => typeNode = type;
internal ESIR_DefaultValueExpression(ESIR_TypeNode type) => typeNode = type;
internal ESIR_NullLiteralExpression(ESIR_TypeNode type) => typeNode = type;