/* SCCS - @(#)FormalNode.java 1.2 - 02/28/99 - 12:39:12 */ /* * Copyright (c) 1997 USC Brain Project. email nsl@java.usc.edu. */ // // FormalNode //////////////////////////////////////////////////////////// /** * FormalNode - Variables with definite type */ package pp.src.jbf; import java.lang.*; public class FormalNode extends YYtoken{ public TypeNode type; public boolean lvalue; public String code0; public FormalNode(YYtoken ctype, YYtoken sym) { // well, it is kind of convenience to reuse something in YYtokentypes. super(ctype.tokentype, sym.text, ctype.lineno, ctype.charno, ctype.charno0); lvalue = true; // setLvalue(true); type = (TypeNode) ctype; code0=ctype.text+" "+sym.text; } public FormalNode(FormalNode node) { super(node.tokentype, node.text, node.lineno, node.charno, node.charno0); lvalue = true; // setLvalue(true); type = ((FormalNode)node).type; code0=node.code0; } /** a token with unknown type */ public FormalNode(YYtoken node) { super(node.tokentype, node.text, node.lineno, node.charno, node.charno0); lvalue = true; // setLvalue(true); type = null; // unknown type code0="UNKNOWNTYPE"+" "+node.text; } public void setLvalue(boolean b) { lvalue = b;} public boolean isLvalue() { return lvalue; } /** For hash table created by the system only */ public int hashCode() { if (text.length() > 1) { return (int)(text.charAt(0)+text.charAt(text.length())); } else { return (int)(text.charAt(0)); } } /** For hashtable created by the system only */ public boolean equals(YYtoken comp) { if (text.equals(comp.text)) return true; return false; } public int getDim() { if (type==null) { return 0; } else { return type.getDim(); } } }