minute read
Compiler
You are reading our Automation1 API documentation for the .NET programming language.
In the .NET API, Compiler lets you compile AeroScript source code into compiled AeroScript programs and compiled AeroScript libraries.
The Basics
In general, you do not need to use the Controller.Compiler property. If you want to run an AeroScript program, you can use the Controller.Runtime.Tasks.Program.Run method with either an AeroScript source file or a compiled AeroScript program. However, you can use the Controller.Compiler property to compile AeroScript programs ahead of time or to compile AeroScript libraries. See the Tasks page.
How to Use
When you compile AeroScript source with the Controller.Compiler property, you receive a CompiledAeroScript object. Unlike compiling in other programming languages, compiling AeroScript through the .NET API never writes the resulting compiled AeroScript to a file. Instead, you must write the bytes of the resulting compiled AeroScript program or AeroScript library to a file. Refer to the example that follows.
CompiledAeroScript controller.Compiler.CompileControllerFile(string controllerFileName);
CompiledAeroScript controller.Compiler.CompileTextAsLibrary(string textAeroScriptLibrarySource);
CompiledAeroScript controller.Compiler.CompileTextAsProgram(string textAeroScriptProgramSource);
You can use the CompiledAeroScript object with the Controller.Runtime.Tasks property to run the resulting compiled AeroScript program. Or you can write the compiled result to a controller file by using the Controller.Files property and the CompiledAeroScript.CompiledBytes property. See the Files page.
Thread Safety
All the methods and properties that operate under the Controller.Compiler property are thread safe. You can call them from two or more threads without interference.
All the methods and properties on the CompiledAeroScript class are thread safe. You can call them from two or more threads without interference.
Full Reference
For more information about the methods that are available for Compiler, refer to the list that follows.
Controller.Compiler Methods
Compiles the specified controller file as an AeroScript source file and returns the compiled AeroScript program or library. If the file fails to compile, a CompileException is thrown, which contains the list of compiler errors (the CompileException.CompilerErrors property).
controllerFileName: The controller file to compile as an AeroScript source file.
Returns: A CompiledAeroScript object that is the compiled AeroScript program or library.
Compiles the specified controller file as an AeroScript source file and returns the compiled AeroScript program or library. If the file fails to compile, a CompileException is thrown, which contains the list of compiler errors (the CompileException.CompilerErrors property).
controllerFileName: The controller file to compile as an AeroScript source file.
compileWithDebugInformation: Whether or not to compile the specified controller file with debug information.
Returns: A CompiledAeroScript object that is the compiled AeroScript program or library.
Compiles the specified text as a library and returns the compiled AeroScript library. If the text fails to compile, a CompileException is thrown, which contains the list of compiler errors (the CompileException.CompilerErrors property).
textAeroScriptLibrarySource: The text to compile as an AeroScript library.
Returns: A CompiledAeroScript object that is the compiled AeroScript library.
Compiles the specified text as a program and returns the compiled AeroScript program. If the text fails to compile, a CompileException is thrown, which contains the list of compiler errors (the CompileException.CompilerErrors property).
textAeroScriptProgramSource: The text to compile as an AeroScript program.
Returns: A CompiledAeroScript object that is the compiled AeroScript program.