Changeset 4083


Ignore:
Timestamp:
Nov 9, 2009, 4:46:35 PM (11 years ago)
Author:
yura
Message:
  • Renaming and refactoring.
Location:
to-imperative/trunk
Files:
7 edited
1 moved

Legend:

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

    r4081 r4083  
    77import org.refal.plus.Expr;
    88
    9 public final class MailBox extends LinkedBlockingQueue<Expr> {
     9public final class MsgBox extends LinkedBlockingQueue<Expr> {
    1010    private static final long serialVersionUID = 1964658309366552579L;
    1111
  • to-imperative/trunk/java/java/refal/plus/Box.java

    r4048 r4083  
    1313    private Box () {}
    1414
    15     static org.refal.plus.objects.Box getBox (Expr expr) throws ClassCastException {
    16         return (org.refal.plus.objects.Box) Symbol.getObject(expr);
     15    static org.refal.plus.objects.Box getBox (Expr box) throws ClassCastException {
     16        return (org.refal.plus.objects.Box) Symbol.getObject(box);
    1717    }
    1818
     
    3636    @RefalFormat("$func Store s.box e.expr = ;")
    3737    public static void Store (Expr box, Expr expr) throws RefalException {
    38         assert box.length() == 1;
    3938        try {
    4039            getBox(box).expr = expr;
     
    4645    @RefalFormat("$func Put s.box e.expr = ;")
    4746    public static void Put (Expr box, Expr expr) throws RefalException {
    48         org.refal.plus.objects.Box b = getBox(box);
    49         b.expr = Expr.concat(b.expr, expr);
     47        try {
     48            org.refal.plus.objects.Box b = getBox(box);
     49            b.expr = Expr.concat(b.expr, expr);
     50        } catch (ClassCastException _) {
     51            throw new RefalException("refal.plus.Box.Put", "Invalid argument");
     52        }
    5053    }
    5154
  • to-imperative/trunk/java/java/refal/plus/Parallel.java

    r4081 r4083  
    1414    private Parallel () {}
    1515
    16     static org.refal.plus.objects.MailBox getMailBox (Expr expr) throws ClassCastException {
    17         return (org.refal.plus.objects.MailBox) Symbol.getObject(expr);
     16    static org.refal.plus.objects.MsgBox getMsgBox (Expr mbox) throws ClassCastException {
     17        return (org.refal.plus.objects.MsgBox) Symbol.getObject(mbox);
    1818    }
    1919
     
    3737    }
    3838
    39     @RefalFormat("$func MailBox = s.box;")
    40     public static void MailBox (Result box) {
    41         Symbol.setObject(new org.refal.plus.objects.MailBox(), box);
     39    @RefalFormat("$func MsgBox = s.mbox;")
     40    public static void MsgBox (Result mbox) {
     41        Symbol.setObject(new org.refal.plus.objects.MsgBox(), mbox);
    4242    }
    4343
    4444    @RefalFormat("$func? IRecv s.box = e.expr ;")
    45     public static boolean IRecv (Expr box, Result expr) throws RefalException {
     45    public static boolean IRecv (Expr mbox, Result expr) throws RefalException {
    4646        try {
    47             Expr msg = getMailBox(box).poll();
     47            Expr msg = getMsgBox(mbox).poll();
    4848            if (msg == null)
    4949                return false;
     
    5656
    5757    @RefalFormat("$func Recv s.box = e.expr;")
    58     public static void Recv (Expr box, Result expr) throws RefalException {
     58    public static void Recv (Expr mbox, Result expr) throws RefalException {
    5959        try {
    60             expr.assign(getMailBox(box).take());
     60            expr.assign(getMsgBox(mbox).take());
    6161        } catch (ClassCastException _) {
    6262            throw new RefalException("refal.plus.Parallel.Recv", "Invalid argument");
     
    6767
    6868    @RefalFormat("$func Send s.box e.expr = ;")
    69     public static void Send (Expr box, Expr expr) throws RefalException {
    70         assert box.length() == 1;
     69    public static void Send (Expr mbox, Expr expr) throws RefalException {
    7170        try {
    72             getMailBox(box).add(expr);
     71            getMsgBox(mbox).put(expr);
    7372        } catch (ClassCastException _) {
    7473            throw new RefalException("refal.plus.Parallel.Send", "Invalid argument");
     74        } catch (InterruptedException _) {
     75            throw new RefalException("refal.plus.Parallel.Send", "Interrupted");
    7576        }
    7677    }
  • to-imperative/trunk/java/java/refal/plus/StdIO.java

    r4048 r4083  
    2020    private StdIO () {}
    2121
    22     private static Channel getChannel (Expr expr) throws ClassCastException {
    23         return (Channel) Symbol.getObject(expr);
     22    private static Channel getChannel (Expr channel) throws ClassCastException {
     23        return (Channel) Symbol.getObject(channel);
    2424    }
    2525
  • to-imperative/trunk/java/java/refal/plus/String.java

    r4048 r4083  
    1616    private String () {}
    1717
    18     private static org.refal.plus.objects.String getString (Expr expr) throws ClassCastException {
    19         return (org.refal.plus.objects.String) Symbol.getObject(expr);
     18    private static org.refal.plus.objects.String getString (Expr string) throws ClassCastException {
     19        return (org.refal.plus.objects.String) Symbol.getObject(string);
    2020    }
    2121
    22     private static Character getCharacter (Expr expr) throws ClassCastException {
    23         return (Character) Util.getTerm(expr);
     22    private static Character getCharacter (Expr ch) throws ClassCastException {
     23        return (Character) Util.getTerm(ch);
    2424    }
    2525
  • to-imperative/trunk/java/java/refal/plus/Table.java

    r4048 r4083  
    1414    private Table () {}
    1515
    16     private static org.refal.plus.objects.Table getTable (Expr expr) throws ClassCastException {
    17         return (org.refal.plus.objects.Table) Symbol.getObject(expr);
     16    private static org.refal.plus.objects.Table getTable (Expr table) throws ClassCastException {
     17        return (org.refal.plus.objects.Table) Symbol.getObject(table);
    1818    }
    1919
  • to-imperative/trunk/java/java/refal/plus/Vector.java

    r4048 r4083  
    1616    private Vector () {}
    1717
    18     private static org.refal.plus.objects.Vector getVector (Expr expr) throws ClassCastException {
    19         return (org.refal.plus.objects.Vector) Symbol.getObject(expr);
     18    private static org.refal.plus.objects.Vector getVector (Expr vector) throws ClassCastException {
     19        return (org.refal.plus.objects.Vector) Symbol.getObject(vector);
    2020    }
    2121
  • to-imperative/trunk/samples/src/ParallelTest.rf

    r4082 r4083  
    1616$func Main = e;
    1717
    18 Main = <MailBox> :: s.mbox,
     18Main = <MsgBox> :: s.mbox,
    1919        <PrintLn <Time>>,
    2020        <ParApply &ParCall 40000 s.mbox> : e,
Note: See TracChangeset for help on using the changeset viewer.