示例#1
0
        public void Visit(DispatchExplicitNode node)
        {
            node.Expression.Accept(this);
            if (node.IdType.Text == "Object")
            {
                node.IdType = new TypeNode(node.Expression.Line, node.Expression.Column, node.Expression.StaticType.Text);
            }

            if (!scope.IsDefinedType(node.IdType.Text, out TypeInfo typeSuperClass))
            {
                errors.Add(SemanticError.NotDeclaredType(node.IdType));
            }

            if (!(node.Expression.StaticType <= typeSuperClass))
            {
                errors.Add(SemanticError.CannotConvert(node, node.Expression.StaticType, typeSuperClass));
            }

            node.Arguments.ForEach(x => x.Accept(this));

            var scopeSuperClass = typeSuperClass.ClassReference.Scope;

            if (!(scopeSuperClass.IsDefined(node.IdMethod.Text, node.Arguments.Select(x => x.StaticType).ToArray(), out node.StaticType)))
            {
                errors.Add(SemanticError.NotDeclareFunction(node, node.IdMethod.Text));
            }
        }
示例#2
0
        public void Visit(DispatchExplicitNode node)
        {
            string cclass = node.IdType.Text;

            node.Expression.Accept(this);
            DispatchVisit(node, cclass);
        }
示例#3
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);
        }
示例#4
0
 public void Visit(DispatchExplicitNode node)
 {
     throw new NotImplementedException();
 }