diff --git a/src/generator/Fun.java b/src/generator/Fun.java index c3f3829..400f25c 100644 --- a/src/generator/Fun.java +++ b/src/generator/Fun.java @@ -22,13 +22,8 @@ import static java.lang.classfile.attribute.StackMapFrameInfo.SimpleVerification public class Fun { public static void main(String... args) throws Exception { -// var loader = new GeneratorClassLoader(Fun.class.getClassLoader()); -// loader.loadClass(Fun.class.getName()).getMethod("run").invoke(null); - var thread = new Thread(() -> { - Fun.run(); - }); - thread.setContextClassLoader(new GeneratorClassLoader(Fun.class.getClassLoader())); - thread.start(); + var loader = new GeneratorClassLoader(Fun.class.getClassLoader()); + loader.loadClass(Fun.class.getName()).getMethod("run").invoke(null); } public static void run() { @@ -80,7 +75,6 @@ public class Fun { try (var stream = Fun.class.getResourceAsStream(p)) { var bytes = Objects.requireNonNull(stream).readAllBytes(); bytes = searchForGenerators(bytes); - Files.write(Path.of("cs/" + name + ".class"), bytes); customClazzDefMap.put(name, bytes); customClazzMap.put(name, defineClass(name, bytes, 0, bytes.length)); return customClazzMap.get(name); @@ -164,11 +158,6 @@ public class Fun { }); } ); - try { - Files.write(Path.of("cs/" + cd.displayName() + ".class"), bytes); - } catch (IOException e) { - throw new RuntimeException(e); - } customClazzDefMap.put(cd.displayName(), bytes); return cd; } diff --git a/src/generator/Test.java b/src/generator/Test.java index 6ca95be..26cdebc 100644 --- a/src/generator/Test.java +++ b/src/generator/Test.java @@ -1,6 +1,5 @@ package generator; -import fastexpr.stages.Lexer; public class Test { // public static Gen gen() { @@ -49,22 +48,22 @@ public class Test { char curr = input.charAt(pos++); switch (curr){ - case '(' -> Gen.yield(Lexer.Punc.LPar); - case ')' -> Gen.yield(Lexer.Punc.RPar); - case '+' -> Gen.yield(Lexer.Punc.Add); - case '-' -> Gen.yield(Lexer.Punc.Sub); - case '/' -> Gen.yield(Lexer.Punc.Div); - case '*' -> Gen.yield(Lexer.Punc.Mul); - case ',' -> Gen.yield(Lexer.Punc.Comma); - case '^' -> Gen.yield(Lexer.Punc.Carrot); - case '=' -> Gen.yield(Lexer.Punc.Equals); + case '(' -> Gen.yield(Punc.LPar); + case ')' -> Gen.yield(Punc.RPar); + case '+' -> Gen.yield(Punc.Add); + case '-' -> Gen.yield(Punc.Sub); + case '/' -> Gen.yield(Punc.Div); + case '*' -> Gen.yield(Punc.Mul); + case ',' -> Gen.yield(Punc.Comma); + case '^' -> Gen.yield(Punc.Carrot); + case '=' -> Gen.yield(Punc.Equals); case char c when Character.isWhitespace(c) -> {} case char c when Character.isAlphabetic(c) -> { while((Character.isLetter(curr) || Character.isLetterOrDigit(curr))){ if(pos>=input.length())break; curr = input.charAt(pos++); } - Gen.yield(new Lexer.Ident(input.substring(start, pos-1))); + Gen.yield(new Ident(input.substring(start, pos-1))); } case char c when '0' <= c && c <= '9' -> { boolean exp = false; @@ -80,7 +79,7 @@ public class Test { } } - Gen.yield(new Lexer.Numeric(Double.parseDouble(input.substring(start, pos-1).replace("_", "")))); + Gen.yield(new Numeric(Double.parseDouble(input.substring(start, pos-1).replace("_", "")))); } default -> throw new RuntimeException("Invalid char " + curr); }