Example #1
0
        public override ASTNode VisitDispatchExplicit([NotNull] CoolParser.DispatchExplicitContext context)
        {
            DispatchExplicitNode node = new DispatchExplicitNode(context)
            {
                Expression = Visit(context.expression(0)) as ExpressionNode
            };

            var typeSuperClass = context.TYPE() == null ? new TypeNode(node.Expression.Line, node.Expression.Column, node.Expression.StaticType.Text) :
                                 new TypeNode(context.TYPE().Symbol.Line, context.TYPE().Symbol.Column, context.TYPE().GetText());

            node.IdType = typeSuperClass;

            IdNode idNode = new IdNode(context.ID().Symbol.Line, context.ID().Symbol.Column, context.ID().GetText());

            node.IdMethod = idNode;

            node.Arguments = (from x in context.expression().Skip(1) select Visit(x) as ExpressionNode).ToList();
            return(node);
        }
        public override ASTNode VisitDispatchExplicit([NotNull] CoolParser.DispatchExplicitContext context)
        {
            var _base    = Visit(context.expr(0)) as ExpressionNode;
            var idMethod = new IdNode(context.ID().Symbol.Line, context.ID().Symbol.Column, context.ID().GetText());
            var args     = (from x in context.expr().Skip(1) select Visit(x) as ExpressionNode).ToList();

            return(context.TYPE() == null ?
                   new ExplicitDispatch(context.Start.Line, context.Start.Column)
            {
                Base = _base, IdMethod = idMethod, Arguments = args
            } as DispatchNode :
                   new BaseDispatch(context.Start.Line, context.Start.Column)
            {
                Base = _base,
                IdMethod = idMethod,
                Arguments = args,
                TypeBase = new TypeNode(context.TYPE().Symbol.Line, context.TYPE().Symbol.Column, context.TYPE().GetText())
            });
        }