Changeset 3422
- Timestamp:
- Feb 22, 2008, 8:06:21 PM (13 years ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.plus.rfpdt/src/org/refal/plus/rfpdt/core/builder/RefalASGenerator.java
r3403 r3422 100 100 items.toRight(makeName(modName + "." + astConstBinding.name.identifier)); 101 101 astConstBinding.exp.accept(this, items); 102 e.toRight((Comparable< Expr>) items.yield());102 e.toRight((Comparable<?>) items.yield()); 103 103 } 104 104 … … 118 118 Expr.Concatenator inFormat = Expr.getConcatenator(); 119 119 astFuncDecl.inFormat.accept(this, inFormat); 120 items.toRight((Comparable< Expr>) inFormat.yield());120 items.toRight((Comparable<?>) inFormat.yield()); 121 121 Expr.Concatenator outFormat = Expr.getConcatenator(); 122 122 astFuncDecl.outFormat.accept(this, outFormat); 123 items.toRight((Comparable< Expr>) outFormat.yield());123 items.toRight((Comparable<?>) outFormat.yield()); 124 124 if (astFuncDecl.funcDef instanceof AstNative) 125 125 items.toRight(((AstNative) astFuncDecl.funcDef).right.identifier); … … 128 128 body.toRight(BRANCH); 129 129 ((AstFuncDef) astFuncDecl.funcDef).body.accept(this, body); 130 items.toRight((Comparable< Expr>) body.yield());130 items.toRight((Comparable<?>) body.yield()); 131 131 } 132 e.toRight((Comparable< Expr>) items.yield());132 e.toRight((Comparable<?>) items.yield()); 133 133 } 134 134 … … 160 160 Expr.Concatenator inFormat = Expr.getConcatenator(); 161 161 astFuncDecl.inFormat.accept(this, inFormat); 162 items.toRight((Comparable< Expr>) inFormat.yield());162 items.toRight((Comparable<?>) inFormat.yield()); 163 163 Expr.Concatenator outFormat = Expr.getConcatenator(); 164 164 astFuncDecl.outFormat.accept(this, outFormat); 165 items.toRight((Comparable< Expr>) outFormat.yield());165 items.toRight((Comparable<?>) outFormat.yield()); 166 166 items.toRight(astNative.left.identifier); 167 e.toRight((Comparable< Expr>) items.yield());167 e.toRight((Comparable<?>) items.yield()); 168 168 } 169 169 … … 179 179 String modName = astObjDecl.module != null ? astObjDecl.module : moduleName; 180 180 items.toRight(makeName(modName + "." + astObjDecl.name.identifier)); 181 e.toRight((Comparable< Expr>) items.yield());181 e.toRight((Comparable<?>) items.yield()); 182 182 } 183 183 … … 198 198 sentence.toRight(BRANCH); 199 199 astSentence.accept(this, sentence); 200 items.toRight((Comparable< Expr>) sentence.yield());200 items.toRight((Comparable<?>) sentence.yield()); 201 201 } 202 e.toRight((Comparable< Expr>) items.yield());202 e.toRight((Comparable<?>) items.yield()); 203 203 } 204 204 205 205 public void visit (AstCut astCut, Expr.Concatenator e) { 206 e.toRight((Comparable< Expr>) new Expr(CUT));206 e.toRight((Comparable<?>) new Expr(CUT)); 207 207 } 208 208 209 209 public void visit (AstCutAll astCutAll, Expr.Concatenator e) { 210 e.toRight((Comparable< Expr>) new Expr(CUTALL));210 e.toRight((Comparable<?>) new Expr(CUTALL)); 211 211 } 212 212 … … 215 215 error.toRight(ERROR); 216 216 astError.sentence.accept(this, error); 217 e.toRight((Comparable< Expr>) error.yield());217 e.toRight((Comparable<?>) error.yield()); 218 218 } 219 219 220 220 public void visit (AstFail astFail, Expr.Concatenator e) { 221 e.toRight((Comparable< Expr>) new Expr(FAIL));221 e.toRight((Comparable<?>) new Expr(FAIL)); 222 222 } 223 223 224 224 public void visit (AstFence astFence, Expr.Concatenator e) { 225 e.toRight((Comparable< Expr>) new Expr(FENCE));225 e.toRight((Comparable<?>) new Expr(FENCE)); 226 226 } 227 227 … … 230 230 format.toRight(FORMAT); 231 231 astFormat.exp.accept(this, format); 232 e.toRight((Comparable< Expr>) format.yield());232 e.toRight((Comparable<?>) format.yield()); 233 233 } 234 234 … … 239 239 source.toRight(BRANCH); 240 240 astIter.sentence.accept(this, source); 241 iter.toRight((Comparable< Expr>) source.yield());241 iter.toRight((Comparable<?>) source.yield()); 242 242 Expr.Concatenator format = Expr.getConcatenator(); 243 243 format.toRight(FORMAT); 244 244 astIter.target.accept(this, format); 245 iter.toRight((Comparable< Expr>) format.yield());246 e.toRight((Comparable< Expr>) iter.yield());245 iter.toRight((Comparable<?>) format.yield()); 246 e.toRight((Comparable<?>) iter.yield()); 247 247 } 248 248 … … 251 251 source.toRight(BRANCH); 252 252 astNot.sentence.accept(this, source); 253 e.toRight((Comparable< Expr>) Expr.concat(NOT, (Comparable<Expr>) source.yield()));253 e.toRight((Comparable<?>) Expr.concat(NOT, (Comparable<?>) source.yield())); 254 254 } 255 255 … … 258 258 items.toRight(astPattern.dir.select(LEFT, RIGHT)); 259 259 astPattern.exp.accept(this, items); 260 e.toRight((Comparable< Expr>) items.yield());260 e.toRight((Comparable<?>) items.yield()); 261 261 } 262 262 … … 265 265 items.toRight(RESULT); 266 266 astResult.exp.accept(this, items); 267 e.toRight((Comparable< Expr>) items.yield());267 e.toRight((Comparable<?>) items.yield()); 268 268 } 269 269 … … 279 279 trap.toRight(BRANCH); 280 280 astTrap.trySentence.accept(this, trap); 281 items.toRight((Comparable< Expr>) trap.yield());281 items.toRight((Comparable<?>) trap.yield()); 282 282 Expr.Concatenator with = Expr.getConcatenator(); 283 283 with.toRight(BRANCH); 284 284 astTrap.catchSentence.accept(this, with); 285 items.toRight((Comparable< Expr>) with.yield());286 e.toRight((Comparable< Expr>) items.yield());285 items.toRight((Comparable<?>) with.yield()); 286 e.toRight((Comparable<?>) items.yield()); 287 287 } 288 288 … … 297 297 items.toRight(makeName(modName + "." + astCall.funcDecl.name.identifier)); 298 298 astCall.arg.accept(this, items); 299 e.toRight((Comparable< Expr>) items.yield());299 e.toRight((Comparable<?>) items.yield()); 300 300 } 301 301 … … 317 317 items.toRight(PAREN); 318 318 astParen.exp.accept(this, items); 319 e.toRight((Comparable< Expr>) items.yield());319 e.toRight((Comparable<?>) items.yield()); 320 320 } 321 321 … … 327 327 modName = moduleName; 328 328 items.toRight(makeName(modName + "." + astRef.decl.name.identifier)); 329 e.toRight((Comparable< Expr>) items.yield());329 e.toRight((Comparable<?>) items.yield()); 330 330 } 331 331 332 332 public void visit (AstVar astVar, Expr.Concatenator e) { 333 333 String varType = astVar.type.name().toUpperCase() + "VAR"; // FIXME 334 Comparable< Expr> varName;334 Comparable<?> varName; 335 335 if (astVar.name != null && astVar.name.identifier.length() > 0) 336 336 varName = new Expr(astVar.name.identifier); // FIXME 337 337 else 338 338 varName = new Expr("$tmp-" + astVar.pos.charStart); // FIXME 339 e.toRight((Comparable< Expr>) Expr.concat(varType, varName));339 e.toRight((Comparable<?>) Expr.concat(varType, varName)); 340 340 } 341 341 -
to-imperative/trunk/compiler/rfp_asail_java.rf
r3413 r3422 295 295 /*empty*/ = 'Expr.empty'; 296 296 (PAREN e.expr) = 297 'new Expr ((Comparable ) '<Expr_Ref_To_Java e.expr>')';297 'new Expr ((Comparable<?>) '<Expr_Ref_To_Java e.expr>')'; 298 298 term = 299 299 <Term_Ref_To_Java term> :: (e.term), … … 309 309 Term_Ref_To_Java term = term : { 310 310 (PAREN e.expr) = 311 ('(Comparable ) '<Expr_Ref_To_Java e.expr>);311 ('(Comparable<?>) '<Expr_Ref_To_Java e.expr>); 312 312 (DEREF e.expr (e.pos)) = 313 313 ('(Expr) '<Expr_Ref_To_Java e.expr>'.at ('<Expr_Int_To_Java e.pos>')'); … … 392 392 (e1) = { 393 393 e1 : \{ 394 '(Comparable )' e;394 '(Comparable<?>)' e; 395 395 'new Func' e; 396 396 'Symbol.new' e; … … 412 412 e.expr : t.item e.rest, t.item : { 413 413 (PAREN e.paren_expr) = 414 ('(Comparable ) '<Const_Expr_To_Java e.paren_expr>);414 ('(Comparable<?>) '<Const_Expr_To_Java e.paren_expr>); 415 415 (REF t.name) = 416 416 (<Name_To_Java t.name>); -
to-imperative/trunk/java/runtime/org/refal/plus/Expr.java
r3419 r3422 17 17 */ 18 18 19 public final class Expr implements Comparable<Expr>, Iterable<Comparable >, RandomAccess {19 public final class Expr implements Comparable<Expr>, Iterable<Comparable<?>>, RandomAccess { 20 20 public static final Expr empty = new Expr(new Comparable[1], 0, 0); 21 21 … … 31 31 private static final InplaceConcatenator concatenator = new InplaceConcatenator(); 32 32 33 private final Comparable [] terms;33 private final Comparable<?>[] terms; 34 34 private final int start; 35 35 private final int length; 36 36 37 37 /** 38 * Constructs expression from a subarray of an array of Comparable objects.38 * Constructs expression from a subarray of an array of Comparable<?> objects. 39 39 * This is private constructor because it doesn't copy the array and doesn't 40 40 * check that there aren't nulls in the array. 41 41 */ 42 private Expr (Comparable [] ts, int st, int len) {42 private Expr (Comparable<?>[] ts, int st, int len) { 43 43 assert ts != null : "ts="+ts; 44 44 //assert 0 <= st && st < ts.length && 0 <= len : "ts.length="+ts.length+", st="+st+", len="+len; … … 58 58 59 59 /** 60 * Constructor from Comparable object61 */ 62 public Expr (Comparable obj) {60 * Constructor from Comparable<?> object 61 */ 62 public Expr (Comparable<?> obj) { 63 63 assert obj != null : "obj="+obj; 64 64 terms = new Comparable[4]; … … 88 88 * position of the term 89 89 */ 90 public Comparable at (int i) {90 public Comparable<?> at (int i) { 91 91 assert 0 <= i && i < length : "length="+length+", i="+i; 92 92 return terms[(start + i) % terms.length]; … … 152 152 assert expr != null : "expr="+expr; 153 153 assert 0 <= j && j <= expr.length - length : "length="+length+", expr.length="+expr.length+", j="+j; 154 Comparable [] terms1 = expr.terms;154 Comparable<?>[] terms1 = expr.terms; 155 155 int tslen1 = terms1.length; 156 156 int k1 = (expr.start + j) % tslen1; … … 190 190 * Compares this expression with the specified expression for order. 191 191 */ 192 @SuppressWarnings("unchecked") 192 193 public int compareTo (Expr expr) { 193 194 assert expr != null : "expr="+expr; … … 201 202 } else if (length == expr.length) 202 203 compare_len = 0; 203 Comparable [] terms1 = expr.terms;204 Comparable<?>[] terms1 = expr.terms; 204 205 int tslen1 = terms1.length; 205 206 int k1 = expr.start; … … 207 208 int k = start; 208 209 for ( ; min_len > 0; min_len--, k = (k + 1) % tslen, k1 = (k1 + 1) % tslen1) { 209 Comparable term = terms[k];210 Comparable term1 = terms1[k1];210 Comparable<?> term = terms[k]; 211 Comparable<?> term1 = terms1[k1]; 211 212 int res = RefalRuntime.classCompare(term.getClass(), term1.getClass()); 212 213 if (res == 0) 213 res = term.compareTo(term1);214 res = ((Comparable<Comparable<?>>) term).compareTo(term1); // May be CheckCastException 214 215 if (res != 0) 215 216 return res; … … 218 219 } 219 220 220 private static void arrayCopy (Comparable [] src, int srcStart, Comparable[] dst, int dstStart, int length) {221 private static void arrayCopy (Comparable<?>[] src, int srcStart, Comparable<?>[] dst, int dstStart, int length) { 221 222 assert length > 0; 222 223 int srcLen = src.length; … … 255 256 return expr1; 256 257 } 257 Comparable [] ts1 = expr1.terms;258 Comparable [] ts2 = expr2.terms;258 Comparable<?>[] ts1 = expr1.terms; 259 Comparable<?>[] ts2 = expr2.terms; 259 260 int e1_end = (expr1.start + len1) % ts1.length; 260 261 if (ts1 == ts2 && e1_end == expr2.start) { … … 281 282 * Concatenates two terms. 282 283 */ 283 public static Expr concat (Comparable obj1, Comparableobj2) {284 public static Expr concat (Comparable<?> obj1, Comparable<?> obj2) { 284 285 assert obj1 != null && obj2 != null : "obj1="+obj1+", obj2="+obj2; 285 Comparable [] terms = new Comparable[4];286 Comparable<?>[] terms = new Comparable[4]; 286 287 terms[0] = obj1; 287 288 terms[1] = obj2; … … 292 293 * Concatenates expression and term. 293 294 */ 294 public static Expr concat (Expr expr, Comparable obj) {295 public static Expr concat (Expr expr, Comparable<?> obj) { 295 296 assert expr != null && obj != null : "expr="+expr+", obj="+obj; 296 297 if (expr.length == 0) … … 309 310 * Concatenates term and expression. 310 311 */ 311 public static Expr concat (Comparable obj, Expr expr) {312 public static Expr concat (Comparable<?> obj, Expr expr) { 312 313 assert obj != null && expr != null : "obj="+obj+", expr="+expr; 313 314 if (expr.length == 0) … … 336 337 337 338 /** 338 * Creates expression from an array of Comparable objects. Array shouldn't339 * Creates expression from an array of Comparable<?> objects. Array shouldn't 339 340 * contain nulls. 340 341 */ 341 public static Expr fromArray (Comparable [] arr) {342 public static Expr fromArray (Comparable<?>[] arr) { 342 343 assert noNulls(arr) : "arr="+arr; 343 344 int len = arr.length; 344 Comparable [] terms = new Comparable[len * 2];345 Comparable<?>[] terms = new Comparable[len * 2]; 345 346 System.arraycopy(arr, 0, terms, 0, len); 346 347 return new Expr(terms, 0, len); … … 351 352 * For use in assertions when creating expressions from arrays. 352 353 */ 353 private static boolean noNulls (Comparable [] arr) {354 private static boolean noNulls (Comparable<?>[] arr) { 354 355 if (arr == null) 355 356 return false; 356 for (Comparable obj : arr)357 for (Comparable<?> obj : arr) 357 358 if (obj == null) 358 359 return false; … … 366 367 public StringBuffer toStringBuffer () { 367 368 StringBuffer str = new StringBuffer(length); 368 for (Comparable term : this)369 for (Comparable<?> term : this) 369 370 if (term instanceof Expr) 370 371 str.append('(').append(((Expr) term).toStringBuffer()).append(')'); … … 379 380 StringBuffer str = new StringBuffer(2 * length); 380 381 boolean chars = false; 381 for (Comparable term : this) {382 for (Comparable<?> term : this) { 382 383 if (term instanceof Character) { 383 384 if (!chars) { … … 473 474 } 474 475 475 public class Iterator implements ListIterator<Comparable > {476 public class Iterator implements ListIterator<Comparable<?>> { 476 477 int idx; 477 478 … … 488 489 } 489 490 490 public Comparable next () {491 public Comparable<?> next () { 491 492 if (idx < 0 || length <= idx) 492 493 throw new NoSuchElementException(); … … 498 499 } 499 500 500 public Comparable previous () {501 public Comparable<?> previous () { 501 502 idx--; 502 503 if (idx < 0 || length <= idx) … … 509 510 } 510 511 511 public void add (Comparable obj) {512 public void add (Comparable<?> obj) { 512 513 throw new UnsupportedOperationException(); 513 514 } … … 517 518 } 518 519 519 public void set (Comparable obj) {520 public void set (Comparable<?> obj) { 520 521 throw new UnsupportedOperationException(); 521 522 } … … 531 532 532 533 public interface Concatenator { 533 public Concatenator toRight (Comparable obj);534 public Concatenator toRight (Comparable<?> obj); 534 535 535 536 public Concatenator toRight (Expr expr); … … 543 544 544 545 private static final class ParenthesesMarker { 545 public final Comparable object;546 547 public ParenthesesMarker(Comparable obj) {546 public final Comparable<?> object; 547 548 public ParenthesesMarker(Comparable<?> obj) { 548 549 object = obj; 549 550 } … … 554 555 } 555 556 556 public ListConcatenator toRight (Comparable obj) {557 public ListConcatenator toRight (Comparable<?> obj) { 557 558 list.add(new ParenthesesMarker(obj)); 558 559 length++; … … 571 572 if (length == 0) 572 573 return Expr.empty; 573 Comparable [] terms = new Comparable[length*2];574 Comparable<?>[] terms = new Comparable[length*2]; 574 575 int i = 0; 575 576 for (Object obj : list) … … 585 586 586 587 private static final class InplaceConcatenator implements Concatenator { 587 private Comparable [] terms;588 private Comparable<?>[] terms; 588 589 private int length; 589 590 … … 605 606 } 606 607 607 public InplaceConcatenator toRight (Comparable obj) {608 public InplaceConcatenator toRight (Comparable<?> obj) { 608 609 assert obj != null; 609 610 if (terms.length <= length) { 610 Comparable [] ts = new Comparable[length * 2];611 Comparable<?>[] ts = new Comparable[length * 2]; 611 612 System.arraycopy(terms, 0, ts, 0, length); 612 613 terms = ts; … … 622 623 int newLength = length + expr.length; 623 624 if (terms.length < newLength) { 624 Comparable [] ts = new Comparable[newLength * 2];625 Comparable<?>[] ts = new Comparable[newLength * 2]; 625 626 System.arraycopy(terms, 0, ts, 0, length); 626 627 terms = ts; … … 693 694 // * Creates expression from Comparable object. 694 695 // */ 695 //public static Expr fromComparable (Comparable obj) {696 //public static Expr fromComparable (Comparable<?> obj) { 696 697 // assert obj != null; 697 698 // return new Expr(obj); … … 719 720 // * There shouldn't be nulls in array between st and st+len. 720 721 // */ 721 //public static Expr fromComparableArray (Comparable [] arr, int st, int len) {722 //public static Expr fromComparableArray (Comparable<?>[] arr, int st, int len) { 722 723 // assert noNulls(arr, st, len); 723 // Comparable [] terms = new Comparable[len * 2 + 4];724 // Comparable<?>[] terms = new Comparable[len * 2 + 4]; 724 725 // System.arraycopy(arr, st, terms, 0, len); 725 726 // return new Expr(terms, 0, len); -
to-imperative/trunk/java/runtime/org/refal/plus/RefalRuntime.java
r3419 r3422 22 22 public static void setArgs (String arg0, String[] _args) { 23 23 Expr.Concatenator c = Expr.getConcatenator(_args.length + 1); 24 c.toRight((Comparable< Expr>) Expr.fromSequence(arg0));24 c.toRight((Comparable<?>) Expr.fromSequence(arg0)); 25 25 for (String arg : _args) 26 c.toRight((Comparable< Expr>) Expr.fromSequence(arg));26 c.toRight((Comparable<?>) Expr.fromSequence(arg)); 27 27 args = c.yield(); 28 28 } -
to-imperative/trunk/java/runtime/org/refal/plus/Result.java
r3419 r3422 24 24 } 25 25 26 //public void assign (Comparable [] arr) {26 //public void assign (Comparable<?>[] arr) { 27 27 // expr = Expr.fromComparableArray(arr); 28 28 //} -
to-imperative/trunk/java/runtime/refal/plus/Table.java
r3418 r3422 85 85 Expr.Concatenator concat = Expr.getConcatenator(c.size()); 86 86 for (Expr expr : c) 87 concat.toRight((Comparable< Expr>) expr);87 concat.toRight((Comparable<?>) expr); 88 88 res.assign(concat.yield()); 89 89 } catch (ClassCastException _) { … … 100 100 Expr.Concatenator concat = Expr.getConcatenator(c.size()); 101 101 for (Expr expr : c) 102 concat.toRight((Comparable< Expr>) expr);102 concat.toRight((Comparable<?>) expr); 103 103 res.assign(concat.yield()); 104 104 } catch (ClassCastException _) { … … 115 115 Expr.Concatenator concat = Expr.getConcatenator(map.size()); 116 116 for (Map.Entry<Expr, Expr> pair : map.entrySet()) 117 concat.toRight((Comparable< Expr>) Expr.concat((Comparable<Expr>) pair.getKey(), (Comparable<Expr>) pair.getValue()));117 concat.toRight((Comparable<?>) Expr.concat((Comparable<?>) pair.getKey(), (Comparable<?>) pair.getValue())); 118 118 res.assign(concat.yield()); 119 119 } catch (ClassCastException _) {
Note: See TracChangeset
for help on using the changeset viewer.