Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Unified Diff: lib/runtime/dart/_js_helper.js

Issue 1069493002: implement opassign, fix bugs in pre/postfix, introduce a let* helper (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/runtime/dart/_js_helper.js
diff --git a/lib/runtime/dart/_js_helper.js b/lib/runtime/dart/_js_helper.js
index b6a6dcd6d63505b71c897408066f0378d113f2bb..916f02a28223d4e56dd5da55002f0b1eaa284c33 100644
--- a/lib/runtime/dart/_js_helper.js
+++ b/lib/runtime/dart/_js_helper.js
@@ -560,7 +560,7 @@ var _js_helper;
return null;
if (match[core.$get](dart.notNull(match[core.$length]) - 1) != null)
return null;
- match[core.$length] = 1;
+ match[core.$length] = dart.notNull(match[core.$length]) - 1;
return new _MatchImplementation(this, dart.as(match, core.List$(core.String)));
}
matchAsPrefix(string, start) {
@@ -818,7 +818,7 @@ var _js_helper;
code = dart.as(dart.dinvoke(receiver, 'codeUnitAt', dart.notNull(i) + 1), core.int);
if ((dart.notNull(code) & ~1023) == 56320) {
buffer.write(dart.dinvokef(onNonMatch, dart.dinvoke(receiver, 'substring', i, dart.notNull(i) + 2)));
- i = 2;
+ i = dart.notNull(i) + 2;
continue;
}
}
@@ -1539,8 +1539,9 @@ var _js_helper;
if (!dart.is(arguments$, _interceptors.JSArray))
arguments$ = new core.List.from(arguments$);
} else {
- arguments$ = new core.List.from([victim]);
- arguments$[core.$addAll](arguments$);
+ let _$ = new core.List.from([victim]);
+ _$[core.$addAll](arguments$);
+ arguments$ = _$;
if (this.cachedInterceptor != null)
receiver = this.cachedInterceptor;
}
@@ -1570,8 +1571,9 @@ var _js_helper;
providedArgumentCount = arguments$[core.$length];
}
} else {
- arguments$ = new core.List.from([victim]);
- arguments$[core.$addAll](arguments$);
+ let _$ = new core.List.from([victim]);
+ _$[core.$addAll](arguments$);
+ arguments$ = _$;
if (this.cachedInterceptor != null)
receiver = this.cachedInterceptor;
providedArgumentCount = dart.notNull(arguments$[core.$length]) - 1;
@@ -1678,11 +1680,8 @@ var _js_helper;
positions.set(this.parameterName(index), index);
}
let index = 0;
- ((_$) => {
- _$[core.$sort]();
- return _$;
- })(positions.keys[core.$toList]())[core.$forEach](((name) => {
- this.cachedSortedIndices[core.$set](((x$) => index = dart.notNull(x$) + 1, x$)(index), positions.get(name));
+ ((_$) => (_$ = positions.keys[core.$toList](), _$[core.$sort](), _$))()[core.$forEach](((name) => {
+ this.cachedSortedIndices[core.$set](((x$) => (x$ = index, index = dart.notNull(x$) + 1, x$))(), positions.get(name));
}).bind(this));
}
return dart.as(this.cachedSortedIndices[core.$get](unsortedIndex), core.int);
@@ -1717,8 +1716,8 @@ var _js_helper;
let _mangledNameMatchesType = Symbol('_mangledNameMatchesType');
class Primitives extends core.Object {
static initializeStatics(id) {
- Primitives.mirrorFunctionCacheName = `_${id}`;
- Primitives.mirrorInvokeCacheName = `_${id}`;
+ Primitives.mirrorFunctionCacheName = core.String['+'](Primitives.mirrorFunctionCacheName, `_${id}`);
+ Primitives.mirrorInvokeCacheName = core.String['+'](Primitives.mirrorInvokeCacheName, `_${id}`);
}
static objectHashCode(object) {
let hash = dart.as(object.$identityHash, core.int);
@@ -1857,7 +1856,7 @@ var _js_helper;
let result = "";
let kMaxApply = 500;
let end = array[core.$length];
- for (let i = 0; dart.notNull(i) < dart.notNull(end); i = kMaxApply) {
+ for (let i = 0; dart.notNull(i) < dart.notNull(end); i = dart.notNull(i) + dart.notNull(kMaxApply)) {
let subarray = null;
if (dart.notNull(end) <= dart.notNull(kMaxApply)) {
subarray = array;
@@ -2020,7 +2019,7 @@ var _js_helper;
let arguments$ = new core.List.from([]);
let namedArgumentList = new core.List.from([]);
if (positionalArguments != null) {
- argumentCount = positionalArguments[core.$length];
+ argumentCount = dart.notNull(argumentCount) + dart.notNull(positionalArguments[core.$length]);
arguments$[core.$addAll](positionalArguments);
}
let names = '';
@@ -2533,8 +2532,8 @@ var _js_helper;
let index = 0;
let length = getLength(keyValuePairs);
while (dart.notNull(index) < dart.notNull(length)) {
- let key = getIndex(keyValuePairs, ((x$) => index = dart.notNull(x$) + 1, x$)(index));
- let value = getIndex(keyValuePairs, ((x$) => index = dart.notNull(x$) + 1, x$)(index));
+ let key = getIndex(keyValuePairs, ((x$) => (x$ = index, index = dart.notNull(x$) + 1, x$))());
+ let value = getIndex(keyValuePairs, ((x$) => (x$ = index, index = dart.notNull(x$) + 1, x$))());
result.set(key, value);
}
return result;
@@ -2590,7 +2589,7 @@ var _js_helper;
this.$initialize();
} : Closure.isCsp ? function(a, b, c, d) {
this.$initialize(a, b, c, d);
- } : new Function("a", "b", "c", "d", "this.$initialize(a,b,c,d);" + ((x$) => Closure.functionCounter = dart.notNull(x$) + 1, x$)(Closure.functionCounter));
+ } : new Function("a", "b", "c", "d", "this.$initialize(a,b,c,d);" + ((x$) => (x$ = Closure.functionCounter, Closure.functionCounter = dart.notNull(x$) + 1, x$))());
prototype.constructor = constructor;
constructor.prototype = prototype;
let trampoline = func;
@@ -2711,11 +2710,11 @@ var _js_helper;
return Closure.cspForwardCall(arity, isSuperCall, stubName, func);
}
if (arity == 0) {
- return new Function('return function(){' + `return this.${BoundClosure.selfFieldName()}.${stubName}();` + `${((x$) => Closure.functionCounter = dart.notNull(x$) + 1, x$)(Closure.functionCounter)}` + '}')();
+ return new Function('return function(){' + `return this.${BoundClosure.selfFieldName()}.${stubName}();` + `${((x$) => (x$ = Closure.functionCounter, Closure.functionCounter = dart.notNull(x$) + 1, x$))()}` + '}')();
}
dart.assert(1 <= dart.notNull(arity) && dart.notNull(arity) < 27);
let arguments$ = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, arity).join(",");
- return new Function(`return function(${arguments$}){` + `return this.${BoundClosure.selfFieldName()}.${stubName}(${arguments$});` + `${((x$) => Closure.functionCounter = dart.notNull(x$) + 1, x$)(Closure.functionCounter)}` + '}')();
+ return new Function(`return function(${arguments$}){` + `return this.${BoundClosure.selfFieldName()}.${stubName}(${arguments$});` + `${((x$) => (x$ = Closure.functionCounter, Closure.functionCounter = dart.notNull(x$) + 1, x$))()}` + '}')();
}
static cspForwardInterceptedCall(arity, isSuperCall, name, func) {
let getSelf = _foreign_helper.RAW_DART_FUNCTION_REF(BoundClosure.selfOf);
@@ -2799,11 +2798,11 @@ var _js_helper;
return Closure.cspForwardInterceptedCall(arity, isSuperCall, stubName, func);
}
if (arity == 1) {
- return new Function('return function(){' + `return this.${selfField}.${stubName}(this.${receiverField});` + `${((x$) => Closure.functionCounter = dart.notNull(x$) + 1, x$)(Closure.functionCounter)}` + '}')();
+ return new Function('return function(){' + `return this.${selfField}.${stubName}(this.${receiverField});` + `${((x$) => (x$ = Closure.functionCounter, Closure.functionCounter = dart.notNull(x$) + 1, x$))()}` + '}')();
}
dart.assert(1 < dart.notNull(arity) && dart.notNull(arity) < 28);
let arguments$ = "abcdefghijklmnopqrstuvwxyz".split("").splice(0, dart.notNull(arity) - 1).join(",");
- return new Function(`return function(${arguments$}){` + `return this.${selfField}.${stubName}(this.${receiverField}, ${arguments$});` + `${((x$) => Closure.functionCounter = dart.notNull(x$) + 1, x$)(Closure.functionCounter)}` + '}')();
+ return new Function(`return function(${arguments$}){` + `return this.${selfField}.${stubName}(this.${receiverField}, ${arguments$});` + `${((x$) => (x$ = Closure.functionCounter, Closure.functionCounter = dart.notNull(x$) + 1, x$))()}` + '}')();
}
toString() {
return "Closure";
@@ -3358,42 +3357,47 @@ var _js_helper;
if (this.parameterTypes != null) {
for (let i = 0; dart.notNull(i) < dart.notNull(this.parameterTypes[core.$length]); i = dart.notNull(i) + 1) {
let type = this.parameterTypes[core.$get](i);
- if (needsComma)
- result = ', ';
- result = `${type}`;
+ if (needsComma) {
+ result = core.String['+'](result, ', ');
+ }
+ result = core.String['+'](result, `${type}`);
needsComma = true;
}
}
if (dart.notNull(this.optionalParameterTypes != null) && !dart.notNull(this.optionalParameterTypes[core.$isEmpty])) {
- if (needsComma)
- result = ', ';
+ if (needsComma) {
+ result = core.String['+'](result, ', ');
+ }
needsComma = false;
- result = '[';
+ result = core.String['+'](result, '[');
for (let i = 0; dart.notNull(i) < dart.notNull(this.optionalParameterTypes[core.$length]); i = dart.notNull(i) + 1) {
let type = this.optionalParameterTypes[core.$get](i);
- if (needsComma)
- result = ', ';
- result = `${type}`;
+ if (needsComma) {
+ result = core.String['+'](result, ', ');
+ }
+ result = core.String['+'](result, `${type}`);
needsComma = true;
}
- result = ']';
+ result = core.String['+'](result, ']');
} else if (this.namedParameters != null) {
- if (needsComma)
- result = ', ';
+ if (needsComma) {
+ result = core.String['+'](result, ', ');
+ }
needsComma = false;
- result = '{';
+ result = core.String['+'](result, '{');
let keys = _js_names.extractKeys(this.namedParameters);
for (let i = 0; dart.notNull(i) < dart.notNull(keys[core.$length]); i = dart.notNull(i) + 1) {
let name = keys[core.$get](i);
- if (needsComma)
- result = ', ';
+ if (needsComma) {
+ result = core.String['+'](result, ', ');
+ }
let rti = dart.dinvoke(this.namedParameters[name], 'toRti');
- result = `${rti} ${name}`;
+ result = core.String['+'](result, `${rti} ${name}`);
needsComma = true;
}
- result = '}';
+ result = core.String['+'](result, '}');
}
- result = `) -> ${this.returnType}`;
+ result = core.String['+'](result, `) -> ${this.returnType}`);
return result;
}
}
@@ -3585,39 +3589,39 @@ var _js_helper;
let sep = '';
if (this[_hasArguments]) {
for (let argument of this[_arguments]) {
- s = sep;
- s = this[_convert](argument);
+ s = core.String['+'](s, sep);
+ s = core.String['+'](s, this[_convert](argument));
sep = ', ';
}
}
if (this[_hasOptionalArguments]) {
- s = `${sep}[`;
+ s = core.String['+'](s, `${sep}[`);
sep = '';
for (let argument of this[_optionalArguments]) {
- s = sep;
- s = this[_convert](argument);
+ s = core.String['+'](s, sep);
+ s = core.String['+'](s, this[_convert](argument));
sep = ', ';
}
- s = ']';
+ s = core.String['+'](s, ']');
}
if (this[_hasNamedArguments]) {
- s = `${sep}{`;
+ s = core.String['+'](s, `${sep}{`);
sep = '';
for (let name of _js_names.extractKeys(this[_namedArguments])) {
- s = sep;
- s = `${name}: `;
- s = this[_convert](this[_namedArguments][name]);
+ s = core.String['+'](s, sep);
+ s = core.String['+'](s, `${name}: `);
+ s = core.String['+'](s, this[_convert](this[_namedArguments][name]));
sep = ', ';
}
- s = '}';
+ s = core.String['+'](s, '}');
}
- s = ') -> ';
+ s = core.String['+'](s, ') -> ');
if (this[_isVoid]) {
- s = 'void';
+ s = core.String['+'](s, 'void');
} else if (this[_hasReturnType]) {
- s = this[_convert](this[_returnType]);
+ s = core.String['+'](s, this[_convert](this[_returnType]));
} else {
- s = 'dynamic';
+ s = core.String['+'](s, 'dynamic');
}
return this[_cachedToString] = `${s}`;
}

Powered by Google App Engine
This is Rietveld 408576698