Class: CodeTools::Compiler::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/rubinius/code/compiler/stages.rb

Direct Known Subclasses

Bytecode, Encoder, Packager, Parser, Printer, Writer

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(compiler, last) ⇒ Stage

Returns a new instance of Stage.



27
28
29
# File 'lib/rubinius/code/compiler/stages.rb', line 27

def initialize(compiler, last)
  @next_stage = create_next_stage compiler, last
end

Instance Attribute Details

#next_stageObject

Returns the value of attribute next_stage.



8
9
10
# File 'lib/rubinius/code/compiler/stages.rb', line 8

def next_stage
  @next_stage
end

#printerObject

Returns the value of attribute printer.



8
9
10
# File 'lib/rubinius/code/compiler/stages.rb', line 8

def printer
  @printer
end

Class Method Details

.next_stage(klass) ⇒ Object



19
20
21
# File 'lib/rubinius/code/compiler/stages.rb', line 19

def self.next_stage(klass)
  @next_stage_class = klass
end

.next_stage_classObject



23
24
25
# File 'lib/rubinius/code/compiler/stages.rb', line 23

def self.next_stage_class
  @next_stage_class
end

.stage(name) ⇒ Object



10
11
12
13
# File 'lib/rubinius/code/compiler/stages.rb', line 10

def self.stage(name)
  @stage = name
  Stages[name] = self
end

.stage_nameObject



15
16
17
# File 'lib/rubinius/code/compiler/stages.rb', line 15

def self.stage_name
  @stage
end

Instance Method Details

#create_next_stage(compiler, last) ⇒ Object



39
40
41
42
43
44
# File 'lib/rubinius/code/compiler/stages.rb', line 39

def create_next_stage(compiler, last)
  return if self.class.stage_name == last

  stage = self.class.next_stage_class
  stage.new compiler, last if stage
end

#input(data) ⇒ Object



31
32
33
# File 'lib/rubinius/code/compiler/stages.rb', line 31

def input(data)
  @input = data
end

#insert(stage) ⇒ Object



46
47
48
# File 'lib/rubinius/code/compiler/stages.rb', line 46

def insert(stage)
  @next_stage, stage.next_stage = stage.next_stage, self
end

#processor(klass) ⇒ Object



35
36
37
# File 'lib/rubinius/code/compiler/stages.rb', line 35

def processor(klass)
  @processor = klass
end

#run_nextObject



50
51
52
53
54
55
56
57
# File 'lib/rubinius/code/compiler/stages.rb', line 50

def run_next
  if @next_stage
    @next_stage.input @output
    @next_stage.run
  else
    @output
  end
end