[Nice-commit] Nice/src/bossa/syntax ConstantExp.java,1.41,1.42 GlobalVarDeclaration.java,1.16,1.17 N
Brought to you by:
bonniot
From: <ar...@us...> - 2003-06-12 21:04:46
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv10643/F:/nice/src/bossa/syntax Modified Files: ConstantExp.java GlobalVarDeclaration.java NewExp.java Pattern.java Log Message: Implemented dispatch on global constants with a reference as value. Doesn't work yet with multiple packages!!! Index: ConstantExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/ConstantExp.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** ConstantExp.java 5 Jun 2003 16:06:01 -0000 1.41 --- ConstantExp.java 12 Jun 2003 21:04:40 -0000 1.42 *************** *** 66,70 **** if(value == null) Internal.warning(this+"["+this.getClass()+" has no value"); ! return new gnu.expr.QuoteExp(value, nice.tools.code.Types.javaType(type)); } --- 66,73 ---- if(value == null) Internal.warning(this+"["+this.getClass()+" has no value"); ! ! if (value instanceof VarSymbol) ! return ((VarSymbol)value).compile(); ! return new gnu.expr.QuoteExp(value, nice.tools.code.Types.javaType(type)); } Index: GlobalVarDeclaration.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/GlobalVarDeclaration.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** GlobalVarDeclaration.java 12 Jun 2003 16:46:51 -0000 1.16 --- GlobalVarDeclaration.java 12 Jun 2003 21:04:40 -0000 1.17 *************** *** 78,81 **** --- 78,86 ---- return GlobalVarDeclaration.this.value; } + + Definition getDefinition() + { + return GlobalVarDeclaration.this; + } } Index: NewExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/NewExp.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** NewExp.java 15 Nov 2002 13:49:51 -0000 1.34 --- NewExp.java 12 Jun 2003 21:04:40 -0000 1.35 *************** *** 85,88 **** private TypeIdent ti; ! private mlsub.typing.TypeConstructor tc; } --- 85,88 ---- private TypeIdent ti; ! mlsub.typing.TypeConstructor tc; } Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** Pattern.java 12 Jun 2003 16:46:52 -0000 1.53 --- Pattern.java 12 Jun 2003 21:04:41 -0000 1.54 *************** *** 127,131 **** } ! void resolveGlobalConstants(VarScope scope) { if (name != null && tc == null & typeConstructor == null) --- 127,131 ---- } ! void resolveGlobalConstants(VarScope scope, TypeScope typeScope) { if (name != null && tc == null & typeConstructor == null) *************** *** 139,157 **** } ! if (symbol != null && symbol.constant && ! symbol.getValue() instanceof ConstantExp) ! { ! ConstantExp val = (ConstantExp)symbol.getValue(); ! if (val.tc == PrimitiveType.floatTC) ! return; ! if (val instanceof StringConstantExp) ! this.typeConstructor = new TypeIdent( new LocatedString("java.lang.String", location)); ! this.tc = val.tc; ! name = null; ! atValue = val; } } --- 139,172 ---- } ! if (symbol != null && symbol.constant ) ! { ! if (symbol.getValue() instanceof ConstantExp) ! { ! ConstantExp val = (ConstantExp)symbol.getValue(); ! if (val.tc == PrimitiveType.floatTC) ! return; ! if (val instanceof StringConstantExp) ! typeConstructor = new TypeIdent( new LocatedString("java.lang.String", location)); ! tc = val.tc; ! name = null; ! atValue = val; ! } ! else if (symbol.getValue() instanceof NewExp) ! { ! NewExp val = (NewExp)symbol.getValue(); ! ! symbol.getDefinition().resolve(); ! if (val.tc != null) ! { ! tc = val.tc; ! atValue = new ConstantExp(null, tc, symbol, ! name.toString(), location); ! name = null; ! } ! } } } *************** *** 161,165 **** { for(int i = 0; i < patterns.length; i++) { ! patterns[i].resolveGlobalConstants(vscope); patterns[i].resolveTC(tscope); } --- 176,180 ---- { for(int i = 0; i < patterns.length; i++) { ! patterns[i].resolveGlobalConstants(vscope, tscope); patterns[i].resolveTC(tscope); } *************** *** 398,401 **** --- 413,419 ---- return "@" + (atValue.longValue() >= 0 ? "+" : "") + atValue; + if (atValue.value instanceof VarSymbol) + return "@=" + atValue; + return "@" + atValue; } *************** *** 450,453 **** --- 468,475 ---- return new Pattern(ConstantExp.makeString(new LocatedString( name.substring(1,name.length()-1), Location.nowhere()))); + + if (name.charAt(0) == '=') + return new Pattern(new LocatedString(name.substring(1), + Location.nowhere()), null); } *************** *** 500,503 **** --- 522,528 ---- return Gen.stringEquals((String)atValue.value, parameter); + if (atReference()) + return Gen.referenceEqualsExp(atValue.compile(), parameter); + gnu.bytecode.Type ct = Types.javaType(tc); if (exactlyAt) *************** *** 542,544 **** --- 567,573 ---- public boolean atFalse() { return atValue != null && atValue.isFalse(); } public boolean atString() { return atValue instanceof StringConstantExp; } + public boolean atReference() + { + return atValue != null && atValue.value instanceof VarSymbol; + } } |