资源简介

<<两周自制脚本语言>>源代码

资源截图

代码片段和文件信息

package chap10;
import java.util.List;
import javassist.gluonj.*;
import stone.ArrayParser;
import stone.StoneException;
import stone.ast.*;
import chap6.Environment;
import chap6.BasicEvaluator;
import chap6.BasicEvaluator.ASTreeEx;
import chap7.FuncEvaluator;
import chap7.FuncEvaluator.PrimaryEx;

@Require({FuncEvaluator.class ArrayParser.class})
@Reviser public class ArrayEvaluator {
    @Reviser public static class ArrayLitEx extends ArrayLiteral {
        public ArrayLitEx(List list) { super(list); }
        public object eval(Environment env) {
            int s = numChildren();
            object[] res = new object[s];
            int i = 0;
            for (ASTree t: this)
                res[i++] = ((ASTreeEx)t).eval(env);
            return res;
        }
    }
    @Reviser public static class ArrayRefEx extends ArrayRef {
        public ArrayRefEx(List c) { super(c); }
        public object eval(Environment env object value) {
            if (value instanceof object[]) {
                object index = ((ASTreeEx)index()).eval(env);
                if (index instanceof Integer)
                    return ((object[])value)[(Integer)index];
            }

            throw new StoneException(“bad array access“ this);
        }
    }
    @Reviser public static class AssignEx extends BasicEvaluator.BinaryEx {
        public AssignEx(List c) { super(c); }
        @Override
        protected object computeAssign(Environment env object rvalue) {
            ASTree le = left();
            if (le instanceof PrimaryExpr) {
                PrimaryEx p = (PrimaryEx)le;
                if (p.hasPostfix(0) && p.postfix(0) instanceof ArrayRef) {
                    object a = ((PrimaryEx)le).evalSubExpr(env 1);
                    if (a instanceof object[]) {
                        ArrayRef aref = (ArrayRef)p.postfix(0);
                        object index = ((ASTreeEx)aref.index()).eval(env);
                        if (index instanceof Integer) {
                            ((object[])a)[(Integer)index] = rvalue;
                            return rvalue;
                        }
                    }
                    throw new StoneException(“bad array access“ this);
                }
            }
            return super.computeAssign(env rvalue);
        }
    }       
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-06-07 13:05  stone-master\
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\
     文件         295  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\.classpath
     文件           6  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\.gitignore
     文件         369  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\.project
     文件      722210  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\gluonj.jar
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap10\
     文件        2351  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap10\ArrayEvaluator.java
     文件         451  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap10\ArrayRunner.java
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\
     文件        1359  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\ArrayEnv.java
     文件        1039  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\EnvOptInterpreter.java
     文件         326  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\EnvOptRunner.java
     文件        4815  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\EnvOptimizer.java
     文件         475  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\OptFunction.java
     文件        1639  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\ResizableArrayEnv.java
     文件        1506  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap11\Symbols.java
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\
     文件        2404  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\InlineCache.java
     文件         325  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\InlineRunner.java
     文件         810  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\MemberSymbols.java
     文件         390  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\ObjOptInterpreter.java
     文件         326  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\ObjOptRunner.java
     文件        6805  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\ObjOptimizer.java
     文件        1451  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\OptClassInfo.java
     文件         596  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\OptMethod.java
     文件        1177  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\OptStoneobject.java
     文件         505  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap12\SymbolThis.java
     目录           0  2015-06-07 13:05  stone-master\stone-2012feb21\stone-lang\src\chap13\
............此处省略108个文件信息

评论

共有 条评论