mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-07 05:08:51 -04:00
made generators have better class names
This commit is contained in:
parent
84fdaeb430
commit
10d07e2c80
4 changed files with 15 additions and 1 deletions
|
|
@ -66,6 +66,17 @@ public class Examples {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static Gen<Double, Void> test(double[] nyas){
|
public static Gen<Double, Void> test(double[] nyas){
|
||||||
|
|
||||||
|
var test = 1+switch(nyas[0]){
|
||||||
|
case 1.0 -> {
|
||||||
|
Gen.yield(11);
|
||||||
|
yield 2;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
Gen.yield(12);
|
||||||
|
yield 4;
|
||||||
|
}
|
||||||
|
};
|
||||||
for(var d : nyas){
|
for(var d : nyas){
|
||||||
Gen.yield(d);
|
Gen.yield(d);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ public class Main implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
var gen = Lexer.parse("f7(x,y,z,w, u,v, othersIg) = v-(x*y+y+ln(z)^2*sin(z*pi/2))/(w*u)+sqrt(othersIg*120e-1)");
|
var gen = Lexer.parse("f7(x,y,z,w, u,v, othersIg) = v-(x*y+y+ln(z)^2*sin(z*pi/2))/(w*u)+sqrt(othersIg*120e-1)");
|
||||||
|
// var gen = Examples.test(new double[]{1,2,3,4});
|
||||||
while(gen.next() instanceof Gen.Yield(var tok)) {
|
while(gen.next() instanceof Gen.Yield(var tok)) {
|
||||||
System.out.println(tok);
|
System.out.println(tok);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public class GeneratorBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateStateMachine(ClassBuilder clb, CodeBuilder cob, CodeModel com){
|
private void generateStateMachine(ClassBuilder clb, CodeBuilder cob, CodeModel com){
|
||||||
|
|
||||||
var stateSwitchCases = new ArrayList<SwitchCase>();
|
var stateSwitchCases = new ArrayList<SwitchCase>();
|
||||||
var invalidState = cob.newLabel();
|
var invalidState = cob.newLabel();
|
||||||
stateSwitchCases.add(SwitchCase.of(0, cob.newLabel()));
|
stateSwitchCases.add(SwitchCase.of(0, cob.newLabel()));
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ public class GeneratorClassLoader extends ClassLoader {
|
||||||
if (!mem.flags().has(AccessFlag.STATIC)) {
|
if (!mem.flags().has(AccessFlag.STATIC)) {
|
||||||
mts = mts.insertParameterTypes(0, clm.thisClass().asSymbol());
|
mts = mts.insertParameterTypes(0, clm.thisClass().asSymbol());
|
||||||
}
|
}
|
||||||
var gb = new GeneratorBuilder("Gen" + customClazzDefMap.size(), mts.parameterArray());
|
var name = "Gen_" + clm.thisClass().name().stringValue() + "_" + mem.methodName().stringValue() + "_" + customClazzDefMap.size();
|
||||||
|
var gb = new GeneratorBuilder(name, mts.parameterArray());
|
||||||
mb.withCode(gb::buildGeneratorMethodShim);
|
mb.withCode(gb::buildGeneratorMethodShim);
|
||||||
addGenerator(gb.CD_this_gen.displayName(), gb.buildGenerator(com));
|
addGenerator(gb.CD_this_gen.displayName(), gb.buildGenerator(com));
|
||||||
} else mb.with(me);
|
} else mb.with(me);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue