Permalink
Browse files

add support for cascades

  • Loading branch information...
rkh committed Jan 20, 2011
1 parent 5e82c45 commit bfc568e1cde42d9a237b73ce5ddcf16136d5aa11
Showing with 20 additions and 0 deletions.
  1. +8 −0 README.md
  2. +6 −0 lib/reak/compiler.rb
  3. +6 −0 lib/reak/syntax/call.rb
View
@@ -8,6 +8,12 @@ Status:
* Compiler is incomplete
* Standard library and core classes are near to non-existent
+Setup:
+
+ rvm use rbx
+ gem install bundler
+ bundle install
+
Example usage:
~/Workspace/reak (git: master) ☃〠 bin/reak
@@ -17,6 +23,8 @@ Example usage:
true
st> 1 rubyPerform: #to_s
a RubyObject("1")
+ st> 1 - 1; + "yes, this is valid smalltalk" 1
+ 2
This implementation is not image based nor does it have a built-in IDE. So, if
you are looking for a classic Smalltalk, you might better be looking somewhere
View
@@ -60,6 +60,12 @@ def call_method(node)
g.smalltalk_send(node.selector, node.arity)
end
+ def call_cascade(node)
+ g.dup
+ node.visit self
+ g.pop
+ end
+
def nil_kind(node)
g.push :nil
end
View
@@ -107,6 +107,12 @@ def self.new(reciever, messages)
Body.new nil, messages.map { |m| Call.new(reciever, m) }
end
+ def visit(visitor)
+ reciever.visit(visitor)
+ messages[0..-2].each { |msg| visitor.call_cascade(msg) }
+ messages.last.visit(visitor)
+ end
+
def to_sexp
[:cascade, reciever.to_sexp].concat messages.map { |m| m.to_sexp }
end

0 comments on commit bfc568e

Please sign in to comment.