Beispiel #1
0
        public IType Visit(If_Else node)
        {
            IType type_exp1 = this.Visit(node.cond);
            IType type_exp2 = this.Visit(node.then);
            IType type_exp3 = this.Visit(node.elsse);

            if (type_exp1 == null || type_exp2 == null || type_exp3 == null)
            {
                return(null);
            }

            if (type_exp1.Name != "Bool")
            {
                Logger += "En la expresion " + node.ToString() + "-> error de tipos (La condicion no tiene tipo bool) \n";
                return(null);
            }
            return(Context.GetType(type_exp2.LCA(type_exp3).Name));
        }
Beispiel #2
0
        public string Visit(If_Else node)
        {
            var cond = Visit(node.cond);
            var then = Visit(node.then);

            var ret      = method.Add_local("ret_if", true);
            var begin_if = method.Take_var("begin_if");
            var end_if   = method.Take_var("end_if");

            method.Add_Instruction(new CIL_ConditionalJump(cond, begin_if));

            if (node.elsse != null)
            {
                var elsse = Visit(node.elsse);
                method.Add_Instruction(new CIL_Assig(ret, elsse));
                method.Add_Instruction(new CIL_Goto(end_if));
            }

            method.Add_Instruction(new CIL_Assig(ret, then));
            method.Add_Instruction(new CIL_Label(end_if));
            return(ret);
        }
 public bool Visit(If_Else node)
 {
     return(this.Visit(node.cond) && this.Visit(node.then) && this.Visit(node.elsse));
 }
Beispiel #4
0
 public bool Visit(If_Else node)
 {
     throw new System.NotImplementedException();
 }