Id.java

Go to the documentation of this file.
00001 package plp.expressions2.expression;
00002 
00003 import plp.expressions1.util.Tipo;
00004 import plp.expressions2.memory.AmbienteCompilacao;
00005 import plp.expressions2.memory.AmbienteExecucao;
00006 import plp.expressions2.memory.VariavelNaoDeclaradaException;
00007 
00008 public class Id implements Expressao {
00009 
00010         private String  idName;
00011 
00012         public Id(String strName) {
00013                 idName =  strName;
00014         }
00015 
00016         public boolean equals(Object obj) {
00017                 if (obj instanceof Id) {
00018                         return ((Id) obj).idName.equals(this.idName);
00019                 }
00020                 return false;
00021         }
00022 
00023         public int hashCode() {
00024                 return idName.hashCode();
00025         }
00026 
00027         public String toString() {
00028                 return idName;
00029         }
00030 
00031         public Valor avaliar(AmbienteExecucao ambiente) throws VariavelNaoDeclaradaException {
00032                 return ambiente.get(this);
00033         }
00034 
00045         public boolean checaTipo(AmbienteCompilacao amb) throws VariavelNaoDeclaradaException {
00046                 boolean result = true;
00047                 Tipo t = amb.get(this); // se estiver no ambiente, entao esta ok.
00048                 return result;
00049         }
00050 
00059         public Tipo getTipo(AmbienteCompilacao amb) throws VariavelNaoDeclaradaException {
00060                 return amb.get(this);
00061         }
00062 
00063         public String getIdName() {
00064                 return idName;
00065         }
00066 
00067         public void setIdName(String idName) {
00068                 this.idName = idName;
00069         }
00070 
00071 }

Generated on Tue Sep 12 21:36:02 2006 for PLP by  doxygen 1.4.7