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 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.
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
Modifier and TypeFieldDescriptionprivate String
Main entry name.private File
The output .jar fileprivate ProgramModule
The ProgramModule.private final Reader
The Reader in case of SimulaEditor. -
Constructor Summary
ConstructorDescriptionSimulaCompiler
(String inputFileName) Create a new SimulaCompiler.SimulaCompiler
(String inputFileName, Reader reader) Create a new SimulaCompiler. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
add
(JarOutputStream target, File source, int pathSize) Add directory or a file to a JarOutputStream.private int
callJavacCompiler
(String classPath) Call Java command line compiler.private int
callJavaSystemCompiler
(JavaCompiler compiler, String classPath) Call Java system compilerprivate String
createJarFile
(ProgramModule program) Create .jar file.private void
deleteTempFiles
(File dir) Delete temporary .class files.void
Do Compilestatic void
doListClassFile
(String classFileName) Print a .class file listing.static int
Execute an OS commandprivate static int
Execute OS Commandprivate void
File Summaryprivate void
List temp class file directory treeprivate void
List a directory tree.private static void
listJarFile
(File file) List .jar fileprivate void
Print summary at program end.
-
Field Details
-
reader
The Reader in case of SimulaEditor. -
programModule
The ProgramModule. -
outputJarFile
The output .jar file -
mainEntry
Main entry name.
-
-
Constructor Details
-
SimulaCompiler
Create a new SimulaCompiler.- Parameters:
inputFileName
- the source file name
-
SimulaCompiler
Create a new SimulaCompiler.- Parameters:
inputFileName
- the source file namereader
- Reader in case of SimulaEditor
-
-
Method Details
-
list
List temp class file directory tree- Parameters:
dir
- tempClassFileDir
-
list
List a directory tree.- Parameters:
indent
- the indentationdir
- the directory
-
deleteTempFiles
Delete temporary .class files.- Parameters:
dir
- temporary .class directory
-
doCompile
public void doCompile()Do Compile -
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
- Throws:
IOException
- if something went wrong
-
createJarFile
Create .jar file.- Parameters:
program
- the ProgramModule- Returns:
- .jar file name
- Throws:
IOException
- if something went wrong
-
add
Add directory or a file to a JarOutputStream.- Parameters:
target
- the JarOutputStreamsource
- source file or directorypathSize
- the path size- Throws:
IOException
- if something went wrong
-
fileSummary
private void fileSummary()File Summary -
printSummary
private void printSummary()Print summary at program end. -
listJarFile
List .jar file- Parameters:
file
- the .jar file
-
doListClassFile
Print a .class file listing.- Parameters:
classFileName
- the .class file name
-
execute
Execute OS Command- Parameters:
cmd
- command vector- Returns:
- return value from the OS
- Throws:
IOException
- if something went wrong
-
execute
Execute an OS command- Parameters:
cmdarray
- command array- Returns:
- exit value
- Throws:
IOException
- if an I/O error occurs
-