private void ConvertToDoubleIfNeeded(MiniType a, MiniType b) { if (a == MiniType.Double && b != MiniType.Double) { Emit("conv." + MiniType.Double.ToPrimitive()); } }
public VariableDeclaration(string name, IScope scope, MiniType type, LexLocation loc = null) { Name = name; Scope = scope; scope.AddToScope(this); Type = type; Location = loc; }
public override MiniType GetResultType(MiniType typeA, MiniType typeB = MiniType.Unknown) { if (typeA == MiniType.Unknown || typeB == MiniType.Unknown) { throw new ArgumentException("You can't use this operator on this types."); } return(GetResultTypeBinary(typeA, typeB)); }
public override bool CanUse(MiniType typeA, MiniType typeB) { switch (typeA) { case MiniType.Double: return(typeB == MiniType.Double || typeB == MiniType.Int); } return(typeA == typeB); }
public override bool CanUse(MiniType typeA) { switch (typeA) { case MiniType.Int: return(true); } return(false); }
public override bool CanUse(MiniType typeA, MiniType typeB = MiniType.Unknown) { switch (typeA) { case MiniType.Int: return(typeB == MiniType.Int || typeB == MiniType.Double); case MiniType.Double: return(typeB == MiniType.Int || typeB == MiniType.Double); } return(false); }
public static string ToPrimitive(this MiniType type) { switch (type) { case MiniType.Int: return("i4"); case MiniType.Double: return("r8"); case MiniType.Bool: return("i4"); } return(null); }
public static string ToCil(this MiniType type) { switch (type) { case MiniType.Int: return("int32"); case MiniType.Double: return("float64"); case MiniType.Bool: return("bool"); case MiniType.String: return("string"); } return(null); }
public static string ToCSharp(this MiniType type) { switch (type) { case MiniType.Int: return("Int32"); case MiniType.Double: return("Double"); case MiniType.Bool: return("Boolean"); case MiniType.String: return("String"); } return(null); }
private TypeNode CreateValue() { var value = ValueStack[ValueStack.Depth - 1]; MiniType type = value.token.ConvertToType(); string val = value.val; TypeNode result; if (type == MiniType.Unknown) { result = Error("Cannot use provided type: {0}", value.token).typeNode; StartRecovery(); } else { result = new Value(type, val, CurrentLocationSpan); } return(result); }
public Value(MiniType type, string val, LexLocation loc = null) { Type = type; Val = val; Location = loc; }
public override MiniType GetResultType(MiniType type) { return(type); }
public Operator WithResultType(MiniType typeA, MiniType typeB = MiniType.Unknown) { Type = GetResultType(typeA, typeB); return(this); }
public abstract bool CanUse(MiniType typeA);
public abstract MiniType GetResultType(MiniType type);
public static Operator Create(Token token, MiniType typeA, LexLocation location = null) { var operatorToken = token.ConvertToOperator(true); return(Create(operatorToken, location).WithResultType(typeA)); }
public abstract bool CanUse(MiniType typeA, MiniType typeB = MiniType.Unknown);
public static bool CanUse(Token token, MiniType typeA) { lastToken = token.ConvertToOperator(true); lastOperator = CreateFromToken(lastToken); return(lastOperator.CanUse(typeA)); }
public static Operator Create(Token token, MiniType typeA, LexLocation location = null) => Factory.Create(token, typeA, location);
public static bool CanUse(Token token, MiniType typeA) => Factory.CanUse(token, typeA);
public override MiniType GetResultTypeBinary(MiniType typeA, MiniType typeB) { return(typeA == MiniType.Double || typeB == MiniType.Double ? MiniType.Double : MiniType.Int); }
public override bool CanUse(MiniType typeA) { return(typeA != MiniType.Unknown); }
public abstract MiniType GetResultTypeBinary(MiniType typeA, MiniType typeB);
public abstract MiniType GetResultType(MiniType typeA, MiniType typeB = MiniType.Unknown);
public override bool CanUse(MiniType typeA, MiniType typeB = MiniType.Unknown) { return(typeA == MiniType.Bool && typeB == MiniType.Bool); }
public override bool CanUse(MiniType typeA) { return(false); }
public override MiniType GetResultTypeBinary(MiniType typeA, MiniType typeB) { return(MiniType.Bool); }
public override MiniType GetResultType(MiniType typeA, MiniType typeB = MiniType.Unknown) { return(MiniType.Unknown); }