Package shen.Shen

Examples of shen.Shen.Compiler


        return fibBoxed(n - 1) + fibBoxed(n - 2);
    }

    static void bench(String test, int times) throws Throwable {
        Object kl = read(new StringReader(test)).get(0);
        bench(new Compiler(kl).load("__eval__", Callable.class).newInstance(), times);
    }
View Full Code Here


    }

    static <T> Class<T> compile(String file, Class<T> aClass) throws Throwable {
        try (Reader in = resource(format("%s.kl", file))) {
            debug("loading: %s", file);
            Compiler compiler = new Compiler(null, file, cons(intern("do"), read(in)));
            //noinspection RedundantCast
            File compilePath = new File((String) intern("*compile-path*").value());
            File classFile = new File(compilePath, file + ".class");
            if (!(compilePath.mkdirs() || compilePath.isDirectory())) throw new IOException("could not make directory: " + compilePath);
            try {
                return compiler.load(classFile.getName().replaceAll(".class$", ".kl"), aClass);
            } finally {
                lines.clear();
                if (compiler.bytes != null)
                    try (OutputStream out = new FileOutputStream(classFile)) {
                        out.write(compiler.bytes);
View Full Code Here

        static MethodHandle function(String x) throws Exception {
            return function(intern(x));
        }

        public static Object eval_kl(Object kl) throws Throwable {
            return new Compiler(kl).load("__eval__", Callable.class).newInstance().call();
        }
View Full Code Here

            typeHint.remove();
            push(handle(className, bytecodeName, desc(returnType, types)));
            insertArgs(0, scope);

            scope.addAll(asList(args));
            Compiler fn = new Compiler(cw, className, kl, scope.toArray(new Symbol[scope.size()]));
            fn.method(ACC_PUBLIC | ACC_STATIC | ACC_FINAL, intern(name), bytecodeName, returnType, types);
        }
View Full Code Here

TOP

Related Classes of shen.Shen.Compiler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.