Class SimulaCodeTransform
java.lang.Object
simula.compiler.transform.SimulaCodeTransform
- All Implemented Interfaces:
ClassFileTransform<CodeTransform, CodeElement, CodeBuilder>
,CodeTransform
Simula .class file transformer.
To easily modify the code, the Simula Compiler generates certain method call in the .java file:
Process the stream of CodeElement
s looking for two particular code sequences:
CASE 1: Repair the JUMPTABLE(_JTX, n).
This method-call is a placeholder for where to put in a Jump-Table.
The parameter 'n' is the number of cases.
JUMPTABLE will always occur before any any labels.
Locate the instruction sequence:
... any instruction(s) GETFIELD _JTX ICONST n or BIPUSH or SIPUSH INVOKESTATIC _JUMPTABLE
Replace it by:
... any instruction(s) GETFIELD _JTX TABLESWITCH ... uses 'n' labels which is binded later.
CASE 2: Repair a LABEL(n).
This method-call is used to signal the occurrence of a Simula Label.
The label 'n' in the TABLESWITCH is binded.
Locate the instruction sequence:
ICONST n or BIPUSH or SIPUSH INVOKESTATIC _SIM_LABEL NEXT-INSTRUCTION
Replace it by:
PREV-INSTRUCTION LABELBINDING( case n ) NEXT-INSTRUCTION
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<SwitchCase> The switch cases.private CodeElement
The previous CodeElementFields inherited from interface java.lang.classfile.CodeTransform
ACCEPT_ALL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(CodeBuilder builder, CodeElement element) void
atEnd
(CodeBuilder builder) private int
getConst
(CodeElement element) ConstantInstruction: ICONST n or BIPUSH or SIPUSHtoString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.classfile.ClassFileTransform
atStart
Methods inherited from interface java.lang.classfile.CodeTransform
andThen
-
Field Details
-
cases
The switch cases. -
prevElement
The previous CodeElement
-
-
Constructor Details
-
SimulaCodeTransform
SimulaCodeTransform()Default Constructor.
-
-
Method Details
-
atEnd
- Specified by:
atEnd
in interfaceClassFileTransform<CodeTransform, CodeElement, CodeBuilder>
-
accept
- Specified by:
accept
in interfaceClassFileTransform<CodeTransform, CodeElement, CodeBuilder>
-
getConst
ConstantInstruction: ICONST n or BIPUSH or SIPUSH- Parameters:
element
- a CodeElement: ICONST n or BIPUSH or SIPUSH- Returns:
- the integer constant value
- Throws:
RuntimeException
- if something went wrong
-
toString
-