public bool Visit(Method_Def node)
        {
            bool          solve      = true;
            List <string> id_defines = new List <string>();

            foreach (var arg in node.args.list_Node)
            {
                if (id_defines.Contains(arg.name.name))
                {
                    Logger += "En la expresion " + node.ToString() + "-> error de identificador ('" + arg.name.name + "' ya esta definido) \n";
                    solve   = false;
                }
                else
                {
                    id_defines.Add(arg.name.name);
                    Context.DefineSymbol(arg.name.name, Context.GetType(arg.type.s));
                }
            }

            solve &= this.Visit(node.exp);

            Context.UndefineSymbol(id_defines.Count);

            return(solve);
        }
Exemplo n.º 2
0
        public string Visit(Method_Def node)
        {
            method = new Current_Method();
            string solution = Visit(node.exp);

            method.Add_Instruction(new CIL_Return(solution));
            Code.Add(node.name.name, new CIL_Function(node.name.name, new List <string>(node.args.list_Node.Select(x => x.name.name)), new List <string>(method.locals.Values), method.body));
            return("");
        }
Exemplo n.º 3
0
        public string Visit(Method_Def node)
        {
            method      = new Current_Method();
            method.args = new List <string>(node.args.list_Node.Select(m => m.name.name));
            string solution = node.exp.Visit(this);

            method.Add_Instruction(new CIL_Return(solution));
            string mtdName = node.name.name + "_" + current_type.Name;

            Code.Add(mtdName, new CIL_Function(mtdName, new List <string>(node.args.list_Node.Select(x => x.name.name)), new List <string>(method.locals.Values), method.body));
            return("");
        }
        public bool Visit(Method_Def node)
        {
            bool solve = true;

            solve &= Visit(node.type);

            foreach (var arg in node.args.list_Node)
            {
                solve &= this.Visit(arg);
            }


            solve &= this.Visit(node.exp);
            return(solve);
        }
Exemplo n.º 5
0
        public IType Visit(Method_Def node)
        {
            foreach (var arg in node.args.list_Node)
            {
                Context.DefineSymbol(arg.name.name, Context.GetType(arg.type.s));
            }

            IType type_exp    = this.Visit(node.exp);
            IType type_return = Context.GetType(node.type.s);

            if (type_exp != null && type_return != null && !type_exp.Conform(type_return))
            {
                Logger += "En la expresion " + node.ToString() + "-> error de tipos (El tipo de la expresion no se conforma al tipo de retorno) \n";
                return(null);
            }

            foreach (var arg in node.args.list_Node)
            {
                Context.UndefineSymbol();
            }

            return(type_return);
        }
Exemplo n.º 6
0
 public bool Visit(Method_Def node)
 {
     throw new System.NotImplementedException();
 }