public object visitUnaryExpr(Expression.Unary expr) { var first = expr.Operand.Accept(this); if (expr.Operator == null) { return(first); } // TODO Sematically check available operations (string - string impossible) // TODO abstract these operations (and maybe variable types) switch (expr.Operator.GetName()) { case "PLUS": return((int)first); case "MINUS": return(-((int)first)); case "NOT": return(!((bool)first)); default: throw new System.NotImplementedException(string.Format("UNARY {0} NOT IMPLEMENTED", expr.Operator.GetName())); } }
protected override object?Visit(Expression.Unary ury) { base.Visit(ury); // TODO: Implement everything // For now we assume correct usage switch (ury.Operator) { case Expression.UnaryOp.Dereference: { var subType = System.TypeOf(ury.Operand); if (!(subType is Type.Ptr)) { // TODO throw new NotImplementedException("Can't deref non-pointer!"); } } break; default: { // TODO } break; } return(null); }
public string visitUnaryExpr(Expression.Unary expr) { var firstType = expr.Operand.Accept(this); // TODO use eval to get types? if (expr.Operator != null && expr.Operator.Type == TokenType.NOT) { return("bool"); } return(firstType); }
public object VisitUnaryExpression(Expression.Unary expression) { object right = Evaluate(expression.right); switch (expression.op.type) { case TokenType.MINUS: CheckNumberOperand(expression.op, right); return(-(double)right); case TokenType.BANG: return(!IsTruthy(right)); } // Unreachable. return(null); }
public ByteCodeChunk VisitUnaryExpression(Expression.Unary expression) { var chunk = new ByteCodeChunk(); chunk.AddRange(VisitExpression(expression.Right)); switch (expression.Operator.Type) { case TokenType.Minus: chunk.AddInstruction(Instruction.NegateI); break; default: throw new ArgumentOutOfRangeException( $"`{expression.Operator.Type.ToString()} is not a valid unary operator.'"); } return(chunk); }
public string VisitUnaryExpression(Expression.Unary expression) { return(Parenthesize(expression.op.lexeme, expression.right)); }
public object VisitUnaryExpression(Expression.Unary expression) { Resolve(expression.right); return(null); }
public object VisitUnaryExpr(Expression.Unary expr) { throw new NotImplementedException("Resolver VisitUnaryExpr is not implemented"); }
public object VisitUnaryExpr(Expression.Unary expr) { throw new NotImplementedException(); }