Class: CIAT::Compilers::Java
- Inherits:
-
Object
- Object
- CIAT::Compilers::Java
- Includes:
- Differs::HtmlDiffer, Processors::BasicProcessing
- Defined in:
- lib/ciat/compilers/java.rb
Overview
Implements a processor written in Java.
It requires source
and compilation
elements.
-
source
is used as source to the Java compiler. -
compilation
is used for comparsion.
Best Practices
Suppose you use Eclipse to develop your compiler or interpreter, and you have this folder structure:
-
bin
stores your compiled classes (under test) -
lib
contains support JAR files -
acceptance
is a root folder for your CIAT tests with yourRakefile
You may find this classpath useful:
Dir.glob('../lib/*.jar').join(':') + ":../bin"
Instance Attribute Summary collapse
-
#light ⇒ Object
The traffic light to indicate the success or failure of the processor.
-
#processor_kind ⇒ Object
readonly
Returns the value of attribute processor_kind.
Instance Method Summary collapse
-
#describe ⇒ Object
Return a description of the processor.
- #executable ⇒ Object
-
#initialize(classpath, compiler_class, options = {}) ⇒ Java
constructor
Constructs a “Java compiler” object.
Methods included from Differs::HtmlDiffer
Methods included from Processors::BasicProcessing
#command_line_args, #diff, #error_file, #execute, #for_test, #input_file, #output_file, #process, #relevant_element_names, #relevant_elements
Constructor Details
#initialize(classpath, compiler_class, options = {}) ⇒ Java
Constructs a “Java compiler” object. classpath
is the complete classpath to execute the compiler. compiler_class
is the fully qualified name of the class that executes your compiler; this driver should take two command-line arguments: the name of the source file and the name of the generated target-code file.
Possible options:
-
description
specifies a descriptive name for your compiler; used in the HTML report.
35 36 37 38 39 40 41 42 |
# File 'lib/ciat/compilers/java.rb', line 35 def initialize(classpath, compiler_class, ={}) @processor_kind = [:processor_kind] || CIAT::Processors::Compiler.new @classpath = classpath @compiler_class = compiler_class @descriptions = {} @description = [:description] || "compiler (implemented in Java)" @light = [:light] || TrafficLight.new end |
Instance Attribute Details
#light ⇒ Object
The traffic light to indicate the success or failure of the processor.
23 24 25 |
# File 'lib/ciat/compilers/java.rb', line 23 def light @light end |
#processor_kind ⇒ Object (readonly)
Returns the value of attribute processor_kind.
24 25 26 |
# File 'lib/ciat/compilers/java.rb', line 24 def processor_kind @processor_kind end |
Instance Method Details
#describe ⇒ Object
Return a description of the processor.
45 46 47 |
# File 'lib/ciat/compilers/java.rb', line 45 def describe @description end |
#executable ⇒ Object
49 50 51 |
# File 'lib/ciat/compilers/java.rb', line 49 def executable "java -cp '#{@classpath}' #{@compiler_class}" end |