Module Simula

Class GeneratedJavaClass

java.lang.Object
simula.compiler.GeneratedJavaClass

public final class GeneratedJavaClass extends Object
Generated Java class.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • enclosingJavaModule

      private GeneratedJavaClass enclosingJavaModule
      The enclosing JavaModule
    • writer

      private final Writer writer
      The Java output writer.
    • lineMap

      private final Vector<Integer> lineMap
      The line number map
    • javaOutputFile

      final File javaOutputFile
      The output file for generated Java code.
    • blockDeclaration

      public final BlockDeclaration blockDeclaration
      Given as argument.
    • saveCode

      public Vector<CodeLine> saveCode
      Used during coding to save the generated code.
    • mustDoByteCodeEngineering

      public boolean mustDoByteCodeEngineering
      Signals that ByteCodeEngineering is necessary.
    • currentJavaLineNumber

      private int currentJavaLineNumber
      Current Java line number
    • prevLineNumber

      private static int prevLineNumber
      Previous source line number.
    • indent

      private int indent
      Current indentation
  • Constructor Details

    • GeneratedJavaClass

      public GeneratedJavaClass(BlockDeclaration blockDeclaration)
      Create a new GeneratedJavaClass.
      Parameters:
      blockDeclaration - argument
  • Method Details

    • modid

      private String modid()
      Edit the current module's identification.
      Returns:
      the current module's identification
    • getClassOutputFileName

      String getClassOutputFileName()
      Returns the output file for generated Java code.
      Returns:
      the output file for generated Java code
    • closeJavaOutput

      public void closeJavaOutput()
      Close Java output file.
      Throws:
      RuntimeException - if writing .java output failed
    • debug

      public static void debug(String line)
      Output a debug code line.

      To optimize, it is safe to drop such lines

      Parameters:
      line - a debug code line
    • code

      public static void code(String line)
      Output a code line without comment.
      Parameters:
      line - a code line
    • code

      public static void code(String line, String comment)
      Output a code line with comment.
      Parameters:
      line - a code line
      comment - a comment string
    • code

      public static void code(CodeLine c)
      Output a code line.
      Parameters:
      c - a code line
    • write

      private void write(int sourceLineNumber, String line, String modid)
      Write a code line to the Java output writer.
      Parameters:
      sourceLineNumber - the source line number
      line - the code line string
      modid - module identifier
    • edLineNumberLine

      private String edLineNumberLine(int simulaLine, String modid)
      Code Utility: Edit line number comment line.

      On the form:

                      // JavaLine currentJavaLineNumber <== SourceLine simulaLine
       
      Parameters:
      simulaLine - Simula line number
      modid - the module identifier
      Returns:
      the resulting Java source line
    • edIndent

      private String edIndent()
      Utility: Edit indent string
      Returns:
      the indent string
    • appendLine

      private void appendLine(int javaLine, int simulaLine)
      Append an entry to the line map.
      Parameters:
      javaLine - the Java line number
      simulaLine - the simula line number
    • codeProgramInfo

      public void codeProgramInfo()
      Output program info. I.e. identifier and lineMap.
    • writeCode

      private void writeCode(String s)
      Write a code line to the Java output writer.
      Parameters:
      s - the code line string
    • toString

      public String toString()
      Overrides:
      toString in class Object