Esempio n. 1
0
 public void put(string key, Valor valor)
 {
     /*for (EnvValues e = this; e != null; e = e.previo)
     {
         if (e.tablaValores.ContainsKey(key))
         {
             e.tablaValores[key] = valor;
             return;
         }
     }*/
     if (tablaValores.ContainsKey(key))
         throw new Exception("Ya existe la variable \"" + key + "\". EnvV.");
     tablaValores.Add(key, valor);
 }
Esempio n. 2
0
 public StructVariableDeclaration(string strid,string strvarname, Tipo tipostr, Valor valRegistro)
 {
     strId = strid;
     strVarId = strvarname;
     tipo = tipostr;
     valorRegistro = valRegistro;
 }
Esempio n. 3
0
        public void set(string key, Valor valor)
        {
            for (EnvValues e = this; e != null; e = e.previo)
            {
                if (e.tablaValores.ContainsKey(key))
                {
                    e.tablaValores.Remove(key);
                    e.tablaValores.Add(key, valor);
                    return;
                }
            }

            throw new Exception("No existe variable " + key + ". EnvV.");
        }
Esempio n. 4
0
        public override void setElem2(Valor valor)
        {
            Valor v = this.entornoStr.get(this.lexeme);

            if (v is ValorRegistro)
            {
                Valor v2 = ((ValorRegistro)v).valor.get(member.lexeme);

                if (v2 is ValorRegistro)
                {
                    member.entornoStr = ((ValorRegistro)v).valor;
                    member.setElem2(valor);
                }
                else
                    ((ValorRegistro)v).valor.set(member.lexeme, valor);
            }
            else
            {
                /*Valor v2 = ((ValorEnumeracion)v).valor.get(member.lexeme);

                ((ValorEnumeracion)v).valor.set(member.lexeme, valor);*/
            }
        }
Esempio n. 5
0
 public abstract void setElem2(Valor valor);
Esempio n. 6
0
 public override void setElem2(Valor valor)
 {
     throw ErrorMessage("No es necesarion. Llamada Funcion.");
 }
Esempio n. 7
0
        public override void setElem(Valor valor)
        {
            //initEnvValores();
            Valor v = Parser.pilaValores.Peek().get(this.lexeme);

            if (v is ValorRegistro)
            {
                Valor v2 = ((ValorRegistro)v).valor.get(member.lexeme);

                if (v2 is ValorRegistro)
                {
                    member.entornoStr = ((ValorRegistro)v).valor;
                    member.setElem2(valor);
                }
                else
                    ((ValorRegistro)v).valor.set(member.lexeme, valor);
            }
            else
            {
                /*Valor v2 = ((ValorEnumeracion)v).valor.get(member.lexeme);

                ((ValorEnumeracion)v).valor.set(member.lexeme, valor);*/
            }
        }
Esempio n. 8
0
 public override void setElem2(Valor valor)
 {
     throw ErrorMessage("No es necesario.");
 }
Esempio n. 9
0
 public override void setElem(Valor valor)
 {
     throw ErrorMessage("No se puede setear valores. LlamadaFuncion / getEntornoValores()");
 }
Esempio n. 10
0
        public override void setElem(Valor valor)
        {
            Tipo t = entornoTiposActual.get(lexeme);

            if (t.isReference)
            {
                ValorArreglo v = (ValorArreglo)Parser.pilaValores.Peek().get(t.referby);//t.referHere.get(t.referby);//1

                Valor ret = v;

                for (int x = 0; x < IndexList.Count - 1; x++)
                {
                    ValorEntero index = (ValorEntero)IndexList[x].interpretar();

                    if (index.valor < (((ValorArreglo)ret).valor).Count)
                        ret = ((ValorArreglo)ret).valor[index.valor];
                    else
                        throw ErrorMessage("Indice fuera de limites de arreglo.");
                }

                ValorEntero idx = (ValorEntero)IndexList.Last().interpretar();

                if (idx.valor < (((ValorArreglo)ret).valor).Count)
                    ((ValorArreglo)ret).valor[idx.valor] = valor;
                else
                    throw ErrorMessage("Indice fuera de limites de arreglo.");

            }
            else
            {
                //this.entornoValoresActual.set(this.lexeme, valor);

                ValorArreglo v = (ValorArreglo)Parser.pilaValores.Peek().get(this.lexeme);//1

                Valor ret = v;

                for (int x = 0; x < IndexList.Count - 1; x++)
                {
                    ValorEntero index = (ValorEntero)IndexList[x].interpretar();

                    if (index.valor < (((ValorArreglo)ret).valor).Count)
                        ret = ((ValorArreglo)ret).valor[index.valor];
                    else
                        throw ErrorMessage("Indice fuera de limites de arreglo.");
                }

                ValorEntero idx = (ValorEntero)IndexList.Last().interpretar();

                if (idx.valor < (((ValorArreglo)ret).valor).Count)
                    ((ValorArreglo)ret).valor[idx.valor] = valor;
                else
                    throw ErrorMessage("Indice fuera de limites de arreglo.");
            }
        }
Esempio n. 11
0
        public override void setElem(Valor valor)
        {
            //initEnvValores();
            Tipo t = entornoTiposActual.get(lexeme);

            if (t.isReference)
                t.referHere.set(t.referby, valor);
            else
                Parser.pilaValores.Peek().set(this.lexeme, valor);//this.entornoValoresActual.set(this.lexeme, valor);
        }
Esempio n. 12
0
        public FunctionDefinition()
        {
            entornoTiposLocal = Parser.entornoTipos;
            entornoValoresLocal = Parser.pilaValores.Peek();

            ValorRetorno = null;
            returned = false;
        }
Esempio n. 13
0
        public FunctionDefinition(string nombreFuncion, Tipo ret, Sentence cpStmnt)
        {
            idFuncion = nombreFuncion;
            Tiporetorno = ret;
            compoundStatement = cpStmnt;
            entornoTiposLocal = Parser.entornoTipos;
            entornoValoresLocal = Parser.entornoValores;

            ValorRetorno = null;
            returned = false;
        }
Esempio n. 14
0
        public EnumerationVariableDeclaration(string enumName, string enumVarName, Tipo tipoenum, Valor valEnum)
        {
            enumerationName = enumName;
            enumerationVarName = enumVarName;
            tipo = tipoenum;

            valorEnum = valEnum;
            entornoValoresActual = Parser.entornoValores;
        }