mirror of
https://github.com/PeterCamilleri/fOOrth
synced 2024-11-16 07:47:56 +01:00
Added the dbg_puts method for debug output.
This commit is contained in:
parent
fdf152bd76
commit
688e1806f5
7 changed files with 33 additions and 14 deletions
|
@ -52,7 +52,7 @@ module XfOOrth
|
|||
|
||||
#Append text to the compile buffer.
|
||||
def <<(text)
|
||||
puts " Append=#{text.inspect}" if @debug
|
||||
dbg_puts " Append=#{text.inspect}"
|
||||
@buffer << text
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module XfOOrth
|
|||
#<br>Note:
|
||||
#* Adds a nested context level to be un-nested at a later point.
|
||||
def begin_compile_mode(ctrl, defs={}, &action)
|
||||
puts " begin_compile_mode" if debug
|
||||
dbg_puts " begin_compile_mode"
|
||||
@context.check_set(:mode, [:execute])
|
||||
@context = Context.new(@context, mode: :compile, ctrl: ctrl, action: action)
|
||||
@context.merge(defs)
|
||||
|
@ -29,7 +29,7 @@ module XfOOrth
|
|||
#<br>Note:
|
||||
#* Un-nests a context level.
|
||||
def end_compile_mode(ctrls, tags)
|
||||
puts " end_compile_mode" if debug
|
||||
dbg_puts " end_compile_mode"
|
||||
@context.check_set(:ctrl, ctrls)
|
||||
source, @buffer = "lambda {|vm| #{@buffer} }", nil
|
||||
result = instance_exec(self, source, tags, &@context[:action])
|
||||
|
@ -43,7 +43,7 @@ module XfOOrth
|
|||
#<br>Note:
|
||||
#* Adds a nested context level to be un-nested at a later point.
|
||||
def suspend_compile_mode(ctrl)
|
||||
puts " suspend_compile_mode" if debug
|
||||
dbg_puts " suspend_compile_mode"
|
||||
@context.check_set(:mode, [:compile])
|
||||
@context = Context.new(@context, mode: :execute, ctrl: ctrl)
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ module XfOOrth
|
|||
#<br>Note:
|
||||
#* Un-nests a context level.
|
||||
def resume_compile_mode(ctrls)
|
||||
puts " resume_compile_mode" if debug
|
||||
dbg_puts " resume_compile_mode"
|
||||
@context.check_set(:ctrl, ctrls)
|
||||
@context = @context.previous
|
||||
end
|
||||
|
@ -69,7 +69,7 @@ module XfOOrth
|
|||
#<br>Note:
|
||||
#* Adds a nested context level to be un-nested at a later point.
|
||||
def suspend_execute_mode(text, ctrl)
|
||||
puts " suspend_execute_mode" if debug
|
||||
dbg_puts " suspend_execute_mode"
|
||||
@context = Context.new(@context, ctrl: ctrl)
|
||||
|
||||
if @context[:mode] == :execute
|
||||
|
@ -98,7 +98,7 @@ module XfOOrth
|
|||
#<br>Note:
|
||||
#* Un-nests a context level.
|
||||
def resume_execute_mode(text, ctrls)
|
||||
puts " resume_execute_mode" if debug
|
||||
dbg_puts " resume_execute_mode"
|
||||
check_deferred_mode(text, ctrls)
|
||||
@context = @context.previous
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ module XfOOrth
|
|||
save, @parser = @parser, Parser.new(source)
|
||||
|
||||
while (token = get_token)
|
||||
puts token.to_s if @debug
|
||||
dbg_puts token.to_s
|
||||
code = token.code
|
||||
|
||||
if (@context[:mode] == :execute) || ((token.has_tag?(:immediate)) && (!@force))
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
# coding: utf-8
|
||||
|
||||
require_relative 'debug/display_abort'
|
||||
require_relative 'debug/dbg_puts'
|
||||
|
||||
#Set up the default debug conduit.
|
||||
$foorth_dbg = $stdout
|
||||
|
||||
|
|
15
lib/fOOrth/debug/dbg_puts.rb
Normal file
15
lib/fOOrth/debug/dbg_puts.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# coding: utf-8
|
||||
|
||||
#* dbg_puts.rb - Display diagnostic/debug information if enabled.
|
||||
module XfOOrth
|
||||
|
||||
#* dbg_puts.rb - Display diagnostic/debug information if enabled.
|
||||
class VirtualMachine
|
||||
def dbg_puts(*args)
|
||||
$foorth_dbg.puts(*args) if debug
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -13,7 +13,7 @@ module XfOOrth
|
|||
type = VmSpec
|
||||
|
||||
begin_compile_mode(':', vm: vm, &lambda {|vm, src, tags|
|
||||
puts "#{name} => #{src}" if vm.debug
|
||||
vm.dbg_puts "#{name} => #{src}"
|
||||
target.create_shared_method(name, type, tags, &eval(src))
|
||||
})
|
||||
|
||||
|
@ -30,7 +30,7 @@ module XfOOrth
|
|||
type = XfOOrth.name_to_type(name)
|
||||
|
||||
vm.begin_compile_mode('.:', cls: target, &lambda {|vm, src, tags|
|
||||
puts "#{target.name} #{name} => #{src}" if vm.debug
|
||||
vm.dbg_puts "#{target.foorth_name} #{name} => #{src}"
|
||||
target.create_shared_method(name, type, tags, &eval(src))
|
||||
})
|
||||
|
||||
|
@ -46,7 +46,7 @@ module XfOOrth
|
|||
type = XfOOrth.name_to_type(name)
|
||||
|
||||
vm.begin_compile_mode('.::', obj: target, &lambda {|vm, src, tags|
|
||||
puts "#{target.name} #{name} => #{src}" if vm.debug
|
||||
vm.dbg_puts "#{target.foorth_name} {name} => #{src}"
|
||||
target.create_exclusive_method(name, type, tags, &eval(src))
|
||||
})
|
||||
|
||||
|
|
5
reek.txt
5
reek.txt
|
@ -1,3 +1,2 @@
|
|||
lib/fOOrth/compiler/modes.rb -- 1 warning:
|
||||
[16, 32, 46, 58, 72, 101]:XfOOrth::VirtualMachine tests debug at least 6 times (RepeatedConditional)
|
||||
1 total warning
|
||||
|
||||
0 total warnings
|
||||
|
|
Loading…
Reference in a new issue