Exemplo n.º 1
0
        public IType Visit(While_loop node)
        {
            IType type_exp1 = this.Visit(node.exp1);

            this.Visit(node.exp2);

            if (type_exp1 == null || type_exp1.Name != "Bool")
            {
                Logger += "En la expresion " + node.ToString() + "-> error de tipos (La condicion no tiene tipo bool) \n";
            }
            return(Context.GetType("Object"));
        }
Exemplo n.º 2
0
        public string Visit(While_loop node)
        {
            var begin_while = method.current_scope.Get_var("begin_while");
            var body_while  = method.current_scope.Get_var("body_while");
            var end_while   = method.current_scope.Get_var("end_while");

            var ret  = method.Add_local("ret_while", true);
            var cond = Visit(node.exp1);
            var body = Visit(node.exp2);

            method.Add_Instruction(new CIL_Label(begin_while));
            method.Add_Instruction(new CIL_ConditionalJump(cond, body_while));
            method.Add_Instruction(new CIL_Goto(end_while));
            method.Add_Instruction(new CIL_Label(body_while));
            method.Add_Instruction(new CIL_Assig(ret, body));
            method.Add_Instruction(new CIL_Goto(begin_while));
            method.Add_Instruction(new CIL_Label(end_while));
            return(ret);
        }
 public bool Visit(While_loop node)
 {
     return(this.Visit(node.exp1) && this.Visit(node.exp2));
 }
Exemplo n.º 4
0
 public bool Visit(While_loop node)
 {
     throw new System.NotImplementedException();
 }