java.lang.Object
simula.compiler.GeneratedJavaClass
Generated Java class.
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
Modifier and TypeFieldDescriptionfinal BlockDeclaration
Given as argument.private int
Current Java line numberprivate GeneratedJavaClass
The enclosing JavaModuleprivate int
Current indentation(package private) final File
The output file for generated Java code.The line number mapboolean
Signals that ByteCodeEngineering is necessary.private static int
Previous source line number.Used during coding to save the generated code.private final Writer
The Java output writer. -
Constructor Summary
ConstructorDescriptionGeneratedJavaClass
(BlockDeclaration blockDeclaration) Create a new GeneratedJavaClass. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
appendLine
(int javaLine, int simulaLine) Append an entry to the line map.void
Close Java output file.static void
Output a code line without comment.static void
Output a code line with comment.static void
Output a code line.void
Output program info.static void
Output a debug code line.private String
edIndent()
Utility: Edit indent stringprivate String
edLineNumberLine
(int simulaLine, String modid) Code Utility: Edit line number comment line.(package private) String
Returns the output file for generated Java code.private String
modid()
Edit the current module's identification.toString()
private void
Write a code line to the Java output writer.private void
Write a code line to the Java output writer.
-
Field Details
-
enclosingJavaModule
The enclosing JavaModule -
writer
The Java output writer. -
lineMap
The line number map -
javaOutputFile
The output file for generated Java code. -
blockDeclaration
Given as argument. -
saveCode
Used during coding to save the generated code. -
mustDoByteCodeEngineering
public boolean mustDoByteCodeEngineeringSignals that ByteCodeEngineering is necessary. -
currentJavaLineNumber
private int currentJavaLineNumberCurrent Java line number -
prevLineNumber
private static int prevLineNumberPrevious source line number. -
indent
private int indentCurrent indentation
-
-
Constructor Details
-
GeneratedJavaClass
Create a new GeneratedJavaClass.- Parameters:
blockDeclaration
- argument
-
-
Method Details
-
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
Output a debug code line.To optimize, it is safe to drop such lines
- Parameters:
line
- a debug code line
-
code
Output a code line without comment.- Parameters:
line
- a code line
-
code
Output a code line with comment.- Parameters:
line
- a code linecomment
- a comment string
-
code
Output a code line.- Parameters:
c
- a code line
-
write
Write a code line to the Java output writer.- Parameters:
sourceLineNumber
- the source line numberline
- the code line stringmodid
- module identifier
-
edLineNumberLine
Code Utility: Edit line number comment line.On the form:
// JavaLine currentJavaLineNumber <== SourceLine simulaLine
- Parameters:
simulaLine
- Simula line numbermodid
- the module identifier- Returns:
- the resulting Java source line
-
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 numbersimulaLine
- the simula line number
-
codeProgramInfo
public void codeProgramInfo()Output program info. I.e. identifier and lineMap. -
writeCode
Write a code line to the Java output writer.- Parameters:
s
- the code line string
-
toString
-