mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-06 21:00:35 -04:00
moved more things to config, fixed package name typo
This commit is contained in:
parent
a577a825f8
commit
817004672d
18 changed files with 44 additions and 33 deletions
|
|
@ -1,12 +1,12 @@
|
|||
package lexer;
|
||||
|
||||
import com.parkertenbroeck.generator.Gen;
|
||||
import com.parkertenbroeck.bcms.RT;
|
||||
import com.parkertenbroeck.bcms.loadtime.StateMachineClassLoader;
|
||||
import com.parkertenbroeck.bcsm.RT;
|
||||
import com.parkertenbroeck.bcsm.loadtime.StateMachineClassLoader;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
RT.runWithStateMachines(StateMachineClassLoader.Config.builtin(), (Object) args);
|
||||
RT.runWithStateMachines(StateMachineClassLoader.Config.builtin().write_classes("build/modified/generators/"), (Object) args);
|
||||
|
||||
lexer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package sockets;
|
||||
|
||||
import com.parkertenbroeck.async_runtime.Jokio;
|
||||
import com.parkertenbroeck.bcms.RT;
|
||||
import com.parkertenbroeck.bcms.loadtime.StateMachineClassLoader;
|
||||
import com.parkertenbroeck.bcsm.RT;
|
||||
import com.parkertenbroeck.bcsm.loadtime.StateMachineClassLoader;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
RT.runWithStateMachines(StateMachineClassLoader.Config.builtin(), (Object) args);
|
||||
RT.runWithStateMachines(StateMachineClassLoader.Config.builtin().write_classes("build/modified/generators/"), (Object) args);
|
||||
|
||||
await();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import com.parkertenbroeck.async_runtime.Jokio;
|
|||
import com.parkertenbroeck.async_runtime.io.net.ServerSocket;
|
||||
import com.parkertenbroeck.async_runtime.io.net.Socket;
|
||||
import com.parkertenbroeck.future.Future;
|
||||
import com.parkertenbroeck.bcms.loadtime.future.Cancellation;
|
||||
import com.parkertenbroeck.bcsm.loadtime.future.Cancellation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.parkertenbroeck.bcms;
|
||||
package com.parkertenbroeck.bcsm;
|
||||
|
||||
|
||||
import com.parkertenbroeck.bcms.loadtime.StateMachineClassLoader;
|
||||
import com.parkertenbroeck.bcsm.loadtime.StateMachineClassLoader;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Set;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.classfile.CodeBuilder;
|
||||
import java.lang.classfile.instruction.LineNumber;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
|
||||
import java.lang.classfile.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.constant.ClassDesc;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
public enum ReplacementKind {
|
||||
ImmediateReplacingPop,
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.classfile.CodeBuilder;
|
||||
import java.lang.classfile.TypeKind;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.constant.ClassDesc;
|
||||
import java.lang.constant.MethodTypeDesc;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.classfile.CodeBuilder;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.classfile.CodeBuilder;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.classfile.CodeBuilder;
|
||||
import java.lang.classfile.Label;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import java.lang.classfile.*;
|
||||
import java.lang.classfile.attribute.InnerClassInfo;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.parkertenbroeck.bcms.loadtime;
|
||||
package com.parkertenbroeck.bcsm.loadtime;
|
||||
|
||||
import com.parkertenbroeck.future.Future;
|
||||
import com.parkertenbroeck.generator.Gen;
|
||||
import com.parkertenbroeck.bcms.loadtime.future.FutureSMBuilder;
|
||||
import com.parkertenbroeck.bcms.loadtime.gen.GenSMBuilder;
|
||||
import com.parkertenbroeck.bcsm.loadtime.future.FutureSMBuilder;
|
||||
import com.parkertenbroeck.bcsm.loadtime.gen.GenSMBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.classfile.*;
|
||||
|
|
@ -18,6 +18,7 @@ public class StateMachineClassLoader extends ClassLoader {
|
|||
private final HashMap<String, Class<?>> customClazzMap = new HashMap<>();
|
||||
private final List<String> skip;
|
||||
private final HashMap<ClassDesc, SMBB> builders;
|
||||
private final String write_classes_path;
|
||||
|
||||
public interface SMBB{
|
||||
StateMachineBuilder<?> build(ClassModel src_clm, MethodModel src_mem, CodeModel src_com);
|
||||
|
|
@ -25,13 +26,14 @@ public class StateMachineClassLoader extends ClassLoader {
|
|||
public static class Config{
|
||||
HashSet<String> skip = new HashSet<>();
|
||||
HashMap<ClassDesc, SMBB> builders = new HashMap<>();
|
||||
String write_classes;
|
||||
|
||||
public static Config empty(){
|
||||
return new Config();
|
||||
}
|
||||
public static Config builtin(){
|
||||
return empty()
|
||||
.skip("java", "jdk", "jre", "com.parkertenbroeck.generators.loadtime")
|
||||
.skip("java", "jdk", "jre", "com.parkertenbroeck.bcsm.loadtime")
|
||||
.with(Future.class, FutureSMBuilder::new)
|
||||
.with(Gen.class, GenSMBuilder::new);
|
||||
}
|
||||
|
|
@ -50,6 +52,11 @@ public class StateMachineClassLoader extends ClassLoader {
|
|||
builders.put(ret, builder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config write_classes(String path){
|
||||
write_classes = path;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public StateMachineClassLoader(ClassLoader parent) {
|
||||
|
|
@ -60,15 +67,19 @@ public class StateMachineClassLoader extends ClassLoader {
|
|||
super(parent);
|
||||
skip = config.skip.stream().toList();
|
||||
builders = new HashMap<>(config.builders);
|
||||
write_classes_path = config.write_classes;
|
||||
}
|
||||
|
||||
void add(String name, byte[] def){
|
||||
try {
|
||||
Files.createDirectories(Path.of("build/modified/generators/" + name.replace(".", "/")).getParent());
|
||||
Files.write(Path.of("build/modified/generators/" + name.replace(".", "/") + ".class"), def);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
if(write_classes_path!=null){
|
||||
try {
|
||||
Files.createDirectories(Path.of(write_classes_path + name.replace(".", "/")).getParent());
|
||||
Files.write(Path.of(write_classes_path + name.replace(".", "/") + ".class"), def);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
customClazzMap.put(name, defineClass(name, def, 0, def.length));
|
||||
}
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.parkertenbroeck.bcms.loadtime.future;
|
||||
package com.parkertenbroeck.bcsm.loadtime.future;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package com.parkertenbroeck.bcms.loadtime.future;
|
||||
package com.parkertenbroeck.bcsm.loadtime.future;
|
||||
|
||||
import com.parkertenbroeck.future.Future;
|
||||
import com.parkertenbroeck.future.Waker;
|
||||
import com.parkertenbroeck.bcms.loadtime.*;
|
||||
import com.parkertenbroeck.bcsm.loadtime.*;
|
||||
|
||||
import java.lang.classfile.*;
|
||||
import java.lang.classfile.instruction.SwitchCase;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package com.parkertenbroeck.bcms.loadtime.gen;
|
||||
package com.parkertenbroeck.bcsm.loadtime.gen;
|
||||
|
||||
import com.parkertenbroeck.generator.Gen;
|
||||
import com.parkertenbroeck.bcms.loadtime.*;
|
||||
import com.parkertenbroeck.bcsm.loadtime.*;
|
||||
|
||||
import java.lang.classfile.*;
|
||||
import java.lang.constant.ClassDesc;
|
||||
Loading…
Add table
Add a link
Reference in a new issue