Class: Burn::Generator::TelnetVm

Inherits:
Object
  • Object
show all
Includes:
Debug, Telnet
Defined in:
lib/burn/generator/telnet_vm.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debug

#log

Constructor Details

#initialize(source, conf) ⇒ TelnetVm

Returns a new instance of TelnetVm.



9
10
11
12
13
14
15
16
17
18
# File 'lib/burn/generator/telnet_vm.rb', line 9

def initialize(source, conf)
  @pc = 0 # Program Counter
  @screen = Screen.new(conf)
  @wait = 10
  @opcodes = JitCompiler.new.compile(source) # compiled methods
  log @opcodes.join(":::")
  @user_input = UserInput.new(conf)
  @conf = conf
  @finish = false
end

Instance Attribute Details

#screenObject (readonly)

Returns the value of attribute screen.



6
7
8
# File 'lib/burn/generator/telnet_vm.rb', line 6

def screen
  @screen
end

#waitObject

Returns the value of attribute wait.



7
8
9
# File 'lib/burn/generator/telnet_vm.rb', line 7

def wait
  @wait
end

Instance Method Details

#interrupt(signal) ⇒ Object



43
44
45
46
# File 'lib/burn/generator/telnet_vm.rb', line 43

def interrupt(signal)
  log "INTTERUPT_SETTING:" + @conf.app.user_input.to_s
  @user_input.receive_signal(signal)
end

#next_frameObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/burn/generator/telnet_vm.rb', line 20

def next_frame
  log @pc
  if @wait > 0 then
    @wait = @wait - 1
  elsif !@finish then
    log @user_input
    if @opcodes[@pc] != "#END" && (@opcodes.count-1) > @pc then
      @pc = @pc+1
      # skipping comment out to speed up
      while @opcodes[@pc-1][0] == '#' do
        @pc = @pc+1
      end
      log @opcodes[@pc-1]
      self.instance_eval @opcodes[@pc-1]
    else
      log "Program counter reached at the end of program. #END"
      @finish = true
    end
  else # if @finish == true then
    # do nothing
  end
end