[Nice-commit] Nice/src/bossa/syntax break.nice,1.3,1.4 constant.nice,1.10,1.11 formalParameters.nice
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2005-01-17 13:17:09
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16708/F:/nice/src/bossa/syntax Modified Files: break.nice constant.nice formalParameters.nice overloadedsymbol.nice pattern.nice symbolexp.nice Log Message: Conversion cleanup part 5. Index: break.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/break.nice,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** break.nice 13 Aug 2004 21:04:41 -0000 1.3 --- break.nice 17 Jan 2005 13:16:57 -0000 1.4 *************** *** 38,42 **** toString() = "continue " + (label != null ? notNull(label).toString() : "") + ";"; - } --- 38,41 ---- *************** *** 49,66 **** } - public Statement createContinueStmt(LocatedString label) - { - return new ContinueStmt(label: label); - } - /** A statement anotated by a label (used by break and continue). - */ public class LabeledStmt extends Statement { private final LocatedString label; private final Statement statement; ! private final ?LoopStmt loop = null; public String name() = label.toString(); --- 48,62 ---- } /** A statement anotated by a label (used by break and continue). + */ public class LabeledStmt extends Statement { private final LocatedString label; private final Statement statement; ! private final ?LoopStmt loop; ! ! ?gnu.expr.BlockExp block = null; public String name() = label.toString(); *************** *** 69,87 **** /** @return the loop targeted by this label, or null. */ ! ?LoopStmt getLoop() ! { ! if (loop != null) ! return loop; ! if (statement instanceof LoopStmt) ! return cast(statement); ! return null; ! } ! ! /**************************************************************** ! * Code generation ! ****************************************************************/ ! ! ?gnu.expr.BlockExp block = null; ! generateCode() { --- 65,70 ---- /** @return the loop targeted by this label, or null. */ ! ?LoopStmt getLoop() = loop; ! generateCode() { *************** *** 94,100 **** toString() = this.name() + ":\n" + statement; } - - public new LabeledStmt(LocatedString label, Statement statement, LoopStmt loop) - { - this(label:label, statement:statement, loop: loop, block: null); - } --- 77,78 ---- Index: formalParameters.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/formalParameters.nice,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** formalParameters.nice 16 Jan 2005 00:28:21 -0000 1.7 --- formalParameters.nice 17 Jan 2005 13:16:57 -0000 1.8 *************** *** 21,38 **** public class FormalParameters extends Node { ! private Parameter[] parameters; ! int size; void addThis(Monotype type) { ! if (parameters[0] != null) ! Internal.error("No room for \"this\""); ! ! parameters[0] = new NamedParameter(type: type, name: thisName); } boolean hasThis() { ! return parameters.length > 0 && parameters[0].match("this"); } --- 21,36 ---- public class FormalParameters extends Node { ! private List<Parameter> parameters; ! ! int size() = parameters.size(); void addThis(Monotype type) { ! parameters.add(0, new NamedParameter(type: type, name: thisName)); } boolean hasThis() { ! return parameters.size() > 0 && parameters[0].match("this"); } *************** *** 53,104 **** boolean hasDefaultValue() ! { ! for (int i = size; --i>=0; ) ! if (parameters[i].value() != null) ! return true; ! ! return false; } boolean containsAlike() { ! for (int i = size; --i>=0; ) ! if (parameters[i] != null && parameters[i].type.containsAlike()) ! return true; ! ! return false; } void substitute(Map<java.lang.String, Monotype> map) { ! for (int i = size; --i>=0; ) ! if (parameters[i] != null) // it is the case for "this" placeholder ! parameters[i].type = parameters[i].type.substitute(map); } Monotype[?] types() { ! if (parameters.length == 0) return null; ! ! Monotype[] res = cast(new Monotype[size]); ! for (int i = 0; i < size; i++) ! res[i] = parameters[i].type; ! ! return res; } public MonoSymbol[] getMonoSymbols() { ! MonoSymbol[] res = cast(new MonoSymbol[size]); ! for (int i = 0; i < size; i++) ! res[i] = parameters[i].getSymbol(); ! ! return res; } void typecheck(mlsub.typing.Monotype[] domain) { ! for (int i = 0; i<size; i++) parameters[i].typecheck(domain[i]); } --- 51,85 ---- boolean hasDefaultValue() ! { //why different condition than in previous method??? ! return parameters.any(Parameter param => param.value != null); } boolean containsAlike() { ! return parameters.any(Parameter param => param.type.containsAlike()); } void substitute(Map<java.lang.String, Monotype> map) { ! for (param : parameters) ! param.substitute(map); } Monotype[?] types() { ! if (parameters.isEmpty()) return null; ! ! return parameters.mapToArray(Parameter param => param.type); } public MonoSymbol[] getMonoSymbols() { ! return parameters.mapToArray(Parameter param => param.getSymbol()); } void typecheck(mlsub.typing.Monotype[] domain) { ! for (int i = 0; i<this.size(); i++) parameters[i].typecheck(domain[i]); } *************** *** 106,115 **** resolve() { ! for (int i = 0; i<size; i++) ! parameters[i].resolve(scope, typeScope); ! for (int i = 0; i<size; i++) ! if (parameters[i].symbol != null) ! notNull(parameters[i].symbol).state = ACCESSIBLE; } --- 87,96 ---- resolve() { ! for (param : parameters) ! param.resolve(scope, typeScope); ! for (param : parameters) ! if (param.symbol != null) ! notNull(param.symbol).state = ACCESSIBLE; } *************** *** 119,124 **** void resolveCalledFromAnalyse(Info info) { ! for (int i = 0; i<size; i++) ! parameters[i].resolve(info); } --- 100,105 ---- void resolveCalledFromAnalyse(Info info) { ! for (param : parameters) ! param.resolve(info); } *************** *** 133,137 **** boolean match(Arguments args, VarSymbol symbol) { ! int[] map = new int[size]; // first pass, fill holes with names given at the call site --- 114,118 ---- boolean match(Arguments args, VarSymbol symbol) { ! int[] map = new int[this.size()]; // first pass, fill holes with names given at the call site *************** *** 155,160 **** // check that each parameter is either supplied or optional // stores the invocation expressions ! ?Expression[] exps = new Expression[size]; ! for (int i = 0; i < size; i++) if (map[i] == 0) { --- 136,141 ---- // check that each parameter is either supplied or optional // stores the invocation expressions ! ?Expression[] exps = new Expression[this.size()]; ! for (int i = 0; i < this.size(); i++) if (map[i] == 0) { *************** *** 199,231 **** public boolean hasMatchFor(String s) { ! for (int i = 0; i<size; i++) ! if (parameters[i].match(s)) ! return true; ! ! return false; } toString() = Util.map("", ", ", "", parameters); ! public List<Parameter> asList() ! { ! if (parameters.length != 0) ! return Arrays.asList(parameters); ! ! return new ArrayList(); ! } public List<Parameter> getRequiredParameters() { ! LinkedList<Parameter> res = new LinkedList(); ! for(int i = 0; i < size; i++) ! { ! Parameter param = parameters[i]; ! if (!(param instanceof OptionalParameter)) ! { ! res.add(parameters[i]); ! } ! } ! return res; } --- 180,194 ---- public boolean hasMatchFor(String s) { ! return parameters.any(Parameter param => param.match(s)); } toString() = Util.map("", ", ", "", parameters); ! public List<Parameter> asList() = new ArrayList(parameters); public List<Parameter> getRequiredParameters() { ! return parameters.filter(Parameter param => ! !(param instanceof OptionalParameter)); } *************** *** 234,238 **** java.util.Stack<gnu.bytecode.Variable>[?] res = null; ! for(int i = 0; i < size; i++) { Parameter param = parameters[i]; --- 197,201 ---- java.util.Stack<gnu.bytecode.Variable>[?] res = null; ! for(int i = 0; i < this.size(); i++) { Parameter param = parameters[i]; *************** *** 240,244 **** { if (res == null) ! res = cast(new java.util.Stack[parameters.length]); notNull(res)[i] = notNull(notNull(param.symbol).copies); } --- 203,207 ---- { if (res == null) ! res = cast(new java.util.Stack[this.size()]); notNull(res)[i] = notNull(notNull(param.symbol).copies); } *************** *** 250,261 **** List<Parameter> getParameters(TypeScope scope) { ! ArrayList<Parameter> res = new ArrayList(size); ! for (int i = 0; i < size; i++) { ! Parameter p = parameters[i].cloneParam(); p.type = new MonotypeWrapper(type: p.type.resolve(scope)); ! res.add(p); ! } ! return res; } --- 213,222 ---- List<Parameter> getParameters(TypeScope scope) { ! return parameters.map(Parameter param => { ! let p = param.cloneParam(); p.type = new MonotypeWrapper(type: p.type.resolve(scope)); ! return p; ! }); } *************** *** 266,276 **** } ! public FormalParameters createFormalParameters(?List<Parameter> parameters) { ! if (parameters == null) ! return new FormalParameters(Node.none, parameters: [], size: 0); ! ! return new FormalParameters(Node.none, parameters: parameters.toArray(), ! size: parameters.size()); } --- 227,233 ---- } ! public FormalParameters createFormalParameters(List<Parameter> parameters) { ! return new FormalParameters(Node.none, parameters: parameters); } *************** *** 317,320 **** --- 274,282 ---- boolean isOverriden() = false; + void substitute(Map<java.lang.String, Monotype> map) + { + type = type.substitute(map); + } + void resolve(?VarScope scope, ?TypeScope typeScope) { Index: constant.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/constant.nice,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** constant.nice 16 Jan 2005 00:28:21 -0000 1.10 --- constant.nice 17 Jan 2005 13:16:57 -0000 1.11 *************** *** 345,350 **** public class StringConstantExp extends ConstantExp { - final String escapedValue; - compile() { --- 345,348 ---- *************** *** 363,367 **** value = escapeEOL(value); ! let res = new StringConstantExp(value: unescapeLiteral(value), escapedValue: value, representation: "\""+value+"\"" , className: stringClassName); return res; } --- 361,365 ---- value = escapeEOL(value); ! let res = new StringConstantExp(value: unescapeLiteral(value), representation: "\""+value+"\"" , className: stringClassName); return res; } Index: pattern.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/pattern.nice,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pattern.nice 16 Jan 2005 00:28:21 -0000 1.18 --- pattern.nice 17 Jan 2005 13:16:57 -0000 1.19 *************** *** 777,781 **** } bytecodeRepresentation(BoolPattern p) = p.atValue.isTrue() ? "@true" : "@false"; ! bytecodeRepresentation(StringPattern p) = "@\"" + p.atValue.escapedValue + "\""; bytecodeRepresentation(CharPattern p) = "@\'" + p.atValue.value + "\'"; bytecodeRepresentation(IntPattern p) = "@" + (p.atValue.longValue() >= 0 ? "+" : "") + p.atValue; --- 777,781 ---- } bytecodeRepresentation(BoolPattern p) = p.atValue.isTrue() ? "@true" : "@false"; ! bytecodeRepresentation(StringPattern p) = "@" + p.atValue.representation; bytecodeRepresentation(CharPattern p) = "@\'" + p.atValue.value + "\'"; bytecodeRepresentation(IntPattern p) = "@" + (p.atValue.longValue() >= 0 ? "+" : "") + p.atValue; Index: symbolexp.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/symbolexp.nice,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** symbolexp.nice 14 Jan 2005 22:47:11 -0000 1.4 --- symbolexp.nice 17 Jan 2005 13:16:57 -0000 1.5 *************** *** 86,90 **** } ! Expression createSymbolExp(VarSymbol symbol, Location loc) { let res = new SymbolExp(symbol: symbol); --- 86,90 ---- } ! SymbolExp createSymbolExp(VarSymbol symbol, Location loc) { let res = new SymbolExp(symbol: symbol); Index: overloadedsymbol.nice =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/overloadedsymbol.nice,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** overloadedsymbol.nice 16 Jan 2005 21:51:15 -0000 1.14 --- overloadedsymbol.nice 17 Jan 2005 13:16:57 -0000 1.15 *************** *** 40,44 **** private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { ! SymbolExp res = cast(createSymbolExp(sym, this.location())); res.type = t; return res; --- 40,44 ---- private Expression uniqueExpression(VarSymbol sym, mlsub.typing.Polytype t) { ! SymbolExp res = createSymbolExp(sym, this.location()); res.type = t; return res; *************** *** 464,468 **** int len = symbols.size(); ! VarSymbol[] syms = new VarSymbol[len].fillWith(symbols); boolean[] remove = new boolean[len]; --- 464,468 ---- int len = symbols.size(); ! List<VarSymbol> syms = new ArrayList(symbols); boolean[] remove = new boolean[len]; *************** *** 531,535 **** int len = symbols.size(); ! VarSymbol[] syms = new VarSymbol[len].fillWith(symbols); boolean[] remove = new boolean[len]; --- 531,535 ---- int len = symbols.size(); ! List<VarSymbol> syms = new ArrayList(symbols); boolean[] remove = new boolean[len]; *************** *** 617,624 **** int len = symbols.size(); ! VarSymbol[] syms = cast(symbols.toArray(new VarSymbol[len])); ! for (int i = 0; i < syms.length; i++) ! for (int j = i+1; j < syms.length; j++) if (overlappingJavaMethods(syms[i].getMethodDeclaration(), syms[j].getMethodDeclaration())) --- 617,624 ---- int len = symbols.size(); ! List<VarSymbol> syms = new ArrayList(symbols); ! for (int i = 0; i < len; i++) ! for (int j = i+1; j < len; j++) if (overlappingJavaMethods(syms[i].getMethodDeclaration(), syms[j].getMethodDeclaration())) |