Changeset 3713


Ignore:
Timestamp:
Apr 16, 2008, 7:50:59 PM (13 years ago)
Author:
yura
Message:
  • No dots in variables name in JBC.
  • Use interface Func in runtime.
Location:
to-imperative/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/compiler/refal/org/refal/plus/compiler/rfp_asail_jbc.rf

    r3710 r3713  
    892892      # <IsInTable s.block_table1 VAR t.var>,
    893893      t.var : \{
    894         (SVAR (e.name)) = <ToWord 's.' e.name>;
    895         (TVAR (e.name)) = <ToWord 't.' e.name>;
    896         (VVAR (e.name)) = <ToWord 'v.' e.name>;
    897         (EVAR (e.name)) = <ToWord 'e.' e.name>;
     894        (SVAR (e.name)) = <ToWord 's_' e.name>;
     895        (TVAR (e.name)) = <ToWord 't_' e.name>;
     896        (VVAR (e.name)) = <ToWord 'v_' e.name>;
     897        (EVAR (e.name)) = <ToWord 'e_' e.name>;
    898898      } :: s.name,
    899899      # \{ <ToChars s.name> : e '$' e; },
  • to-imperative/trunk/java/java/org/refal/plus/Func.java

    r3683 r3713  
    77package org.refal.plus;
    88
    9 public abstract class Func implements Comparable<Func> {
    10     public abstract boolean eval (Expr arg, Result res) throws RefalException;
    11 
    12     @Override
    13     public java.lang.String toString () {
    14         return '&' + super.toString();
    15     }
    16 
    17     public int compareTo (Func func) {
    18         return RefalRuntime.compare(this, func);
    19     }
     9public interface Func {
     10    public boolean eval (Expr arg, Result res) throws RefalException;
    2011}
  • to-imperative/trunk/java/java/org/refal/plus/Symbol.java

    r3707 r3713  
    5050    }
    5151
     52    public static Comparable<?> newFunc (String name, Func func) {
     53        return new Reference<Func>(name, func);
     54    }
     55
    5256    public static Reference<StringBuffer> newString () {
    5357        return new Reference<StringBuffer>(new StringBuffer());
     
    8690    }
    8791
     92    public static Func getFunc (Expr expr) throws ClassCastException {
     93        assert expr.length() == 1;
     94        return (Func) ((Reference<?>) expr.at(0)).object;
     95    }
     96
    8897    public static <T> void setToResult (T object, Result res) {
    8998        res.assign(new Reference<T>(object));
  • to-imperative/trunk/java/java/refal/plus/Apply.java

    r3423 r3713  
    1 /*
    2  * $Id$
    3  *
    4  * vim: set syntax=java expandtab shiftwidth=4 tabstop=4:
    5  */
     1// $Id$
    62
    73package refal.plus;
    84
    95import org.refal.plus.Expr;
    10 import org.refal.plus.Func;
    116import org.refal.plus.RefalException;
    127import org.refal.plus.RefalFormat;
    138import org.refal.plus.Result;
     9import org.refal.plus.Symbol;
    1410
    1511public final class Apply {
     
    2016    @RefalFormat("$func? Apply s.Name e.Exp = e.Exp;")
    2117    public static boolean Apply (Expr func, Expr arg, Result res) throws RefalException {
    22         assert func.length() == 1;
    2318        try {
    24             return ((Func) func.at(0)).eval(arg, res);
     19            return Symbol.getFunc(func).eval(arg, res);
    2520        } catch (ClassCastException e) {
    2621            throw new RefalException("Apply", "Apply", "Invalid argument");
  • to-imperative/trunk/java/java/refal/plus/Class.java

    r3705 r3713  
    9494    @RefalFormat("$func? IsFunc e.expr = ;")
    9595    public static boolean IsFunc (Expr expr) {
    96         return getTerm(expr) instanceof Func;
     96        return getObject(expr) instanceof Func;
    9797    }
    9898}
Note: See TracChangeset for help on using the changeset viewer.