# HG changeset patch # User Jaroslav Tulach # Date 1352395952 -3600 # Node ID d48a0da4549c81dc8c178f3d2aa311f1d2e69f95 # Parent a206e280acc854cd7cb77557f84c5eb074b10900 Moving the main method outside of GenJS, so it has lighter dependencies diff -r a206e280acc8 -r d48a0da4549c vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java --- a/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Wed Oct 31 18:05:24 2012 +0100 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/GenJS.java Thu Nov 08 18:32:32 2012 +0100 @@ -17,11 +17,8 @@ */ package org.apidesign.vm4brwsr; -import java.io.BufferedWriter; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; -import java.io.Writer; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -41,18 +38,6 @@ final class GenJS { private GenJS() {} - public static void main(String... args) throws IOException { - if (args.length < 2) { - System.err.println("Usage: java -cp ... -jar ... java/lang/Class org/your/App ..."); - return; - } - - Writer w = new BufferedWriter(new FileWriter(args[0])); - List classes = Arrays.asList(args).subList(1, args.length); - compile(w, classes); - w.close(); - } - static void compile(Appendable out, String... names) throws IOException { compile(out, Arrays.asList(names)); } @@ -197,5 +182,10 @@ } return u.openStream(); } - + + static String toString(String name) throws IOException { + StringBuilder sb = new StringBuilder(); + compile(sb, name); + return sb.toString().toString(); + } } diff -r a206e280acc8 -r d48a0da4549c vm/src/main/java/org/apidesign/vm4brwsr/Main.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vm/src/main/java/org/apidesign/vm4brwsr/Main.java Thu Nov 08 18:32:32 2012 +0100 @@ -0,0 +1,46 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ +package org.apidesign.vm4brwsr; + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.Arrays; +import java.util.List; + +/** Generator of JavaScript from bytecode of classes on classpath of the VM + * with a Main method. + * + * @author Jaroslav Tulach + */ +final class Main { + private Main() {} + + public static void main(String... args) throws IOException { + if (args.length < 2) { + System.err.println("Usage: java -cp ... -jar ... java/lang/Class org/your/App ..."); + return; + } + + Writer w = new BufferedWriter(new FileWriter(args[0])); + List classes = Arrays.asList(args).subList(1, args.length); + GenJS.compile(w, classes); + w.close(); + } +}