Permalink
Browse files

Add compatibility mode.

  • Loading branch information...
1 parent 0aa81c5 commit 5aa10111f0ec1c59bf43c92d6a779fea304cb9c8 @mbebenita committed Apr 4, 2013
Showing with 16 additions and 10 deletions.
  1. +5 −2 src/avm2/compiler/builder.js
  2. +10 −8 src/avm2/runtime.js
  3. +1 −0 src/avm2/util.js
@@ -218,7 +218,7 @@ var c4TraceLevel = c4Options.register(new Option("tc4", "tc4", "number", 0, "Com
local = coercer(local);
} else {
var type = this.abc.domain.getProperty(parameter.type, true, false);
- if (type) {
+ if (type && compatibility) {
local = new Call(start, state.store, globalProperty("coerce"), null, [local, constant(type)], true);
} else {
// unexpected();
@@ -534,7 +534,10 @@ var c4TraceLevel = c4Options.register(new Option("tc4", "tc4", "number", 0, "Com
return coercer(value);
}
}
- return call(globalProperty("coerce"), null, [value, type]);
+ if (compatibility) {
+ return call(globalProperty("coerce"), null, [value, type]);
+ }
+ return value;
}
function getScopeObject(scope) {
View
@@ -138,13 +138,15 @@ function initializeGlobalObject(global) {
// Save the original method in case |getNative| needs it.
originals[object.name][originalFunctionName] = originalFunction;
var overrideFunctionName = Multiname.getPublicQualifiedName(originalFunctionName);
- // Patch the native builtin with a surrogate.
- global[object.name].prototype[originalFunctionName] = function surrogate() {
- if (this[overrideFunctionName]) {
- return this[overrideFunctionName]();
- }
- return originalFunction.call(this);
- };
+ if (compatibility) {
+ // Patch the native builtin with a surrogate.
+ global[object.name].prototype[originalFunctionName] = function surrogate() {
+ if (this[overrideFunctionName]) {
+ return this[overrideFunctionName]();
+ }
+ return originalFunction.call(this);
+ };
+ }
});
});
@@ -1279,7 +1281,7 @@ var Runtime = (function () {
this.createFunction(classInfo.init, scope).call(cls);
// Seal constant traits in the class object.
- this.sealConstantTraits(cls, ci.traits);
+ compatibility && this.sealConstantTraits(cls, ci.traits);
// TODO: Seal constant traits in the instance object. This should be done after
// the instance constructor has executed.
View
@@ -1,4 +1,5 @@
var release = false;
+var compatibility = false;
var inBrowser = typeof console != "undefined";

2 comments on commit 5aa1011

magcius commented on 5aa1011 Apr 6, 2013

Sorry if I ask, but what does the compat mode do?

Owner

mbebenita replied Apr 6, 2013

Being 100% correct can cause performance problems. The idea is to relax some of the semantics with compatibility flag.

Please sign in to comment.