revised patch for #1234; consolidated Value#push and Value#concat into Value#add; removed unnecessary INDEX_PROTO
This commit is contained in:
parent
ab0b36a53f
commit
c9fd0659c2
|
@ -135,7 +135,7 @@
|
||||||
o('Identifier', function() {
|
o('Identifier', function() {
|
||||||
return new Value($1);
|
return new Value($1);
|
||||||
}), o('Value Accessor', function() {
|
}), o('Value Accessor', function() {
|
||||||
return $1.concat($2);
|
return $1.add($2);
|
||||||
}), o('Invocation Accessor', function() {
|
}), o('Invocation Accessor', function() {
|
||||||
return new Value($1, [$2]);
|
return new Value($1, [$2]);
|
||||||
}), o('ThisProperty')
|
}), o('ThisProperty')
|
||||||
|
@ -174,10 +174,6 @@
|
||||||
return extend($2, {
|
return extend($2, {
|
||||||
soak: true
|
soak: true
|
||||||
});
|
});
|
||||||
}), o('INDEX_PROTO Index', function() {
|
|
||||||
return extend($2, {
|
|
||||||
proto: true
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
IndexValue: [
|
IndexValue: [
|
||||||
|
|
|
@ -378,11 +378,7 @@
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
Value.prototype.children = ['base', 'properties'];
|
Value.prototype.children = ['base', 'properties'];
|
||||||
Value.prototype.push = function(prop) {
|
Value.prototype.add = function(props) {
|
||||||
this.properties.push(prop);
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
Value.prototype.concat = function(props) {
|
|
||||||
this.properties = this.properties.concat(props);
|
this.properties = this.properties.concat(props);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
@ -457,7 +453,7 @@
|
||||||
name = new Index(new Assign(nref, name.index));
|
name = new Index(new Assign(nref, name.index));
|
||||||
nref = new Index(nref);
|
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) {
|
Value.prototype.compileNode = function(o) {
|
||||||
var code, prop, props, _i, _len;
|
var code, prop, props, _i, _len;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -217,7 +217,7 @@ grammar =
|
||||||
# Variables and properties that can be assigned to.
|
# Variables and properties that can be assigned to.
|
||||||
SimpleAssignable: [
|
SimpleAssignable: [
|
||||||
o 'Identifier', -> new Value $1
|
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 'Invocation Accessor', -> new Value $1, [$2]
|
||||||
o 'ThisProperty'
|
o 'ThisProperty'
|
||||||
]
|
]
|
||||||
|
@ -253,7 +253,6 @@ grammar =
|
||||||
Index: [
|
Index: [
|
||||||
o 'INDEX_START IndexValue INDEX_END', -> $2
|
o 'INDEX_START IndexValue INDEX_END', -> $2
|
||||||
o 'INDEX_SOAK Index', -> extend $2, soak : yes
|
o 'INDEX_SOAK Index', -> extend $2, soak : yes
|
||||||
o 'INDEX_PROTO Index', -> extend $2, proto: yes
|
|
||||||
]
|
]
|
||||||
|
|
||||||
IndexValue: [
|
IndexValue: [
|
||||||
|
|
|
@ -344,13 +344,8 @@ exports.Value = class Value extends Base
|
||||||
|
|
||||||
children: ['base', 'properties']
|
children: ['base', 'properties']
|
||||||
|
|
||||||
# Add a property `Access` to the list.
|
# Add a property (or *properties* ) `Access` to the list.
|
||||||
push: (prop) ->
|
add: (props) ->
|
||||||
@properties.push prop
|
|
||||||
this
|
|
||||||
|
|
||||||
# Add multiple property `Access`s to the list.
|
|
||||||
concat: (props) ->
|
|
||||||
@properties = @properties.concat props
|
@properties = @properties.concat props
|
||||||
this
|
this
|
||||||
|
|
||||||
|
@ -402,7 +397,7 @@ exports.Value = class Value extends Base
|
||||||
nref = new Literal o.scope.freeVariable 'name'
|
nref = new Literal o.scope.freeVariable 'name'
|
||||||
name = new Index new Assign nref, name.index
|
name = new Index new Assign nref, name.index
|
||||||
nref = new Index nref
|
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.
|
# We compile a value to JavaScript by compiling and joining each property.
|
||||||
# Things get much more interesting if the chain of properties has *soak*
|
# Things get much more interesting if the chain of properties has *soak*
|
||||||
|
|
Loading…
Reference in New Issue