properly handle multiple subexpressions in the same hash, fixes #748
push all hash params before popping any so as to avoid the last stackN var stomping previous ones
This commit is contained in:
@@ -188,15 +188,15 @@ Compiler.prototype = {
|
||||
},
|
||||
|
||||
hash: function(hash) {
|
||||
var pairs = hash.pairs, pair;
|
||||
var pairs = hash.pairs, i, l;
|
||||
|
||||
this.opcode('pushHash');
|
||||
|
||||
for(var i=0, l=pairs.length; i<l; i++) {
|
||||
pair = pairs[i];
|
||||
|
||||
this.pushParam(pair[1]);
|
||||
this.opcode('assignToHash', pair[0]);
|
||||
for(i=0, l=pairs.length; i<l; i++) {
|
||||
this.pushParam(pairs[i][1]);
|
||||
}
|
||||
while(i--) {
|
||||
this.opcode('assignToHash', pairs[i][0]);
|
||||
}
|
||||
this.opcode('popHash');
|
||||
},
|
||||
|
||||
@@ -606,11 +606,10 @@ JavaScriptCompiler.prototype = {
|
||||
|
||||
// [assignToHash]
|
||||
//
|
||||
// On stack, before: value, hash, ...
|
||||
// On stack, after: hash, ...
|
||||
// On stack, before: value, ..., hash, ...
|
||||
// On stack, after: ..., hash, ...
|
||||
//
|
||||
// Pops a value and hash off the stack, assigns `hash[key] = value`
|
||||
// and pushes the hash back onto the stack.
|
||||
// Pops a value off the stack and assigns it to the current hash
|
||||
assignToHash: function(key) {
|
||||
var value = this.popStack(),
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user