Changeset 2024


Ignore:
Timestamp:
Jul 16, 2006, 12:25:51 AM (14 years ago)
Author:
orlov
Message:
  • Assertions about Refal library function formats.
  • Some classes became final.
Location:
to-imperative/trunk/java/org/refal/plus
Files:
12 edited

Legend:

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

    r1953 r2024  
    66import java.math.BigInteger;
    77
    8 public class Util
     8public final class Util
    99{
    1010    public static final BigInteger maxInt  = BigInteger.valueOf(Integer.MAX_VALUE);
  • to-imperative/trunk/java/org/refal/plus/library/Access.java

    r1953 r2024  
    88import java.math.BigInteger;
    99
    10 public class Access
     10public final class Access
    1111{
    1212    static private int intValue (BigInteger i) throws ValueOutOfBoundsException
     
    2020        throws RefalException
    2121    {
    22         // FIXME: insert here assertion s_left.getLen() == 1
     22        assert s_left.getLen() == 1;
    2323        try {
    2424            int left = intValue((BigInteger) s_left.at(0));
     
    3636        throws RefalException
    3737    {
    38         // FIXME: insert here assertion s_right.getLen() == 1
     38        assert s_right.getLen() == 1;
    3939        try {
    4040            int right = intValue((BigInteger) s_right.at(0));
     
    5252        throws RefalException
    5353    {
    54         // FIXME: insert here assertion s_left.getLen() == 1
    55         // FIXME: insert here assertion s_len.getLen() == 1
     54        assert s_left.getLen() == 1;
     55        assert s_len.getLen() == 1;
    5656        try {
    5757            int len  = intValue((BigInteger) s_len .at(0));
     
    7070        throws RefalException
    7171    {
    72         // FIXME: insert here assertion s_right.getLen() == 1
    73         // FIXME: insert here assertion s_len.getLen() == 1
     72        assert s_right.getLen() == 1;
     73        assert s_len.getLen() == 1;
    7474        try {
    7575            int len   = intValue((BigInteger) s_len  .at(0));
     
    8888        throws RefalException
    8989    {
    90         // FIXME: insert here assertion s_left.getLen() == 1
    91         // FIXME: insert here assertion s_right.getLen() == 1
     90        assert s_left.getLen() == 1;
     91        assert s_right.getLen() == 1;
    9292        try {
    9393            int left  = intValue((BigInteger) s_left .at(0));
  • to-imperative/trunk/java/org/refal/plus/library/Apply.java

    r1945 r2024  
    77import org.refal.plus.*;
    88
    9 public class Apply
     9public final class Apply
    1010{
    1111    static public boolean Apply (Expr func, Expr arg, Result res)
    1212        throws RefalException
    1313    {
    14         // FIXME: insert here assertion func.getLen() == 1
     14        assert func.getLen() == 1;
    1515        try {
    1616            return ((Func)func.at(0)).eval(arg, res);
  • to-imperative/trunk/java/org/refal/plus/library/Arithm.java

    r1944 r2024  
    88import java.math.BigInteger;
    99
    10 public class Arithm
     10public final class Arithm
    1111{
    1212    static public void _p_ (Expr s1, Expr s2, Result res) throws RefalException
    1313    {
    14         // FIXME: insert here assertion s1.getLen() == 1
    15         // FIXME: insert here assertion s2.getLen() == 1
     14        assert s1.getLen() == 1;
     15        assert s2.getLen() == 1;
    1616        try {
    1717            res.assign(((BigInteger) s1.at(0)).add((BigInteger) s2.at(0)));
     
    2323    static public void _m_ (Expr s1, Expr s2, Result res) throws RefalException
    2424    {
    25         // FIXME: insert here assertion s1.getLen() == 1
    26         // FIXME: insert here assertion s2.getLen() == 1
     25        assert s1.getLen() == 1;
     26        assert s2.getLen() == 1;
    2727        try {
    2828            res.assign(((BigInteger) s1.at(0)).subtract((BigInteger) s2.at(0)));
     
    3434    static public void _a_ (Expr s1, Expr s2, Result res) throws RefalException
    3535    {
    36         // FIXME: insert here assertion s1.getLen() == 1
    37         // FIXME: insert here assertion s2.getLen() == 1
     36        assert s1.getLen() == 1;
     37        assert s2.getLen() == 1;
    3838        try {
    3939            res.assign(((BigInteger) s1.at(0)).multiply((BigInteger) s2.at(0)));
     
    4545    static public void Div (Expr s1, Expr s2, Result res) throws RefalException
    4646    {
    47         // FIXME: insert here assertion s1.getLen() == 1
    48         // FIXME: insert here assertion s2.getLen() == 1
     47        assert s1.getLen() == 1;
     48        assert s2.getLen() == 1;
    4949        try {
    5050            res.assign(((BigInteger) s1.at(0)).divide((BigInteger) s2.at(0)));
     
    5858    static public void Rem (Expr s1, Expr s2, Result res) throws RefalException
    5959    {
    60         // FIXME: insert here assertion s1.getLen() == 1
    61         // FIXME: insert here assertion s2.getLen() == 1
     60        assert s1.getLen() == 1;
     61        assert s2.getLen() == 1;
    6262        try {
    6363            res.assign(((BigInteger) s1.at(0)).remainder((BigInteger) s2.at(0)));
     
    7272        throws RefalException
    7373    {
    74         // FIXME: insert here assertion s1.getLen() == 1
    75         // FIXME: insert here assertion s2.getLen() == 1
     74        assert s1.getLen() == 1;
     75        assert s2.getLen() == 1;
    7676        try {
    7777            BigInteger[] a = ((BigInteger) s1.at(0)).divideAndRemainder((BigInteger) s2.at(0));
     
    8787    static public void GCD (Expr s1, Expr s2, Result res) throws RefalException
    8888    {
    89         // FIXME: insert here assertion s1.getLen() == 1
    90         // FIXME: insert here assertion s2.getLen() == 1
     89        assert s1.getLen() == 1;
     90        assert s2.getLen() == 1;
    9191        try {
    9292            BigInteger d = ((BigInteger) s1.at(0)).gcd((BigInteger) s2.at(0));
  • to-imperative/trunk/java/org/refal/plus/library/Box.java

    r1963 r2024  
    3838    }
    3939
    40     /**
    41      * @param _e
    42      * @param _res
    43      */
    4440    static public void Box (Expr e, Result res)
    4541    {
     
    4743    }
    4844
    49     /**
    50      * @param _box
    51      * @param _res
    52      * @return
    53      */
    5445    static public void _q_ (Expr box, Result res) throws RefalException
    5546    {
    56         // FIXME: insert here assertion box.length == 1
     47        assert box.getLen() == 1;
    5748        try {
    5849            res.assign(((Box) box.at(0)).expr);
     
    6253    }
    6354
    64     /**
    65      * @param _box
    66      * @param _e
    67      * @return
    68      */
    6955    static public void Store (Expr box, Expr e) throws RefalException
    7056    {
    71         // FIXME: insert here assertion box.length == 1
     57        assert box.getLen() == 1;
    7258        try {
    7359            ((Box) box.at(0)).expr = e;
  • to-imperative/trunk/java/org/refal/plus/library/Class.java

    r1947 r2024  
    88import java.math.BigInteger;
    99
    10 public class Class
     10public final class Class
    1111{
    1212    public static boolean Box_q_ (Expr e)
  • to-imperative/trunk/java/org/refal/plus/library/Compare.java

    r1946 r2024  
    77import org.refal.plus.*;
    88
    9 public class Compare
     9public final class Compare
    1010{
    1111    private static final Expr lt = new Expr(new Character('<'));
  • to-imperative/trunk/java/org/refal/plus/library/Convert.java

    r1946 r2024  
    99import java.lang.String;
    1010
    11 public class Convert
     11public final class Convert
    1212{
    1313    static public void To_m_Chars (Expr e, Result res)
  • to-imperative/trunk/java/org/refal/plus/library/Dir.java

    r1956 r2024  
    2929    public static boolean Read_m_Dir (Expr dir, Result fname) throws RefalException
    3030    {
    31         // FIXME: insert here assertion dir.getLen() == 1
     31        assert dir.getLen() == 1;
    3232        try {
    3333            Dir d = (Dir) dir.at(0);
     
    4444    public static void Close_m_Dir (Expr dir) throws RefalException
    4545    {
    46         // FIXME: insert here assertion dir.getLen() == 1
     46        assert dir.getLen() == 1;
    4747        try {
    4848            ((Dir) dir.at(0)).files = null;
  • to-imperative/trunk/java/org/refal/plus/library/Dos.java

    r1953 r2024  
    99import java.util.Calendar;
    1010
    11 public class Dos
     11public final class Dos
    1212{
    1313    private static final Word[] months = {
     
    3838            BigInteger.valueOf(c.get(Calendar.MILLISECOND) / 10)
    3939        };
    40         e.assign(time);
     40        e.assignUnsafe(time);
    4141    }
    4242
    4343    static public void Arg (Expr e, Result res) throws RefalException
    4444    {
    45         // FIXME: insert here assertion e.getLen() == 1
     45        assert e.getLen() == 1;
    4646        try {
    4747            BigInteger i = (BigInteger) e.at(0);
     
    5757    static public void Exit (Expr e) throws RefalException
    5858    {
    59         // FIXME: insert here assertion e.getLen() == 1
     59        assert e.getLen() == 1;
    6060        try {
    6161            BigInteger i = (BigInteger) e.at(0);
     
    6868        }
    6969    }
    70 
    71 //    /**
    72 //     * @param className
    73 //     * @param args
    74 //     */
    75 //    static public void Arguments(java.lang.String className,
    76 //            java.lang.String[] args) {
    77 //        java.lang.String[] str = className.split("[.]");
    78 //        arg = new java.lang.String[args.length + 1];
    79 //        arg[0] = str[0];
    80 //        System.arraycopy(args, 0, arg, 1, args.length);
    81 //    }
    8270}
  • to-imperative/trunk/java/org/refal/plus/library/StdIO.java

    r1964 r2024  
    1010import java.math.BigInteger;
    1111
    12 public class StdIO
     12public final class StdIO
    1313{
    1414    public static final Expr StdIn  = new Expr(new NamedChannel("StdIn" , System.in));
     
    6363            for (int i = 0; i < n; i++)
    6464                seq[i] = new Character(buf[i]);
    65             chars.assign(seq);
     65            chars.assignUnsafe(seq);
    6666            return true;
    6767        } catch (IOException x) {
     
    8585    public static void Write_e_ (Expr channel, Expr e) throws RefalException
    8686    {
    87         // FIXME: insert here assertion channel.getLen() == 1
     87        assert channel.getLen() == 1;
    8888        try {
    8989            ((Channel) channel.at(0)).print(e.formattedRepresentation());
     
    100100    public static void WriteLN_e_ (Expr channel, Expr e) throws RefalException
    101101    {
    102         // FIXME: insert here assertion channel.getLen() == 1
     102        assert channel.getLen() == 1;
    103103        try {
    104104            ((Channel) channel.at(0)).println(e.formattedRepresentation());
     
    125125    public static void Print_e_ (Expr channel, Expr e) throws RefalException
    126126    {
    127         // FIXME: insert here assertion channel.getLen() == 1
     127        assert channel.getLen() == 1;
    128128        try {
    129129            ((Channel) channel.at(0)).print(e);
     
    140140    public static void PrintLN_e_ (Expr channel, Expr e) throws RefalException
    141141    {
    142         // FIXME: insert here assertion channel.getLen() == 1
     142        assert channel.getLen() == 1;
    143143        try {
    144144            ((Channel) channel.at(0)).println(e);
     
    155155    public static void Flush_e_ (Expr channel) throws RefalException
    156156    {
    157         // FIXME: insert here assertion channel.getLen() == 1
     157        assert channel.getLen() == 1;
    158158        try {
    159159            ((Channel) channel.at(0)).flush();
  • to-imperative/trunk/java/org/refal/plus/library/Table.java

    r1963 r2024  
    2626    static public void Bind (Expr tab, Expr key, Expr val) throws RefalException
    2727    {
    28         // FIXME: insert here assertion tab.length == 1
     28        assert tab.getLen() == 1;
    2929        try {
    3030            ((TreeMap) tab.at(0)).put(key, val);
     
    3636    static public void Unbind (Expr tab, Expr key) throws RefalException
    3737    {
    38         // FIXME: insert here assertion tab.length == 1
     38        assert tab.getLen() == 1;
    3939        try {
    4040            ((TreeMap) tab.at(0)).remove(key);
     
    4646    static public boolean Lookup (Expr tab, Expr key, Result val) throws RefalException
    4747    {
    48         // FIXME: insert here assertion tab.length == 1
     48        assert tab.getLen() == 1;
    4949        try {
    5050            Expr e = (Expr) ((TreeMap) tab.at(0)).get(key);
     
    5959    static public boolean In_m_Table_q_ (Expr tab, Expr key) throws RefalException
    6060    {
    61         // FIXME: insert here assertion tab.length == 1
     61        assert tab.getLen() == 1;
    6262        try {
    6363            return ((TreeMap) tab.at(0)).containsKey(key);
     
    6969    static public void Domain (Expr tab, Result res) throws RefalException
    7070    {
    71         // FIXME: insert here assertion tab.length == 1
     71        assert tab.getLen() == 1;
    7272        try {
    7373            res.assign(((TreeMap) tab.at(0)).keySet().toArray());
     
    7979    static public void Values (Expr tab, Result res) throws RefalException
    8080    {
    81         // FIXME: insert here assertion tab.length == 1
     81        assert tab.getLen() == 1;
    8282        try {
    8383            res.assign(((TreeMap) tab.at(0)).values().toArray());
     
    8989    static public void Table_m_Copy (Expr tab, Result res) throws RefalException
    9090    {
    91         // FIXME: insert here assertion tab.length == 1
     91        assert tab.getLen() == 1;
    9292        try {
    9393            res.assign(((TreeMap) tab.at(0)).clone());
     
    9999    static public void Replace_m_Table (Expr target, Expr source) throws RefalException
    100100    {
    101         // FIXME: insert here assertion target.length == 1
    102         // FIXME: insert here assertion source.length == 1
     101        assert target.getLen() == 1;
     102        assert source.getLen() == 1;
    103103        try {
    104104            TreeMap t = (TreeMap) target.at(0);
     
    112112    static public void Clear_m_Table (Expr tab) throws RefalException
    113113    {
    114         // FIXME: insert here assertion tab.length == 1
     114        assert tab.getLen() == 1;
    115115        try {
    116116            ((TreeMap) tab.at(0)).clear();
     
    122122    static public void Table_m_Size (Expr tab, Result res) throws RefalException
    123123    {
    124         // FIXME: insert here assertion tab.length == 1
     124        assert tab.getLen() == 1;
    125125        try {
    126126            res.assign(BigInteger.valueOf(((TreeMap) tab.at(0)).size()));
Note: See TracChangeset for help on using the changeset viewer.