Exemple #1
0
        public void save(string id, object valor, DataType type, bool esconstante, bool isAssigned, string tipo_dato)
        {
            Ambit amb = this;

            if (!amb.Ambit_name_inmediato.Equals("Function"))
            {
                if (!amb.variables.ContainsKey(id.ToLower()))
                {
                    amb.variables[id.ToLower()] = (new Identifier(valor, id, type, esconstante, isAssigned, false, tipo_dato));
                }
            }
            else
            {
                saveVarFunction(id, valor, type, esconstante, isAssigned);
            }


            /*Ambit amb = this;
             *
             * while (amb != null)
             * {
             *  if (amb.variables.ContainsKey(id.ToLower()))
             *  {
             *      amb.variables[id.ToLower()] = (new Identifier(valor, id, type, esconstante, isAssigned));
             *      return;
             *  }
             *
             *  amb = amb.anterior;
             * }
             * variables.Add(id, new Identifier(valor, id, type, esconstante, isAssigned));*/
        }
Exemple #2
0
        public void saveVarFunction(string id, object valor, DataType type, bool esconstante, bool isAssigned)
        {
            Ambit amb = this;

            if (!amb.variables.ContainsKey(id.ToLower()))
            {
                amb.variables[id.ToLower()] = (new Identifier(valor, id, type, esconstante, isAssigned, true, "Variable"));
            }
        }
Exemple #3
0
        public void saveArrayMultiple(string id, ArraysMultiple arrays)
        {
            Ambit amb = this;

            if (!amb.Arraysmulti.ContainsKey(id.ToLower()))
            {
                amb.Arraysmulti[id.ToLower()] = arrays;
            }
        }
Exemple #4
0
        public void saveType(string id, Types types)
        {
            Ambit amb = this;

            if (!amb.Types.ContainsKey(id.ToLower()))
            {
                amb.Types[id.ToLower()] = types;
            }
        }
Exemple #5
0
        public void setVariableFuncion(string id, object valor, DataType type, bool isAssigned, string tipo_dato)
        {
            Ambit env = this;

            if (env.Variables.ContainsKey(id.ToLower()))
            {
                env.Variables[id.ToLower()] = new Identifier(valor, id, type, false, isAssigned, true, tipo_dato);
            }
        }
Exemple #6
0
        public void saveArray(string id, Arrays arrays)
        {
            Ambit amb = this;

            if (!amb.Arrays.ContainsKey(id.ToLower()))
            {
                amb.Arrays[id.ToLower()] = arrays;
            }
        }
Exemple #7
0
        public Ambit getGeneral()
        {
            Ambit amb = this;

            while (amb.anterior != null)
            {
                amb = amb.anterior;
            }
            return(amb);
        }
Exemple #8
0
 public Ambit(Ambit a, string n, string ni, bool isnull)
 {
     this.variables            = new Dictionary <string, Identifier>();
     this.functions            = new Dictionary <string, Function>();
     this.arrays               = new Dictionary <string, Arrays>();
     this.arraysmulti          = new Dictionary <string, ArraysMultiple>();
     this.ambit_name           = n;
     this.ambit_name_inmediato = ni;
     this.anterior             = a;
     this.ambit_null           = isnull;
 }
Exemple #9
0
        public Identifier getVariableFunctionInAmbit(string id)
        {
            Identifier identifier = new Identifier();
            Ambit      amb        = this;

            if (amb.Variables.ContainsKey(id.ToLower()))
            {
                identifier = amb.Variables[id.ToLower()];
            }
            return(identifier);
        }
Exemple #10
0
        public void setVariableInAmbit(string id, object valor, DataType type, bool isAssigned, string tipo_dato)
        {
            Ambit env = this;

            while (env != null)
            {
                if (env.Variables.ContainsKey(id.ToLower()))
                {
                    env.Variables[id.ToLower()] = new Identifier(valor, id, type, false, isAssigned, false, tipo_dato);
                }
                env = env.anterior;
            }
        }
Exemple #11
0
        public void setArrayMulti(string id, ArraysMultiple tipo_dato)
        {
            Ambit env = this;

            while (env != null)
            {
                if (env.Arraysmulti.ContainsKey(id.ToLower()))
                {
                    env.Arraysmulti[id.ToLower()] = tipo_dato;
                    return;
                }
                env = env.anterior;
            }
        }
Exemple #12
0
        public void setFunction(string id, Function function)
        {
            Ambit env = this;

            while (env != null)
            {
                if (env.Functions.ContainsKey(id.ToLower()))
                {
                    env.Functions[id.ToLower()] = function;
                    return;
                }
                env = env.anterior;
            }
        }
Exemple #13
0
        public Function getFuncion(string id)
        {
            Ambit amb = this;

            while (amb != null)
            {
                if (amb.Functions.ContainsKey(id.ToLower()))
                {
                    return(amb.Functions[id.ToLower()]);
                }
                amb = amb.anterior;
            }
            return(null);
        }
Exemple #14
0
        public Identifier getVariable(string id)
        {
            Identifier identifier = new Identifier();
            Ambit      amb        = this;

            while (amb != null)
            {
                if (amb.Variables.ContainsKey(id.ToLower()))
                {
                    identifier = amb.Variables[id.ToLower()];
                    break;
                }
                amb = amb.anterior;
            }
            return(identifier);
        }
Exemple #15
0
        public ArraysMultiple getArrayMulti(string id)
        {
            Ambit amb = this;

            while (amb != null)
            {
                if (amb.Arraysmulti.ContainsKey(id.ToLower()))
                {
                    return(amb.Arraysmulti[id.ToLower()]);
                }
                amb = amb.anterior;
            }


            return(null);
        }
Exemple #16
0
        public void saveFuncion(string id, Function function)
        {
            Ambit amb = this;

            if (!amb.functions.ContainsKey(id.ToLower()))
            {
                amb.functions[id.ToLower()] = function;
            }

            /*while (amb != null)
             * {
             *  if (amb.functions.ContainsKey(id.ToLower()))
             *  {
             *      amb.functions[id.ToLower()] = function;
             *      return;
             *  }
             *
             *  amb = amb.anterior;
             * }
             * functions.Add(id, function);*/
        }