revised patch for #1234; consolidated Value#push and Value#concat into Value#add; removed unnecessary INDEX_PROTO

This commit is contained in:
Gerald Lewis 2011-08-12 13:38:34 -04:00
parent ab0b36a53f
commit c9fd0659c2
5 changed files with 144 additions and 144 deletions

View File

@ -135,7 +135,7 @@
o('Identifier', function() {
return new Value($1);
}), o('Value Accessor', function() {
return $1.concat($2);
return $1.add($2);
}), o('Invocation Accessor', function() {
return new Value($1, [$2]);
}), o('ThisProperty')
@ -174,10 +174,6 @@
return extend($2, {
soak: true
});
}), o('INDEX_PROTO Index', function() {
return extend($2, {
proto: true
});
})
],
IndexValue: [

View File

@ -378,11 +378,7 @@
return this;
}
Value.prototype.children = ['base', 'properties'];
Value.prototype.push = function(prop) {
this.properties.push(prop);
return this;
};
Value.prototype.concat = function(props) {
Value.prototype.add = function(props) {
this.properties = this.properties.concat(props);
return this;
};
@ -457,7 +453,7 @@
name = new Index(new Assign(nref, name.index));
nref = new Index(nref);
}
return [base.push(name), new Value(bref || base.base, [nref || name])];
return [base.add(name), new Value(bref || base.base, [nref || name])];
};
Value.prototype.compileNode = function(o) {
var code, prop, props, _i, _len;

File diff suppressed because one or more lines are too long

View File

@ -217,7 +217,7 @@ grammar =
# Variables and properties that can be assigned to.
SimpleAssignable: [
o 'Identifier', -> new Value $1
o 'Value Accessor', -> $1.concat $2
o 'Value Accessor', -> $1.add $2
o 'Invocation Accessor', -> new Value $1, [$2]
o 'ThisProperty'
]
@ -253,7 +253,6 @@ grammar =
Index: [
o 'INDEX_START IndexValue INDEX_END', -> $2
o 'INDEX_SOAK Index', -> extend $2, soak : yes
o 'INDEX_PROTO Index', -> extend $2, proto: yes
]
IndexValue: [

View File

@ -344,13 +344,8 @@ exports.Value = class Value extends Base
children: ['base', 'properties']
# Add a property `Access` to the list.
push: (prop) ->
@properties.push prop
this
# Add multiple property `Access`s to the list.
concat: (props) ->
# Add a property (or *properties* ) `Access` to the list.
add: (props) ->
@properties = @properties.concat props
this
@ -402,7 +397,7 @@ exports.Value = class Value extends Base
nref = new Literal o.scope.freeVariable 'name'
name = new Index new Assign nref, name.index
nref = new Index nref
[base.push(name), new Value(bref or base.base, [nref or name])]
[base.add(name), new Value(bref or base.base, [nref or name])]
# We compile a value to JavaScript by compiling and joining each property.
# Things get much more interesting if the chain of properties has *soak*