Esempio n. 1
0
        public string Visit(Let_In node)
        {
            List <string> attrs = new List <string>();

            foreach (var attr in node.attrs.list_Node)
            {
                if (attr.exp != null)
                {
                    attrs.Add(Visit(attr.exp));
                }
                else
                {
                    attrs.Add(null);
                }
            }

            method.Add_scope("let");

            for (int i = 0; i < attrs.Count; i++)
            {
                string name = method.Add_local(node.attrs.list_Node[i].name.name);
                if (attrs[i] != null)
                {
                    method.Add_Instruction(new CIL_Assig(name, attrs[i]));
                }
            }

            var exp = Visit(node.exp);
            var ret = method.Add_local("expr", true);

            method.Add_Instruction(new CIL_Assig(ret, exp));
            method.End_scope();
            return(ret);
        }
        public bool Visit(Let_In node)
        {
            bool          solve      = true;
            List <string> id_defines = new List <string>();

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

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

            Context.UndefineSymbol(id_defines.Count);

            return(solve);
        }
        public bool Visit(Let_In node)
        {
            bool solve = true;

            foreach (var attr in node.attrs.list_Node)
            {
                solve &= this.Visit(attr);
            }
            solve &= this.Visit(node.exp);
            return(solve);
        }
Esempio n. 4
0
        public string Visit(Let_In node)
        {
            List <string> attrs = new List <string>();

            foreach (var attr in node.attrs.list_Node)
            {
                var a = "";
                if (attr.exp == null)
                {
                    if (attr.type.s == "Int")
                    {
                        a = new Const("0").Visit(this);
                    }
                    else if (attr.type.s == "String")
                    {
                        a = method.Add_local("expr", true);
                        method.Add_Instruction(new CIL_Load(a, Data[""]));
                    }
                    else if (attr.type.s == "Bool")
                    {
                        a = new Const("false").Visit(this);
                    }
                    else
                    {
                        a = "void";
                    }
                }
                else
                {
                    a = attr.exp.Visit(this);
                }
                attrs.Add(a);
            }

            method.Add_scope("let");

            for (int i = 0; i < attrs.Count; i++)
            {
                string name = method.Add_local(node.attrs.list_Node[i].name.name);
                if (attrs[i] != null)
                {
                    method.Add_Instruction(new CIL_Assig(name, attrs[i]));
                }
            }
            var exp = node.exp.Visit(this);
            var ret = method.Add_local("expr", true);

            method.Add_Instruction(new CIL_Assig(ret, exp));
            method.End_scope();
            return(ret);
        }
Esempio n. 5
0
        public IType Visit(Let_In node)
        {
            foreach (Attr_Def cld in node.attrs.list_Node)
            {
                this.Visit(cld);
                Context.DefineSymbol(cld.name.name, Context.GetType(cld.type.s));
            }

            IType type = this.Visit(node.exp);

            foreach (Attr_Def cld in node.attrs.list_Node)
            {
                Context.UndefineSymbol();
            }

            return(type);
        }
Esempio n. 6
0
 public bool Visit(Let_In node)
 {
     throw new System.NotImplementedException();
 }