adding no-argument super calls.

This commit is contained in:
Jeremy Ashkenas
2010-07-18 14:46:21 -04:00
parent d017a8f9f7
commit 989d539af3
4 changed files with 134 additions and 116 deletions

View File

@@ -263,7 +263,9 @@
})
],
Super: [
o("SUPER Arguments", function() {
o("SUPER", function() {
return new CallNode('super', [new SplatNode(new LiteralNode('arguments'))]);
}), o("SUPER Arguments", function() {
return new CallNode('super', $2);
})
],

File diff suppressed because one or more lines are too long

View File

@@ -317,6 +317,7 @@ grammar: {
# Calling super.
Super: [
o "SUPER", -> new CallNode 'super', [new SplatNode(new LiteralNode('arguments'))]
o "SUPER Arguments", -> new CallNode 'super', $2
]

View File

@@ -114,7 +114,7 @@ class Hive
constructor: (name) -> @name: name
class Hive.Bee extends Hive
constructor: (name) -> super name
constructor: (name) -> super
maya: new Hive.Bee 'Maya'
ok maya.name is 'Maya'
@@ -170,3 +170,16 @@ list: [3, 2, 1]
conn: new Connection list...
ok conn instanceof Connection
ok conn.out() is '3-2-1'
# Test calling super and passing along all arguments.
class Parent
method: (args...) -> @args: args
class Child extends Parent
method: -> super
c: new Child
c.method 1, 2, 3, 4
ok c.args.join(' ') is '1 2 3 4'