rubymotionlisp 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rubylisp/exception.rb +1 -1
- data/lib/rubylisp/ffi_class.rb +1 -1
- metadata +2 -4
- data/lib/rubylisp.rb +0 -2
- data/lib/rubylisp/debug.rb +0 -238
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 79d1cf36fe85338600c33a3085d4d211d9e6dd5d
         | 
| 4 | 
            +
              data.tar.gz: 951f1a587966f6e528e00b7159ae7512045e70f2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3d13696668fe0df15257d56f11c3984eebd96b32ebd98c1af083601be8859f298a230f80316008f4924fc2a094155773e7ae667f50aa8f255947bd29914783ce
         | 
| 7 | 
            +
              data.tar.gz: 7ff8677aae52bf3bdcc100dce2cdd5768da64ffd92f060c95ad475a7653676d377b04f57d3ab780448f0188cec751529527c8a7cf6135ba2718deb2f64a72944
         | 
    
        data/lib/rubylisp/exception.rb
    CHANGED
    
    
    
        data/lib/rubylisp/ffi_class.rb
    CHANGED
    
    | @@ -93,7 +93,7 @@ module Lisp | |
| 93 93 | 
             
                    local_env = Lisp::EnvironmentFrame.extending(env)
         | 
| 94 94 | 
             
                    local_env.bind_locally(Symbol.named("self"), Lisp::NativeObject.with_value(self))
         | 
| 95 95 | 
             
                    processed_args = args.map {|a| Lisp::ClassObject.convert_to_lisp(a)}
         | 
