Changeset 3686


Ignore:
Timestamp:
Apr 12, 2008, 3:21:40 PM (13 years ago)
Author:
yura
Message:
  • Bug in refal.plus.Vector was found.
  • No org.refal.plus.Reference.Named.
  • org.refal.plus.Vector is added.
  • Logical structures for Reference, Vector and Table.
  • Test version of RfpLogicalStructureProvider?.
Location:
to-imperative/trunk/java/java
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/java/java/org/refal/plus/Reference.java

    r3683 r3686  
    88
    99public class Reference<T> implements Comparable<Reference<?>> {
     10    private final String name;
     11
    1012    public final T object;
    1113
     14    public Reference (String name, T obj) {
     15        this.name = name;
     16        this.object = obj;
     17    }
     18
    1219    public Reference (T obj) {
    13         object = obj;
     20        this(null, obj);
    1421    }
    15    
     22
    1623    @Override
    1724    public boolean equals (Object obj) {
     
    2532
    2633    @Override
    27     public java.lang.String toString () {
    28         return '&' + (object == null ? "null" : object.getClass().getName()) + '@' + Integer.toHexString(hashCode());
     34    public String toString () {
     35        String className = object.getClass().getName();
     36        if (className.startsWith("org.refal.plus."))
     37            className = className.substring("org.refal.plus.".length());
     38        return '&' + (name != null ? name : object == null ? "null" : className + '@' + Integer.toHexString(hashCode()));
    2939    }
    3040
     
    3242        return RefalRuntime.compare(this, ref);
    3343    }
    34 
    35     public static class Named<T> extends Reference<T> {
    36         static {
    37             RefalRuntime.setPriorityTheSame(Named.class, Reference.class);
    38         }
    39 
    40         private final java.lang.String name;
    41 
    42         public Named (java.lang.String n, T obj) {
    43             super(obj);
    44             name = n;
    45         }
    46 
    47         @Override
    48         public java.lang.String toString () {
    49             return "&" + name;
    50         }
    51     }
    5244}
  • to-imperative/trunk/java/java/org/refal/plus/Symbol.java

    r3685 r3686  
    1010import java.util.List;
    1111import java.util.Map;
    12 import java.util.TreeMap;
    13 import java.util.Vector;
    1412
    1513public final class Symbol {
     
    4038
    4139    public static Comparable<?> newString (String name) {
    42         return new Reference.Named<StringBuffer>(name, new StringBuffer());
     40        return new Reference<StringBuffer>(name, new StringBuffer());
    4341    }
    4442
     
    4846
    4947    public static Comparable<?> newTable (String name) {
    50         return new Reference.Named<Map<Expr, Expr>>(name, new Table());
     48        return new Reference<Map<Expr, Expr>>(name, new Table());
    5149    }
    5250
    5351    public static Reference<List<Expr>> newVector () {
    54         return new Reference<List<Expr>>(new Vector<Expr>());
     52        return new Reference<List<Expr>>(new Vector());
    5553    }
    5654
    5755    public static Comparable<?> newVector (String name) {
    58         return new Reference.Named<List<Expr>>(name, new Vector<Expr>());
     56        return new Reference<List<Expr>>(name, new Vector());
    5957    }
    6058}
  • to-imperative/trunk/java/java/org/refal/plus/Table.java

    r3685 r3686  
    44import java.util.TreeMap;
    55
    6 public class Table extends TreeMap<Expr, Expr> {
     6public final class Table extends TreeMap<Expr, Expr> {
    77    private static final long serialVersionUID = -5813283821621021621L;
    88
    9     public static class Entry {
     9    private static final class Entry {
    1010        public final Expr key;
    1111        public final Expr value;
     
    3333    }
    3434
    35     public Object toArray () {
     35    public Object[] toArray () {
    3636        Entry[] arr = new Entry[size()];
    3737        int i = 0;
  • to-imperative/trunk/java/java/refal/plus/Vector.java

    r3423 r3686  
    5151        Expr.Concatenator concat = Expr.getConcatenator(list.size());
    5252        for (Expr expr : list)
    53             concat.toRight(expr);
     53            concat.toRight((Comparable<?>) expr);
    5454        res.assign(concat.yield());
    5555    }
Note: See TracChangeset for help on using the changeset viewer.