Class SimulaCompiler
java.lang.Object
simula.compiler.SimulaCompiler
The Simula Compiler.
The compiler consists of the following steps:
- Initiate global variables.
- Do Parsing: Read source file through the scanner building program syntax tree.
- Do Checking: Traverse the syntax tree performing semantic checking.
- Do Coding dependent on the CompilerMode:
- CompilerMode = viaJavaSource:
- Do JavaCoding: Traverse the syntax tree generating .java code.
- Call Java Compiler to generate .class files.
- Do ByteCodeEngineering updating .class files.
- Create executable .jar of program.
- Execute .jar file.
- CompilerMode = directClassFiles:
- Traverse the syntax tree generating ClassFile code.
- Create executable .jar of program.
- Execute .jar file.
- CompilerMode = simulaClassLoader:
- Traverse the syntax tree generate and load ClassFile code.
- Run the loaded program
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File
The output .jar fileprivate ProgramModule
The ProgramModule.private final Reader
The Reader in case of SimulaEditor. -
Constructor Summary
ConstructorsConstructorDescriptionSimulaCompiler
(String inputFileName) Create a new SimulaCompiler.SimulaCompiler
(String inputFileName, Reader reader) Create a new SimulaCompiler. -
Method Summary
Modifier and TypeMethodDescriptionprivate int
callJavacCompiler
(String classPath) Call Java command line compiler.private int
callJavaSystemCompiler
(JavaCompiler compiler, String classPath) Call Java system compilerprivate void
deleteTempFiles
(File dir) Delete temporary .class files.private void
Possible doByteCodeEngineering reintroducing labels and goto.private void
Call Java compiler 'javac'void
Do Compileprivate void
doExecuteJarFile
(String jarFile, Vector<String> arg) Execute JarFile.private void
File Summaryprivate void
List temp class file directory treeprivate void
List a directory tree.private void
Debug utility: listGeneratedClassFiles.private void
Print summary at program end.
-
Field Details
-
reader
The Reader in case of SimulaEditor. -
programModule
The ProgramModule. -
outputJarFile
The output .jar file
-
-
Constructor Details
-
SimulaCompiler
Create a new SimulaCompiler.- Parameters:
inputFileName
- the source file name
-
SimulaCompiler
-
-
Method Details
-
list
-
list
-
deleteTempFiles
Delete temporary .class files.- Parameters:
dir
- temporary .class directory
-
doCompile
-
doExecuteJarFile
Execute JarFile.- Parameters:
jarFile
- a jarFilearg
- the arguments- Throws:
IOException
- if something went wrong.
-
doCallJavaCompiler
Call Java compiler 'javac'- Throws:
IOException
- if something went wrong.
-
callJavaSystemCompiler
Call Java system compiler- Parameters:
compiler
- the Java compilerclassPath
- the classPath- Returns:
- return value from the Java compiler
- Throws:
IOException
- if something went wrong
-
callJavacCompiler
Call Java command line compiler.- Parameters:
classPath
- the classPath- Returns:
- return value from the Java compiler
-
doByteCodeEngineering
Possible doByteCodeEngineering reintroducing labels and goto.- Throws:
IOException
- if something went wrong.
-
listGeneratedClassFiles
private void listGeneratedClassFiles()Debug utility: listGeneratedClassFiles. -
fileSummary
private void fileSummary()File Summary -
printSummary
private void printSummary()Print summary at program end.
-