mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-07 05:08:51 -04:00
fixed broken
This commit is contained in:
parent
bce3396cf5
commit
70920b14a8
2 changed files with 13 additions and 25 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package generator;
|
||||
|
||||
import fastexpr.stages.Lexer;
|
||||
|
||||
public class Test {
|
||||
// public static Gen<String, Void> 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue