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 FileThe output .jar fileprivate ProgramModuleThe ProgramModule.private final ReaderThe Reader in case of SimulaEditor. -
Constructor Summary
ConstructorsConstructorDescriptionSimulaCompiler(String inputFileName, Reader reader) Create a new SimulaCompiler. -
Method Summary
Modifier and TypeMethodDescriptionprivate intcallJavacCompiler(String classPath) Call Java command line compiler.private intcallJavaSystemCompiler(JavaCompiler compiler, String classPath) Call Java system compilerprivate voiddeleteTempFiles(File dir) Delete temporary .class files.private voidPossible doByteCodeEngineering reintroducing labels and goto.private voidCall Java compiler 'javac'voidDo Compileprivate voiddoExecuteJarFile(String jarFile, Vector<String> arg) Execute JarFile.private voidFile Summaryprivate voidList temp class file directory treeprivate voidList a directory tree.private voidDebug utility: listGeneratedClassFiles.private voidPrint summary at program end.
-
Field Details
-
reader
The Reader in case of SimulaEditor. -
programModule
The ProgramModule. -
outputJarFile
The output .jar file
-
-
Constructor Details
-
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.
-