mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2025-01-05 20:32:02 -05:00
Merge pull request #177 from nathan/set-var-cache
Fixed incorrect caching in primVarSet and primVarChange
This commit is contained in:
commit
07fc1f4728
1 changed files with 6 additions and 4 deletions
|
@ -668,9 +668,10 @@ public class Interpreter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function primVarSet(b:Block):Variable {
|
protected function primVarSet(b:Block):Variable {
|
||||||
var v:Variable = activeThread.target.varCache[arg(b, 0)];
|
var name:String = arg(b, 0);
|
||||||
|
var v:Variable = activeThread.target.varCache[name];
|
||||||
if (!v) {
|
if (!v) {
|
||||||
v = activeThread.target.varCache[b.spec] = activeThread.target.lookupOrCreateVar(arg(b, 0));
|
v = activeThread.target.varCache[name] = activeThread.target.lookupOrCreateVar(name);
|
||||||
if (!v) return null;
|
if (!v) return null;
|
||||||
}
|
}
|
||||||
var oldvalue:* = v.value;
|
var oldvalue:* = v.value;
|
||||||
|
@ -679,9 +680,10 @@ public class Interpreter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function primVarChange(b:Block):Variable {
|
protected function primVarChange(b:Block):Variable {
|
||||||
var v:Variable = activeThread.target.varCache[arg(b, 0)];
|
var name:String = arg(b, 0);
|
||||||
|
var v:Variable = activeThread.target.varCache[name];
|
||||||
if (!v) {
|
if (!v) {
|
||||||
v = activeThread.target.varCache[b.spec] = activeThread.target.lookupOrCreateVar(arg(b, 0));
|
v = activeThread.target.varCache[name] = activeThread.target.lookupOrCreateVar(name);
|
||||||
if (!v) return null;
|
if (!v) return null;
|
||||||
}
|
}
|
||||||
v.value = Number(v.value) + numarg(b, 1);
|
v.value = Number(v.value) + numarg(b, 1);
|
||||||
|
|
Loading…
Reference in a new issue