提交 271abd80 编写于 作者: J Justin Collins

Remove copied+unchanged SexpProcessor code

上级 35bc224a
......@@ -72,14 +72,7 @@ class Brakeman::SexpProcessor
# now do a pass with the real processor (or generic)
meth = @processors[type]
if meth then
if $DEBUG
result = error_handler(type) do
self.send(meth, exp)
end
else
result = self.send(meth, exp)
end
result = self.send(meth, exp)
else
result = self.process_default(exp)
end
......@@ -90,36 +83,6 @@ class Brakeman::SexpProcessor
result
end
def error_handler(type, exp=nil) # :nodoc:
begin
return yield
rescue => err
warn "#{err.class} Exception thrown while processing #{type} for sexp #{exp.inspect} #{caller.inspect}" if $DEBUG
raise
end
end
##
# A fairly generic processor for a dummy node. Dummy nodes are used
# when your processor is doing a complicated rewrite that replaces
# the current sexp with multiple sexps.
#
# Bogus Example:
#
# def process_something(exp)
# return s(:dummy, process(exp), s(:extra, 42))
# end
def process_dummy(exp)
result = @expected.new(:dummy) rescue @expected.new
until exp.empty? do
result << self.process(exp.shift)
end
result
end
##
# Add a scope level to the current env. Eg:
#
......@@ -150,86 +113,4 @@ class Brakeman::SexpProcessor
self.context.shift
end
##
# I really hate this here, but I hate subdirs in my lib dir more...
# I guess it is kinda like shaving... I'll split this out when it
# itches too much...
class Environment
def initialize
@env = []
@env.unshift({})
end
def all
@env.reverse.inject { |env, scope| env.merge scope }
end
def depth
@env.length
end
# TODO: depth_of
def [] name
hash = @env.find { |closure| closure.has_key? name }
hash[name] if hash
end
def []= name, val
hash = @env.find { |closure| closure.has_key? name } || @env.first
hash[name] = val
end
def scope
@env.unshift({})
begin
yield
ensure
@env.shift
raise "You went too far unextending env" if @env.empty?
end
end
end
end
class Object
##
# deep_clone is the usual Marshalling hack to make a deep copy.
# It is rather slow, so use it sparingly. Helps with debugging
# SexpProcessors since you usually shift off sexps.
def deep_clone
Marshal.load(Marshal.dump(self))
end
end
##
# SexpProcessor base exception class.
class SexpProcessorError < StandardError; end
##
# Raised by SexpProcessor if it sees a node type listed in its
# unsupported list.
class UnsupportedNodeError < SexpProcessorError; end
##
# Raised by SexpProcessor if it is in strict mode and sees a node for
# which there is no processor available.
class UnknownNodeError < SexpProcessorError; end
##
# Raised by SexpProcessor if a processor did not process every node in
# a sexp and @require_empty is true.
class NotEmptyError < SexpProcessorError; end
##
# Raised if assert_type encounters an unexpected sexp type.
class SexpTypeError < SexpProcessorError; end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册