public override void VisitNeg(ASTNegative n) { CFlatType t = CheckSubTree(n.Expression); if (t.IsNumeric) { n.CFlatType = t; _lastSeenType = t; } else { ReportError(n.Location, "Only numeric datatypes can be negated. Got type '{0}'", TypeToFriendlyName(t)); } }
protected override bool Visit(ASTNegative node) { if (!Visit(node.Child)) { return(false); } var childType = node.Child.TypeInfo; if (childType is FloatType f) { node.TypeInfo = f; return(true); } if (childType is IntegerType i) { if (!i.Signed) { if (i.Size != BaseType.UnknownSize) { Error(node.Position, $"Cannot negate {childType}"); return(false); } // If the size of the unsigned interger is unknown, then we are free to convert between signed and unsigned node.TypeInfo = Cache.GetInt(BaseType.UnknownSize, true); return(true); } node.TypeInfo = i; return(true); } Error(node.Position, $"Cannot negate {childType}"); return(false); }
protected override bool Visit(ASTNegative node) => EmitUnary <CNegative>(node);
public override void VisitNeg(ASTNegative n) { throw new NotImplementedException(); }
protected abstract bool Visit(ASTNegative node);