Class JavaSourceFileCoder
java.lang.Object
simula.compiler.JavaSourceFileCoder
Java source-file coder.
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal BlockDeclaration
Given as argument.private int
Current Java line numberprivate JavaSourceFileCoder
The enclosing JavaSourceFileCoderprivate 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.private final Writer
The underlying Java output writer. -
Constructor Summary
ConstructorsConstructorDescriptionJavaSourceFileCoder
(BlockDeclaration blockDeclaration) Create a new JavaSourceFileCoder. -
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.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
-
enclosingJavaCoder
The enclosing JavaSourceFileCoder -
writer
The underlying Java output writer. -
lineMap
-
javaOutputFile
The output file for generated Java code. -
blockDeclaration
Given as argument. Class, Procedure, Prefixed Block or Sub-Block. -
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
-
JavaSourceFileCoder
Create a new JavaSourceFileCoder.- 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
-
write
-
edLineNumberLine
-
edIndent
-
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
-