Skip to content

Commit

Permalink
ACTIONSCRIPT: Add saving and restoring of "this" variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed Aug 19, 2018
1 parent 2e4d4b3 commit a6c7114
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/aurora/actionscript/asbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,13 @@ void ASBuffer::actionCallMethod(AVM &avm) {
throw Common::Exception("Object is not a function");

byte counter = 1;
Variable prevThis;

if (function->getPreloadThisFlag()) {
if (!name.empty())
if (!name.empty()) {
prevThis = avm.getRegister(counter);
avm.storeRegister(object, counter);
}
counter += 1;
}
if (function->getPreloadSuperFlag()) {
Expand All @@ -454,6 +457,9 @@ void ASBuffer::actionCallMethod(AVM &avm) {
avm.setReturnValue(Variable());
_stack.push((*function)(avm));

if (!prevThis.isUndefined())
avm.storeRegister(prevThis, 1);

debugC(kDebugActionScript, 1, "actionCallMethod");
}

Expand Down

0 comments on commit a6c7114

Please sign in to comment.