예제 #1
0
        public string Visit(Attr_Def node)
        {
            var exp = "";

            if (node.exp == null)
            {
                if (node.type.s == "Int")
                {
                    exp = new Const("0").Visit(this);
                }
                else if (node.type.s == "String")
                {
                    exp = method.Add_local("expr", true);
                    method.Add_Instruction(new CIL_Load(exp, Data[""]));
                }
                else if (node.type.s == "Bool")
                {
                    exp = new Const("false").Visit(this);
                }
                else
                {
                    exp = "void";
                }
            }
            else
            {
                exp = node.exp.Visit(this);
            }
            method.Add_Instruction(new CIL_SetAttr(new CIL_MyVar("this", current_type.Name), node.name.name, exp));
            return("");
        }
 public bool Visit(Attr_Def node)
 {
     if (node == null)
     {
         return(true);
     }
     return(this.Visit(node.exp));
 }
예제 #3
0
        public IType Visit(Attr_Def node)
        {
            IType type_formal = Context.GetType(node.type.s);

            if (node.exp == null)
            {
                return(type_formal);
            }
            IType type_exp = this.Visit(node.exp);

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

            return(type_exp);
        }
예제 #4
0
 public string Visit(Attr_Def node)
 {
     throw new NotImplementedException();
 }
 public bool Visit(Attr_Def node)
 {
     return(Visit(node.name) && Visit(node.exp) && Visit(node.type));
 }
예제 #6
0
 public bool Visit(Attr_Def node)
 {
     throw new System.NotImplementedException();
 }