Esempio n. 1
0
        public string Visit(AST_ExpCall node)
        {
            var s = methodcontext.GenLocal("exp", true);

            var e0 = node.expr.Visit(this);

            methodcontext.Staments.Add(new CIL_ExceptionCond(e0, "0", "error_null"));

            var typ = "";

            List <string> parm = new List <string>();

            parm.Add(e0);
            foreach (var item in node.arg.stament_list)
            {
                parm.Add(item.Visit(this));
            }

            if (node.explicittype != null)
            {
                typ = node.explicittype.Type;
                methodcontext.Staments.Add(new CIL_FunctionCall(node.id.Id, new CIL_Params(parm), typ, s, false, typ));
            }
            else
            {
                typ = methodcontext.GenLocal("get_typ", true);
                methodcontext.Staments.Add(new CIL_TypeOf(e0, typ));
                methodcontext.Staments.Add(new CIL_FunctionCall(node.id.Id, new CIL_Params(parm), typ, s, true, (node.expr.MyType == null) ? "NULL" : node.expr.MyType.Name));
            }

            return(s);
        }
Esempio n. 2
0
        public bool Visit(AST_ExpCall node)
        {
            bool solve = true;

            if (node.expr != null)
            {
                solve &= node.expr.Visit(this);
            }
            if (node.explicittype != null)
            {
                solve &= node.explicittype.Visit(this);
            }
            solve &= node.arg.Visit(this);

            return(solve);
        }
 public bool Visit(AST_ExpCall node)
 {
     if (!node.expr.Visit(this))
     {
         return(false);
     }
     if (node.explicittype != null)
     {
         if (!All_Types.ContainsKey(node.explicittype.Type))
         {
             CurrErrorLoger.LogError(node.explicittype.row, node.explicittype.col, $"El tipo {node.explicittype.Type} no existe");
             return(false);
         }
     }
     return(node.arg.Visit(this));
 }
Esempio n. 4
0
        public bool Visit(AST_ExpCall node)
        {
            bool solve      = true;
            bool visit_left = node.expr.Visit(this);

            if (node.explicittype == null)
            {
                if (node.expr.MyType == null)
                {
                    return(false);
                }

                var my_type = node.expr.MyType;

                if (!my_type.HasMethod(node.id.Id))
                {
                    CurrErrorLoger.LogError(node.row, node.col, "El tipo " + my_type.Name + " no posee el metodo " + node.id.Id);
                    return(false);
                }
                var my_method = my_type.GetMethod(node.id.Id);

                var invok_params = node.arg.stament_list;

                if (my_method.AttrParams.Count != invok_params.Count)
                {
                    CurrErrorLoger.LogError(node.row, node.col, "La cantidad de parametros no coinciden");
                    return(false);
                }

                for (int i = 0; i < my_method.AttrParams.Count; i++)
                {
                    if (!invok_params[i].Visit(this))
                    {
                        return(false);
                    }
                    if (SemanticType.LCA(my_method.AttrParams[i].Type, invok_params[i].MyType).Name != my_method.AttrParams[i].Type.Name)
                    //if (my_method.AttrParams[i].Type.Name != invok_params[i].MyType.Name)
                    {
                        CurrErrorLoger.LogError(node.row, node.col, "No coinciden los tipos de los parametros");
                        return(false);
                    }
                }
                node.MyType = my_method.ReturnType;
                return(true);
            }
            else
            {
                string cast_type_in_str = node.explicittype.Type;

                if (!All_Types.ContainsKey(cast_type_in_str))
                {
                    CurrErrorLoger.LogError(node.row, node.col, "El tipo al que se esta casteando no esta definido");
                    return(false);
                }
                var cast_type = All_Types[cast_type_in_str];

                var my_type = node.expr.MyType;

                if (!cast_type.HasMethod(node.id.Id))
                {
                    CurrErrorLoger.LogError(node.row, node.col, "El tipo de casteo no posee ese metodo");
                    return(false);
                }
                var my_method = cast_type.GetMethod(node.id.Id);

                var invok_params = node.arg.stament_list;

                if (my_method.AttrParams.Count != invok_params.Count)
                {
                    CurrErrorLoger.LogError(node.row, node.col, "La cantidad de parametros no coinciden");
                    return(false);
                }

                for (int i = 0; i < my_method.AttrParams.Count; i++)
                {
                    if (!invok_params[i].Visit(this))
                    {
                        return(false);
                    }
                    if (SemanticType.LCA(my_method.AttrParams[i].Type, invok_params[i].MyType).Name != my_method.AttrParams[i].Type.Name)
                    //if (my_method.AttrParams[i].Type.Name != invok_params[i].MyType.Name)
                    {
                        CurrErrorLoger.LogError(node.row, node.col, "No coinciden los tipos de los parametros");
                        return(false);
                    }
                }

                var lca = SemanticType.LCA(my_type, cast_type);

                node.MyType = my_method.ReturnType;

                if (lca.Name == cast_type.Name)
                {
                    return(true);
                }
                else
                {
                    CurrErrorLoger.LogError(node.row, node.col, "El tipo " + my_type.Name + "no se conforma" + cast_type.Name);
                    return(false);
                }
            }
        }
Esempio n. 5
0
 public bool Visit(AST_ExpCall node)
 {
     throw new NotImplementedException();
 }
Esempio n. 6
0
 public Base_Object_Value Visit(AST_ExpCall node)
 {
     throw new NotImplementedException();
 }