/*public Boolean validandoTipo(String tipo1, String tipo2, itemValor valor2) * { * //aquí también hay que verificar las dimensiones * * * //if (tipo1.Equals(tipo2) || tipo2.Equals("nulo")) * itemValor tempIt = new itemValor(); * String tipoDato1 = tempIt.getTipoApartirDeString(tipo1); * * if (tipoDato1.Equals("objeto") && valor2.isTypeObjeto()) * //validando que sean los mismos tipos * { * if (tipo1.Equals(valor2.nombreObjeto)) * { * return true; * } * else * { * return false; * } * } * else if (tipoDato1.Equals(tipo2) || tipo2.Equals("nulo")) * { * return true; * } * else * { * return false; * } * * }*/ public static Boolean validandoTipo(String tipo1, itemValor valor2) { //aquí también hay que verificar las dimensiones //if (tipo1.Equals(tipo2) || tipo2.Equals("nulo")) itemValor tempIt = new itemValor(); String tipoDato1 = tempIt.getTipoApartirDeString(tipo1); if (valor2.getTipo().Equals("nulo")) { return(true); } else if (tipoDato1.Equals("objeto") && valor2.isTypeObjeto()) //validando que sean los mismos tipos { if (tipo1.Equals(valor2.nombreObjeto)) { return(true); } else { return(false); } } else if (tipoDato1.Equals(valor2.getTipo()) || valor2.getTipo().Equals("nulo")) { return(true); } else { return(false); } }
public Boolean compararParametros(lstValores lsParametros) { Boolean retorno = false; if (lstParametros.Count == lsParametros.listaValores.Count) { retorno = true; for (int i = 0; i < lstParametros.Count; i++) { llaveParametro lst1 = getListaLlaves()[i]; itemValor lst2 = lsParametros.getItemValor(i); //El priemro es para comprobar los tipos //el segundo es para comparar objetos if (lst1.tipo.Equals(lst2.getTipo()) || lst1.tipo.Equals(lst2.nombreObjeto)) { if (lst1.dimension != lst2.dimensiones.Count) { return(false); } } else { return(false); } } return(retorno); } else { return(false); } }
public static Boolean sePuedeParsear(String tipo1, itemValor valor2) { Object objetoParseado = valor2.getValorParseado(tipo1); if (objetoParseado != null) { return(true); } else { return(false); } }
/* |------------------------------------------------------------------------------------------------------------------- | Comparando los parametros con una lista de valores de entrada |------------------------------------------------------------------------------------------------------------------- | */ public Boolean compararParametrosLstValores(lstValores lst2Parametros) { if (lstParametros.Count == lst2Parametros.listaValores.Count) { int i = 0; foreach (var dic in lstParametros) { //tiene que ser del mismo tipo y dimension itemValor parametro2 = lst2Parametros.getItemValor(i); Console.WriteLine("------------------------"); Console.WriteLine("dic.key.dimension-> " + dic.Key.dimension); Console.WriteLine("parametro2.dimensiones->" + parametro2.dimensiones.Count); /* if (parametro2.isTypeObjeto()&&) * { * * }*/ //if ((dic.Key.dimension == parametro2.dimensiones.Count) && (dic.Value.tipo.valLower.Equals(parametro2.getTipo()))) if ((dic.Key.dimension == parametro2.dimensiones.Count) && itemEntorno.validandoTipo(dic.Value.tipo.valLower, parametro2)) { } else { return(false); } i++; } } else { return(false); } return(true); }
/* * public itemEntorno(tablaSimbolos tabla) * { * this.tipo = new token("nulo"); * this.nombre = new token("--"); * this.valor = new itemValor(); * valor.setTypeNulo(); * this.visibilidad = new token("privado"); * this.dimension = 0; * this.tabla = tabla; * }*/ public itemEntorno(token nombre, token tipo, itemValor valor, token visibilidad, List <int> dimension, tablaSimbolos tabla) { //validando si lo que estoy esperando es un arreglo if (dimension.Count > 0) { if (dimension.Count == valor.dimensiones.Count) { this.tipo = tipo; this.nombre = nombre; //aqui tengo qee validar los objetos this.valor = valor; itemValor tempIt = new itemValor(); String tipoDato1 = tempIt.getTipoApartirDeString(tipo.valLower); if (tipoDato1.Equals("objeto") != valor.isTypeNulo()) { this.valor.setTypeObjeto(tipo.valLower); } this.visibilidad = visibilidad; this.dimension = valor.dimensiones; //asi ya tiene dimensiones definidas } else { tabla.tablaErrores.insertErrorSemantic("Se esta recibiendo :" + valor.dimensiones.Count + " en la matriz : " + nombre.val + " de dimension:" + dimension.Count, nombre); } } else { this.tabla = tabla; if (valor.dimensiones.Count != 0) { tabla.tablaErrores.insertErrorSemantic("Se está intentando guardar en la variable :" + nombre.val + " de tipo " + tipo.valLower + ", una matriz de dimension : " + valor.dimensiones.Count, nombre); } else if (sePuedeParsear(tipo.valLower, valor)) { this.tipo = tipo; this.nombre = nombre; //guardar el valor parseado. this.valor = valor; this.valor.valor = valor.getValorParseado(tipo.valLower); itemValor tempIt = new itemValor(); String tipoDato1 = tempIt.getTipoApartirDeString(tipo.valLower); if (tipoDato1.Equals("objeto") != valor.isTypeNulo()) { this.valor.setTypeObjeto(tipo.valLower); } this.visibilidad = visibilidad; this.dimension = dimension; } else if (validandoTipo(tipo.valLower, valor)) { this.tipo = tipo; this.nombre = nombre; //aqui tengo qee validar los objetos this.valor = valor; itemValor tempIt = new itemValor(); String tipoDato1 = tempIt.getTipoApartirDeString(tipo.valLower); if (tipoDato1.Equals("objeto") != valor.isTypeNulo()) { this.valor.setTypeObjeto(tipo.valLower); } this.visibilidad = visibilidad; this.dimension = dimension; } else { tabla.tablaErrores.insertErrorSemantic("Se está intentando guardar en :" + nombre.val + " de tipo " + tipo.valLower + ", un valor de tipo " + valor.getTipo(), nombre); //error semantico, se está intentando asiganar un valor diferente al declarado por la variable } } }
public itemValorPregunta() { respuesta = new itemValor(); }
/* |-------------------------------------------------------------------------- | Set TIPOS |-------------------------------------------------------------------------- | 0= normal | 1 = return; | 2 = break | 3 = continue | 4 = errores */ public void setValueRetorno(itemValor item) { tipoRetorno = 1; this.valor = item; }