public override Type VisitUnary_not_neg(BRAQParser.Unary_not_negContext context) { //right: right_short_call=short_call | right_call=call | right_literal=literal Type right_type = context.right.Accept(this); if (context.op != null) { try { var type_pair = TypeAllowances .Find(x => x.Equals(new TypeHelper(null, right_type, context.op.Text, null))); type_dict[context] = type_pair.result; return(type_dict[context]); } catch (ArgumentNullException) { string msg = $"Failed to find matching operator {context.op.Text} for type {right_type} [Line {context.op.Line}]"; Console.WriteLine(msg); throw new TypeMismatchError(msg); } } type_dict[context] = right_type; return(right_type); }
public override int VisitUnary_not_neg(BRAQParser.Unary_not_negContext context) { context.right.Accept(this); if (context.op != null) { switch (context.op.Text) { case "-": il.Emit(OpCodes.Neg); break; case "not": il.Emit(OpCodes.Ldc_I4_0); il.Emit(OpCodes.Ceq); break; } } return(0); }
/// <summary> /// Visit a parse tree produced by <see cref="BRAQParser.unary_not_neg"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitUnary_not_neg([NotNull] BRAQParser.Unary_not_negContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="BRAQParser.unary_not_neg"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitUnary_not_neg([NotNull] BRAQParser.Unary_not_negContext context) { }