Class WasmStructuredControlflowCodeGenerator
- java.lang.Object
-
- de.mirkosertic.bytecoder.core.backend.wasm.WasmStructuredControlflowCodeGenerator
-
- All Implemented Interfaces:
StructuredControlflowCodeGenerator
public class WasmStructuredControlflowCodeGenerator extends java.lang.Object implements StructuredControlflowCodeGenerator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
WasmStructuredControlflowCodeGenerator.LambdaInstance
(package private) static class
WasmStructuredControlflowCodeGenerator.NestingLevel<T extends Container>
(package private) static class
WasmStructuredControlflowCodeGenerator.NestingLevelBlock
(package private) static class
WasmStructuredControlflowCodeGenerator.NestingLevelIff
(package private) static class
WasmStructuredControlflowCodeGenerator.NestingLevelLoop
(package private) static class
WasmStructuredControlflowCodeGenerator.NestingLevelSwitch
(package private) static class
WasmStructuredControlflowCodeGenerator.NestingLevelTry
-
Field Summary
-
Constructor Summary
Constructors Constructor Description WasmStructuredControlflowCodeGenerator(CompileUnit compileUnit, Module module, java.util.Map<ResolvedClass,StructType> rtMappings, java.util.Map<ResolvedClass,StructType> objectTypeMappings, ExportableFunction exportableFunction, java.util.function.Function<org.objectweb.asm.Type,WasmType> typeConverter, java.util.function.Function<ResolvedMethod,FunctionType> functionTypeConverter, MethodToIDMapper methodToIDMapper, Graph graph, java.util.List<ResolvedClass> resolvedClasses, VTableResolver vTableResolver, GeneratedMethodsRegistry generatedMethodsRegistry)
-
Method Summary
-
-
-
Field Detail
-
compileUnit
private final CompileUnit compileUnit
-
module
private final Module module
-
objectTypeMappings
private final java.util.Map<ResolvedClass,StructType> objectTypeMappings
-
rtMappings
private final java.util.Map<ResolvedClass,StructType> rtMappings
-
exportableFunction
private final ExportableFunction exportableFunction
-
typeConverter
private final java.util.function.Function<org.objectweb.asm.Type,WasmType> typeConverter
-
functionTypeConverter
private final java.util.function.Function<ResolvedMethod,FunctionType> functionTypeConverter
-
methodToIDMapper
private final MethodToIDMapper methodToIDMapper
-
varLocalMap
private final java.util.Map<AbstractVar,Local> varLocalMap
-
activeLevel
private WasmStructuredControlflowCodeGenerator.NestingLevel<?> activeLevel
-
graph
private final Graph graph
-
resolvedClasses
private final java.util.List<ResolvedClass> resolvedClasses
-
vTableResolver
private final VTableResolver vTableResolver
-
generatedMethodsRegistry
private final GeneratedMethodsRegistry generatedMethodsRegistry
-
lambdaCounter
static int lambdaCounter
-
generatedEquals
int generatedEquals
-
ifcounter
int ifcounter
-
catchcheckcount
int catchcheckcount
-
tableSwitchCount
int tableSwitchCount
-
lookupSwitchCount
int lookupSwitchCount
-
checkcounter
int checkcounter
-
-
Constructor Detail
-
WasmStructuredControlflowCodeGenerator
public WasmStructuredControlflowCodeGenerator(CompileUnit compileUnit, Module module, java.util.Map<ResolvedClass,StructType> rtMappings, java.util.Map<ResolvedClass,StructType> objectTypeMappings, ExportableFunction exportableFunction, java.util.function.Function<org.objectweb.asm.Type,WasmType> typeConverter, java.util.function.Function<ResolvedMethod,FunctionType> functionTypeConverter, MethodToIDMapper methodToIDMapper, Graph graph, java.util.List<ResolvedClass> resolvedClasses, VTableResolver vTableResolver, GeneratedMethodsRegistry generatedMethodsRegistry)
-
-
Method Detail
-
registerVariables
public void registerVariables(java.util.List<AbstractVar> variables)
- Specified by:
registerVariables
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(MethodInvocation invocation)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
writeDirect
private void writeDirect(MethodInvocation node)
-
writeVirtual
private void writeVirtual(MethodInvocation node)
-
writeStatic
private void writeStatic(MethodInvocation node)
-
writeInterface
private void writeInterface(MethodInvocation node)
-
write
public void write(ClassInitialization node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
toWasmValue
private WasmValue toWasmValue(ObjectString value)
-
toWasmValue
private WasmValue toWasmValue(PrimitiveShort value)
-
toWasmValue
private WasmValue toWasmValue(PrimitiveInt value)
-
toWasmValue
private WasmValue toWasmValue(PrimitiveLong value)
-
toWasmValue
private WasmValue toWasmValue(PrimitiveFloat value)
-
toWasmValue
private WasmValue toWasmValue(PrimitiveDouble value)
-
toWasmValue
private WasmValue toWasmValue(MethodArgument value)
-
toWasmValue
private WasmValue toWasmValue(AbstractVar value)
-
toWasmValue
private WasmValue toWasmValue(NullReference value)
-
createNewInstanceOf
public static WasmValue createNewInstanceOf(org.objectweb.asm.Type instanceType, Module module, CompileUnit compileUnit, java.util.Map<ResolvedClass,StructType> objectTypeMappings, java.util.Map<ResolvedClass,StructType> rtMappings, WasmValue externRef)
-
toWasmValue
private WasmValue toWasmValue(ReadInstanceField value)
-
toWasmValue
private WasmValue toWasmValue(MethodInvocationExpression value)
-
toWasmValueStatic
private WasmValue toWasmValueStatic(MethodInvocationExpression value)
-
toWasmValueDirect
private WasmValue toWasmValueDirect(MethodInvocationExpression value)
-
toWasmValueVirtual
private WasmValue toWasmValueVirtual(MethodInvocationExpression value)
-
toWasmValueInterface
private WasmValue toWasmValueInterface(MethodInvocationExpression value)
-
createLambdaInstance
private WasmStructuredControlflowCodeGenerator.LambdaInstance createLambdaInstance(org.objectweb.asm.Type type, ExportableFunction implFunction, java.util.List<StructType.Field> closureFields, java.util.List<WasmValue> closureArguments)
-
generateInvokeDynamicLambdaMetaFactoryInvocation
private WasmValue generateInvokeDynamicLambdaMetaFactoryInvocation(InvokeDynamicExpression node, ResolveCallsite resolveCallsite)
-
generateInvokeDynamicStringMakeConcatWithConstants
private WasmValue generateInvokeDynamicStringMakeConcatWithConstants(InvokeDynamicExpression node, ResolveCallsite resolveCallsite)
-
generateInvokeDynamicObjectMethodsToString
private WasmValue generateInvokeDynamicObjectMethodsToString(InvokeDynamicExpression node, ResolveCallsite resolveCallsite)
-
generateInvokeDynamicObjectMethodsEquals
private WasmValue generateInvokeDynamicObjectMethodsEquals(InvokeDynamicExpression node, ResolveCallsite resolveCallsite)
-
toWasmValue
private WasmValue toWasmValue(InvokeDynamicExpression value)
-
toType
private WasmValue toType(org.objectweb.asm.Type type)
-
toWasmValue
private WasmValue toWasmValue(TypeReference value)
-
toWasmValue
private WasmValue toWasmValue(ReadClassField value)
-
toWasmValue
private WasmValue toWasmValue(RuntimeClass value)
-
toWasmValue
private WasmValue toWasmValue(CaughtException value)
-
toWasmValue
private WasmValue toWasmValue(TypeConversion value)
-
toWasmValue
private WasmValue toWasmValue(InstanceOf value)
-
toInstanceOfCheck
private WasmValue toInstanceOfCheck(WasmValue value, org.objectweb.asm.Type typeToCheck)
-
toWasmValue
private WasmValue toWasmValue(ArrayLength value)
-
toWasmValue
private WasmValue toWasmValue(RuntimeClassOf value)
-
toWasmValue
private WasmValue toWasmValue(EnumValuesOf value)
-
toWasmValue
private WasmValue toWasmValue(Reinterpret value)
-
toWasmValue
private WasmValue toWasmValue(PrimitiveClassReference reference)
-
toWasmValue
private WasmValue toWasmValue(ReferenceTest value)
-
toWasmValue
private WasmValue toWasmValue(NumericalTest value)
-
write
public void write(Copy node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
startIfWithTrueBlock
public void startIfWithTrueBlock(If node)
- Specified by:
startIfWithTrueBlock
in interfaceStructuredControlflowCodeGenerator
-
startIfElseBlock
public void startIfElseBlock(If node)
- Specified by:
startIfElseBlock
in interfaceStructuredControlflowCodeGenerator
-
finishIfBlock
public void finishIfBlock()
- Specified by:
finishIfBlock
in interfaceStructuredControlflowCodeGenerator
-
startBlock
public void startBlock(Sequencer.Block node)
- Specified by:
startBlock
in interfaceStructuredControlflowCodeGenerator
-
finishBlock
public void finishBlock(Sequencer.Block node, boolean stackEmpty)
- Specified by:
finishBlock
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(LineNumberDebugInfo node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(FrameDebugInfo node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(Goto node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(MonitorEnter node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(MonitorExit node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(Unwind node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(Return node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(ReturnValue node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(SetInstanceField node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(SetClassField node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
write
public void write(ArrayStore node)
- Specified by:
write
in interfaceStructuredControlflowCodeGenerator
-
writeBreakTo
public void writeBreakTo(java.lang.String label)
- Specified by:
writeBreakTo
in interfaceStructuredControlflowCodeGenerator
-
writeContinueTo
public void writeContinueTo(java.lang.String label)
- Specified by:
writeContinueTo
in interfaceStructuredControlflowCodeGenerator
-
startTryCatch
public void startTryCatch(java.lang.String label)
- Specified by:
startTryCatch
in interfaceStructuredControlflowCodeGenerator
-
startCatchBlock
public void startCatchBlock()
- Specified by:
startCatchBlock
in interfaceStructuredControlflowCodeGenerator
-
startCatchHandler
public void startCatchHandler(org.objectweb.asm.Type type)
- Specified by:
startCatchHandler
in interfaceStructuredControlflowCodeGenerator
-
finishCatchHandler
public void finishCatchHandler()
- Specified by:
finishCatchHandler
in interfaceStructuredControlflowCodeGenerator
-
writeRethrowException
public void writeRethrowException()
- Specified by:
writeRethrowException
in interfaceStructuredControlflowCodeGenerator
-
finishTryCatch
public void finishTryCatch()
- Specified by:
finishTryCatch
in interfaceStructuredControlflowCodeGenerator
-
startTableSwitch
public void startTableSwitch(TableSwitch node)
- Specified by:
startTableSwitch
in interfaceStructuredControlflowCodeGenerator
-
finishTableSwitch
public void finishTableSwitch()
- Specified by:
finishTableSwitch
in interfaceStructuredControlflowCodeGenerator
-
startTableSwitchDefaultBlock
public void startTableSwitchDefaultBlock()
- Specified by:
startTableSwitchDefaultBlock
in interfaceStructuredControlflowCodeGenerator
-
finishTableSwitchDefaultBlock
public void finishTableSwitchDefaultBlock()
- Specified by:
finishTableSwitchDefaultBlock
in interfaceStructuredControlflowCodeGenerator
-
startLookupSwitch
public void startLookupSwitch(LookupSwitch node)
- Specified by:
startLookupSwitch
in interfaceStructuredControlflowCodeGenerator
-
finishLookupSwitch
public void finishLookupSwitch()
- Specified by:
finishLookupSwitch
in interfaceStructuredControlflowCodeGenerator
-
writeSwitchCase
public void writeSwitchCase(int index)
- Specified by:
writeSwitchCase
in interfaceStructuredControlflowCodeGenerator
-
writeSwitchDefaultCase
public void writeSwitchDefaultCase()
- Specified by:
writeSwitchDefaultCase
in interfaceStructuredControlflowCodeGenerator
-
finishSwitchDefault
public void finishSwitchDefault()
- Specified by:
finishSwitchDefault
in interfaceStructuredControlflowCodeGenerator
-
finishSwitchCase
public void finishSwitchCase()
- Specified by:
finishSwitchCase
in interfaceStructuredControlflowCodeGenerator
-
-