Class SimulaCodeTransform

java.lang.Object
simula.compiler.transform.SimulaCodeTransform
All Implemented Interfaces:
ClassFileTransform<CodeTransform, CodeElement, CodeBuilder>, CodeTransform

final class SimulaCodeTransform extends Object implements 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 CodeElements 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