Changeset 2745


Ignore:
Timestamp:
May 5, 2007, 4:24:20 AM (14 years ago)
Author:
orlov
Message:
  • Undoing change committed in r2682.
  • Result class doesn't extends Expr but incapsulates it again.
Location:
to-imperative/trunk/java
Files:
4 edited

Legend:

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

    r2734 r2745  
    1111 */
    1212
    13 public class Expr
     13public final class Expr
    1414    implements Comparable, Cloneable
    1515{
    1616    public static final Expr empty = new Expr(0);
    1717
    18     protected Object[] terms;
    19 
    20     protected int start;
    21 
    22     protected int length;
     18    private final Object[] terms;
     19
     20    private final int start;
     21
     22    private final int length;
    2323
    2424    /*
     
    7171
    7272    public boolean isEmpty () {
    73         assert terms != null;
    7473        return length == 0;
    7574    }
     
    7978     */
    8079    public int getLen () {
    81         assert terms != null;
    8280        return length;
    8381    }
     
    9088     */
    9189    public Object at (int i) {
    92         assert terms != null;
    9390        assert 0 <= i && i < length;
    9491        return terms[start + i];
     
    10299     */
    103100    public boolean symbolAt (int i) {
    104         assert terms != null;
    105101        assert 0 <= i && i < length;
    106102        return !(terms[start + i] instanceof Expr);
     
    108104
    109105    public boolean equals (Object o) {
    110         assert terms != null;
    111106        return (o instanceof Expr) && equals((Expr) o);
    112107    }
     
    116111     */
    117112    public boolean equals (Expr e) {
    118         assert terms != null && e.terms != null;
    119113        if (length != e.length)
    120114            return false;
     
    152146     */
    153147    public boolean eq (Expr e, int i) {
    154         assert terms != null && e.terms != null;
    155148        assert i >= 0;
    156149        assert e.length - i >= length;
     
    188181     */
    189182    public boolean termEq (Expr e, int i) {
    190         assert terms != null && e.terms != null;
    191183        assert i >= 0;
    192184        assert i < e.length;
     
    200192    public int compareTo (Object o) {
    201193        Expr e = (Expr) o;
    202         assert terms != null && e.terms != null;
    203194//        if (equals(e))        // Check how this affects efficiency!
    204195//            return 0;
     
    253244     */
    254245    public Expr (Expr e1, Expr e2) {
    255         assert e1.terms != null && e2.terms != null;
    256246        length = e1.length + e2.length;
    257247        if (length == 0) {
     
    305295     */
    306296    public Expr (Expr e1, Object t2) {
    307         assert e1.terms != null;
    308297        length = e1.length + 1;
    309298        int e1_end = e1.start + e1.length;
     
    327316    public Expr(Expr e1, int i1, int len1, Expr e2, int i2, int len2) {
    328317        this(len1 + len2);
    329         assert e1.terms != null && e2.terms != null;
    330318        assert i1 >= 0;
    331319        assert len1 >= 0;
     
    470458     */
    471459    public Object[] toArray() {
    472         assert terms != null;
    473460        Object[] arr = new Object[length];
    474461        System.arraycopy(terms, start, arr, 0, length);
     
    480467     */
    481468    public void toArray (Object[] arr, int where, int what, int len) {
    482         assert terms != null;
    483469        assert length - len >= what;
    484470        System.arraycopy(terms, start + what, arr, where, len);
     
    490476
    491477    public StringBuffer toStringBuffer () {
    492         assert terms != null;
    493478        StringBuffer str = new StringBuffer(length);
    494479        for (int i = start, end = start + length; i < end; i++) {
     
    504489
    505490    public java.lang.String formattedRepresentation () {
    506         assert terms != null;
    507491        if (length == 0) return "";
    508492        StringBuffer str = new StringBuffer(2*length);
     
    549533
    550534    public SplitIterator leftSplit (int l) {
    551         assert terms != null;
    552535        return new SplitIterator(this, l);
    553536    }
    554537
    555538    public SplitIterator rightSplit (int r) {
    556         assert terms != null;
    557539        return new SplitIterator(this, length - r);
    558540    }
     
    596578    public Iterator iterator ()
    597579    {
    598         assert terms != null;
    599580        return new Iterator();
    600581    }
  • to-imperative/trunk/java/org/refal/plus/Result.java

    r2734 r2745  
    55package org.refal.plus;
    66
    7 public final class Result extends Expr
     7public final class Result
    88{
    9     static
     9    private Expr expr;
     10
     11    public Result ()
     12    {}
     13
     14    public void assign (Expr e)
    1015    {
    11         RefalRuntime.setPriorityTheSame(Result.class, Expr.class);
     16        expr = e;
    1217    }
    1318
    14     /**
    15      * Creates uninitialized expression.
    16      * Should be initailized later by one of assign() methods.
    17      */
    18     public Result () {
    19         terms = null;
     19    public void assign (Object obj)
     20    {
     21        expr = new Expr(obj);
    2022    }
    2123
    22     public void assign(Expr e) {
    23         assert e.terms != null;
    24         assert terms == null;
    25         terms = e.terms;
    26         start = e.start;
    27         length = e.length;
    28     }
    29 
    30     public void assign(Object obj) {
    31         assign(new Expr(obj));
    32     }
    33 
    34     public void assign(Object[] arr) {
    35         assign(Expr.fromArray(arr));
     24    public void assign (Object[] arr)
     25    {
     26        expr = Expr.fromArray(arr);
    3627    }
    3728
    3829    /*
    39      * Do not copy an array. Use with caution!
     30     * Do not copy an array.  Use with caution!
    4031     */
    41     public void assignUnsafe(Object[] arr) {
    42         assign(Expr.fromArrayUnsafe(arr));
     32    public void assignUnsafe (Object[] arr)
     33    {
     34        expr = Expr.fromArrayUnsafe(arr);
    4335    }
    4436
    4537    public Expr getExpr ()
    4638    {
    47         return this;
     39        return expr;
    4840    }
    4941}
  • to-imperative/trunk/java/refal/plus/Box.java

    r2682 r2745  
    3838        Result res = new Result();
    3939        Get(box, res);
    40         Store (box, new Expr(res, e));
     40        Store (box, new Expr(res.getExpr(), e));
    4141    }
    4242}
  • to-imperative/trunk/java/refal/plus/StdIO.java

    r2682 r2745  
    588588          Result _v_Stream1 = new Result();
    589589          Stream.Stream (_c_3, new Expr(StdIn, new Expr(BigInteger.ONE)), _v_Stream1);
    590           Table.Bind (Buffers, StdIn, _v_Stream1);
     590          Table.Bind (Buffers, StdIn, _v_Stream1.getExpr());
    591591      } catch (RefalException _) {}
    592592  }
Note: See TracChangeset for help on using the changeset viewer.