| 96 | 
            -
                    Lisp::ClassObject.convert_to_ruby(body.apply_to(Lisp::ConsCell.array_to_list(processed_args),  | 
| 96 | 
            +
                    Lisp::ClassObject.convert_to_ruby(body.apply_to(Lisp::ConsCell.array_to_list(processed_args), local_env), local_env)
         | 
| 97 97 | 
             
                  end
         | 
| 98 98 | 
             
                  Lisp::String.with_value("OK")
         | 
| 99 99 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rubymotionlisp
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Dave Astels
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2015-02-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: An embeddable Lisp as an extension language for RubyMotion
         | 
| 14 14 | 
             
            email: dastels@icloud.com
         | 
| @@ -17,7 +17,6 @@ extensions: [] | |
| 17 17 | 
             
            extra_rdoc_files: []
         | 
| 18 18 | 
             
            files:
         | 
| 19 19 | 
             
            - README.md
         | 
| 20 | 
            -
            - lib/rubylisp.rb
         | 
| 21 20 | 
             
            - lib/rubylisp/alist.rb
         | 
| 22 21 | 
             
            - lib/rubylisp/assignment.rb
         | 
| 23 22 | 
             
            - lib/rubylisp/atom.rb
         | 
| @@ -26,7 +25,6 @@ files: | |
| 26 25 | 
             
            - lib/rubylisp/builtins.rb
         | 
| 27 26 | 
             
            - lib/rubylisp/character.rb
         | 
| 28 27 | 
             
            - lib/rubylisp/cons_cell.rb
         | 
| 29 | 
            -
            - lib/rubylisp/debug.rb
         | 
| 30 28 | 
             
            - lib/rubylisp/environment_frame.rb
         | 
| 31 29 | 
             
            - lib/rubylisp/equivalence.rb
         | 
| 32 30 | 
             
            - lib/rubylisp/exception.rb
         | 
    
        data/lib/rubylisp.rb
    DELETED
    
    
    
        data/lib/rubylisp/debug.rb
    DELETED
    
    | @@ -1,238 +0,0 @@ | |
| 1 | 
            -
            # Copyright 2014 David R. Astels.  All rights reserved.
         | 
| 2 | 
            -
            # Use of this source code is governed by a BSD-style
         | 
| 3 | 
            -
            # license that can be found in the LICENSE file.
         | 
| 4 | 
            -
             | 
| 5 | 
            -
              
         | 
| 6 | 
            -
            module Lisp
         | 
| 7 | 
            -
             | 
| 8 | 
            -
              class Debug
         | 
| 9 | 
            -
             | 
| 10 | 
            -
                class <<self
         | 
| 11 | 
            -
                  attr_accessor :trace, :on_error, :on_entry, :single_step, :interactive, :target_env, :eval_in_debug_repl
         | 
| 12 | 
            -
                end
         | 
| 13 | 
            -
                  
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                def self.register
         | 
| 16 | 
            -
                  self.trace = false
         | 
| 17 | 
            -
                  self.on_error = false
         | 
| 18 | 
            -
                  self.on_entry = Set.new
         | 
| 19 | 
            -
                  self.single_step = false
         | 
| 20 | 
            -
                  self.interactive = false
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  Primitive.register("debug-trace") {|args, env| Lisp::Debug::debug_trace_impl(args, env) }
         | 
| 23 | 
            -
                  Primitive.register("debug-on-error") {|args, env| Lisp::Debug::debug_on_error_impl(args, env) }
         | 
| 24 | 
            -
                  Primitive.register("debug-on-entry") {|args, env| Lisp::Debug::debug_on_entry_impl(args, env) }
         | 
| 25 | 
            -
                  Primitive.register("add-debug-on-entry") {|args, env| Lisp::Debug::add_debug_on_entry_impl(args, env) }
         | 
| 26 | 
            -
                  Primitive.register("remove-debug-on-entry") {|args, env| Lisp::Debug::remove_debug_on_entry_impl(args, env) }
         | 
| 27 | 
            -
                  Primitive.register("debug") {|args, env| Lisp::Debug::debug_impl(args, env) }
         | 
| 28 | 
            -
                  Primitive.register("dump") {|args, env| Lisp::Debug::dump_imp2l(args, env) }
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
                def self.debug_trace_impl(args, env)
         | 
| 33 | 
            -
                  return Lisp::Debug.process_error("debug-trace requires 1 argument", env) unless args.length == 1
         | 
| 34 | 
            -
                  flag = args.car.evaluate(env)
         | 
| 35 | 
            -
                  return Lisp::Debug.process_error("the argument to debug-trace has to be a boolean", env) unless flag.boolean?
         | 
| 36 | 
            -
                  self.trace = flag.value
         | 
| 37 | 
            -
                  flag
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
              
         | 
| 40 | 
            -
                def self.debug_on_error_impl(args, env)
         | 
| 41 | 
            -
                  return Lisp::Debug.process_error("debug-on-error requires 1 argument", env) unless args.length == 1
         | 
| 42 | 
            -
                  flag = args.car.evaluate(env)
         | 
| 43 | 
            -
                  return Lisp::Debug.process_error("the argument to debug-on-error has to be a boolean", env) unless flag.boolean?
         | 
| 44 | 
            -
                  self.on_error = flag.value
         | 
| 45 | 
            -
                  flag
         | 
| 46 | 
            -
                end
         | 
| 47 | 
            -
              
         | 
| 48 | 
            -
                def self.debug_on_entry_impl(args, env)
         | 
| 49 | 
            -
                  Lisp::ConsCell.array_to_list(self.on_entry.to_a.sort.map {|s| Lisp::String.with_value(s) })
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
              
         | 
| 52 | 
            -
                def self.add_debug_on_entry_impl(args, env)
         | 
| 53 | 
            -
                  return Lisp::Debug.process_error("add-debug-on-error requires 1 argument", env) unless args.length == 1
         | 
| 54 | 
            -
                  f = args.car.evaluate(env)
         | 
| 55 | 
            -
                  return Lisp::Debug.process_error("the argument to add-debug-on-error has to be a function", env) unless f.function? || f.primitive?
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  self.on_entry.add(f.name)
         | 
| 58 | 
            -
                  f
         | 
| 59 | 
            -
                end
         | 
| 60 | 
            -
              
         | 
| 61 | 
            -
                def self.remove_debug_on_entry_impl(args, env)
         | 
| 62 | 
            -
                  return Lisp::Debug.process_error("remove-debug-on-error requires 1 argument", env) unless args.length == 1
         | 
| 63 | 
            -
                  f = args.car.evaluate(env)
         | 
| 64 | 
            -
                  return Lisp::Debug.process_error("the argument to remove-debug-on-error has to be a function", env) unless f.function?
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                  self.on_entry.remove(f.name)
         | 
| 67 | 
            -
                  f
         | 
| 68 | 
            -
                end
         | 
| 69 | 
            -
              
         | 
| 70 | 
            -
                def self.debug_impl(args, env)
         | 
| 71 | 
            -
                end
         | 
| 72 | 
            -
              
         | 
| 73 | 
            -
                def self.dump_impl(args, env)
         | 
| 74 | 
            -
                  env.dump()
         | 
| 75 | 
            -
                end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 78 | 
            -
                def self.process_state(tokens)
         | 
| 79 | 
            -
                  if tokens.size != 2
         | 
| 80 | 
            -
                    puts "Missing on/off"
         | 
| 81 | 
            -
                    [false, false]
         | 
| 82 | 
            -
                  else
         | 
| 83 | 
            -
                    case tokens[1]
         | 
| 84 | 
            -
                    when 'on'
         | 
| 85 | 
            -
                      [true, true]
         | 
| 86 | 
            -
                    when 'off'
         | 
| 87 | 
            -
                      [true, false]
         | 
| 88 | 
            -
                    else
         | 
| 89 | 
            -
                      puts "on/off expected."
         | 
| 90 | 
            -
                      [false, false]
         | 
| 91 | 
            -
                    end
         | 
| 92 | 
            -
                  end
         | 
| 93 | 
            -
                end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
                def func_or_nil(fname, env)
         | 
| 97 | 
            -
                  f = env.value_of(Lisp::Symbol.named(fname))
         | 
| 98 | 
            -
                  if f.nil? || !f.function?
         | 
| 99 | 
            -
                    puts "No such function."
         | 
| 100 | 
            -
                    nil
         | 
| 101 | 
            -
                  else
         | 
| 102 | 
            -
                    f
         | 
| 103 | 
            -
                  end
         | 
| 104 | 
            -
                end
         | 
| 105 | 
            -
             | 
| 106 | 
            -
                
         | 
| 107 | 
            -
                def self.debug_repl(env)
         | 
| 108 | 
            -
                  parser = Lisp::Parser.new
         | 
| 109 | 
            -
                  puts("Debugging: #{env.current_code[0]}")
         | 
| 110 | 
            -
                  while line = Readline.readline('D> ', true)
         | 
| 111 | 
            -
                    if !line.empty?
         | 
| 112 | 
            -
                      if line[0] == ':'
         | 
| 113 | 
            -
                        tokens = line[1..-1].split
         | 
| 114 | 
            -
                        case tokens[0]
         | 
| 115 | 
            -
                        when '(+'
         | 
| 116 | 
            -
                          f = func_or_nil(tokens[1], env)
         | 
| 117 | 
            -
                          self.on_entry.add(f.name) unless f.nil?
         | 
| 118 | 
            -
                        when '(-'
         | 
| 119 | 
            -
                          f = func_or_nil(tokens[1], env)
         | 
| 120 | 
            -
                          self.on_entry.delete(f.name) unless f.nil?
         | 
| 121 | 
            -
                        when '('
         | 
| 122 | 
            -
                          self.on_entry.to_a.sort.each {|f| puts f}
         | 
| 123 | 
            -
                        when '?'
         | 
| 124 | 
            -
                          puts "RubyLisp Debugger"
         | 
| 125 | 
            -
                          puts "-----------------"
         | 
| 126 | 
            -
                          puts ":(+ func  - debug on entry to func"
         | 
| 127 | 
            -
                          puts ":(- func  - don't debug on entry to func"
         | 
| 128 | 
            -
                          puts ":(        - show functions marked as debug on entry"
         | 
| 129 | 
            -
                          puts ":?        - show this command summary"
         | 
| 130 | 
            -
                          puts ":b        - show the environment stack"
         | 
| 131 | 
            -
                          puts ":c        - continue, exiting the debugger"
         | 
| 132 | 
            -
                          puts ":d        - do a full of the environment stack"
         | 
| 133 | 
            -
                          puts ":e on/off - Enable/disable debug on error"
         | 
| 134 | 
            -
                          puts ":f frame# - do a full dump of a single environment frame"
         | 
| 135 | 
            -
                          puts ":q        - quit GoLisp"
         | 
| 136 | 
            -
                          puts ":r sexpr  - return from the current evaluation with the specified value"
         | 
| 137 | 
            -
                          puts ":s        - single step (run to the next evaluation)"
         | 
| 138 | 
            -
                          puts ":t on/off - Enable/disable tracing"
         | 
| 139 | 
            -
                          puts ":u        - continue until the enclosing environment frame is returned to"
         | 
| 140 | 
            -
                          puts
         | 
| 141 | 
            -
                        when 'b'
         | 
| 142 | 
            -
                          env.dump_headers()
         | 
| 143 | 
            -
                          puts
         | 
| 144 | 
            -
                        when 'c'
         | 
| 145 | 
            -
                          self.target_env = nil
         | 
| 146 | 
            -
                          self.single_step = false
         | 
| 147 | 
            -
                          self.eval_in_debug_repl = false
         | 
| 148 | 
            -
                          return
         | 
| 149 | 
            -
                        when 'd'
         | 
| 150 | 
            -
                          env.dump
         | 
| 151 | 
            -
                        when 'e'
         | 
| 152 | 
            -
                          ok, state = process_state(tokens)
         | 
| 153 | 
            -
                          self.on_error = state if ok
         | 
| 154 | 
            -
                        when 'f'
         | 
| 155 | 
            -
                          if tokens.size != 2
         | 
| 156 | 
            -
                            puts "Missing frame number."
         | 
| 157 | 
            -
                          else
         | 
| 158 | 
            -
                            fnum = tokens[1].to_i
         | 
| 159 | 
            -
                            env.dump_single_frame(fnum)
         | 
| 160 | 
            -
                          end
         | 
| 161 | 
            -
                        when 'q'
         | 
| 162 | 
            -
                          exit()
         | 
| 163 | 
            -
                        when 'r'
         | 
| 164 | 
            -
                          self.eval_in_debug_repl = true
         | 
| 165 | 
            -
                          code = parser.parse(tokens[1..-1].join(' '))
         | 
| 166 | 
            -
                          return_value = code.evaluate(env)
         | 
| 167 | 
            -
                          self.eval_in_debug_repl = false
         | 
| 168 | 
            -
                          self.target_env = nil
         | 
| 169 | 
            -
                          self.single_step = false
         | 
| 170 | 
            -
                          self.eval_in_debug_repl = false
         | 
| 171 | 
            -
                          return return_value
         | 
| 172 | 
            -
                        when 's'
         | 
| 173 | 
            -
                          self.single_step = true
         | 
| 174 | 
            -
                          return
         | 
| 175 | 
            -
                        when 't'
         | 
| 176 | 
            -
                          ok, state = process_state(tokens)
         | 
| 177 | 
            -
                          self.trace = state if ok
         | 
| 178 | 
            -
                        when 'u'
         | 
| 179 | 
            -
                          if env.previous.nil?
         | 
| 180 | 
            -
                            puts "Already at top frame."
         | 
| 181 | 
            -
                          else
         | 
| 182 | 
            -
                            self.target_env = env
         | 
| 183 | 
            -
                            return
         | 
| 184 | 
            -
                          end
         | 
| 185 | 
            -
                        end
         | 
| 186 | 
            -
                      else
         | 
| 187 | 
            -
                        begin 
         | 
| 188 | 
            -
                          self.eval_in_debug_repl = true
         | 
| 189 | 
            -
                          code = parser.parse(line)
         | 
| 190 | 
            -
                          value = code.evaluate(env)
         | 
| 191 | 
            -
                          self.eval_in_debug_repl = false
         | 
| 192 | 
            -
                          puts value.to_s
         | 
| 193 | 
            -
                        rescue Exception => ex
         | 
| 194 | 
            -
                          puts "ERROR: #{ex}"
         | 
| 195 | 
            -
                          puts ex.backtrace
         | 
| 196 | 
            -
                        end
         | 
| 197 | 
            -
                      end
         | 
| 198 | 
            -
                    end
         | 
| 199 | 
            -
                  end
         | 
| 200 | 
            -
                end
         | 
| 201 | 
            -
             | 
| 202 | 
            -
                def self.process_error(error_message, env)
         | 
| 203 | 
            -
                  if self.on_error && self.interactive
         | 
| 204 | 
            -
                    puts "ERROR: #{error_message}"
         | 
| 205 | 
            -
                    self.debug_repl(env)
         | 
| 206 | 
            -
                  else
         | 
| 207 | 
            -
                    raise error_message
         | 
| 208 | 
            -
                  end
         | 
| 209 | 
            -
                end
         | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
                def self.print_dashes(level)
         | 
| 213 | 
            -
                  print("-" * level)
         | 
| 214 | 
            -
                end
         | 
| 215 | 
            -
             | 
| 216 | 
            -
                
         | 
| 217 | 
            -
                def self.log_eval(sexpr, env)
         | 
| 218 | 
            -
                  if !self.eval_in_debug_repl && self.trace
         | 
| 219 | 
            -
                    depth = env.depth
         | 
| 220 | 
            -
                    print("% #d: " % depth)
         | 
| 221 | 
            -
                    print_dashes(depth)
         | 
| 222 | 
            -
                    puts("> #{sexpr.to_s}")
         | 
| 223 | 
            -
                  end
         | 
| 224 | 
            -
                end
         | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
                def self.log_result(result, env)
         | 
| 228 | 
            -
                  if !self.eval_in_debug_repl && self.trace
         | 
| 229 | 
            -
                    depth = env.depth
         | 
| 230 | 
            -
                    print("% #d: <" % depth)
         | 
| 231 | 
            -
                    print_dashes(depth)
         | 
| 232 | 
            -
                    puts(" #{result.to_s}")
         | 
| 233 | 
            -
                  end
         | 
| 234 | 
            -
                end
         | 
| 235 | 
            -
                
         | 
| 236 | 
            -
              
         | 
| 237 | 
            -
              end
         | 
| 238 | 
            -
            end
         |