Exemple #1
0
 public AtsimNode(CoolParser.AtsimExpContext context, Node s) : base(s.Childs)
 {
     this.context = context;
     Expresion    = context.expresion(0);
     Params       = context.expresion();
     MethodID     = context.ID();
     try {
         CallerType  = SymbolTable.Classes[context.TYPE().GetText()];
         Method_Node = SymbolTable.Classes[CallerType.Name].Methods[context.ID().GetText()];
     }catch (Exception) { /* :( */ }
 }
        public override object VisitAtsimExp([NotNull] CoolParser.AtsimExpContext context)
        {
            Expression invokerExp  = (Expression)Visit(context.expresion()[0]);
            Type       invokedType = null;

            if (context.TYPE() != null)
            {
                string s = context.TYPE().GetText();
                if (p.Types.ContainsKey(s))
                {
                    invokedType = p.Types[context.TYPE().GetText()];
                }
                else
                {
                    invokedType = new Type(context.TYPE().GetText(), null, GetCoord(context));
                }
            }

            List <Expression> parameters = new List <Expression>();

            for (int i = 1; i < context.expresion().Length; i++)
            {
                parameters.Add((Expression)Visit(context.expresion()[i]));
            }

            var d = new Dispatch(invokerExp, invokedType, context.ID().GetText(), parameters, GetCoord(context));

            return(d);
        }