| OLD | NEW |
| 1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
| 2 // ********** Library dart:core ************** | 2 // ********** Library dart:core ************** |
| 3 // ********** Natives dart:core ************** | 3 // ********** Natives dart:core ************** |
| 4 /** | 4 /** |
| 5 * Generates a dynamic call stub for a function. | 5 * Generates a dynamic call stub for a function. |
| 6 * Our goal is to create a stub method like this on-the-fly: | 6 * Our goal is to create a stub method like this on-the-fly: |
| 7 * function($0, $1, capture) { this($0, $1, true, capture); } | 7 * function($0, $1, capture) { this($0, $1, true, capture); } |
| 8 * | 8 * |
| 9 * This stub then replaces the dynamic one on Function, with one that is | 9 * This stub then replaces the dynamic one on Function, with one that is |
| 10 * specialized for that particular function, taking into account its default | 10 * specialized for that particular function, taking into account its default |
| (...skipping 13922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13933 if ($notnull_bool(x.get$isConst()) && $notnull_bool(y.get$isConst())) { | 13933 if ($notnull_bool(x.get$isConst()) && $notnull_bool(y.get$isConst())) { |
| 13934 var value = (kind == 35/*TokenKind.AND*/) ? $notnull_bool(x.get$actualValu
e()) && $notnull_bool(y.get$actualValue()) : $notnull_bool(x.get$actualValue())
|| $notnull_bool(y.get$actualValue()); | 13934 var value = (kind == 35/*TokenKind.AND*/) ? $notnull_bool(x.get$actualValu
e()) && $notnull_bool(y.get$actualValue()) : $notnull_bool(x.get$actualValue())
|| $notnull_bool(y.get$actualValue()); |
| 13935 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v
alue, ('' + value), node.span); | 13935 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v
alue, ('' + value), node.span); |
| 13936 } | 13936 } |
| 13937 return new Value($globals.world.nonNullBool, code, node.span, true); | 13937 return new Value($globals.world.nonNullBool, code, node.span, true); |
| 13938 } | 13938 } |
| 13939 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT*
/) { | 13939 else if (kind == 50/*TokenKind.EQ_STRICT*/ || kind == 51/*TokenKind.NE_STRICT*
/) { |
| 13940 var x = this.visitValue(node.x); | 13940 var x = this.visitValue(node.x); |
| 13941 var y = this.visitValue(node.y); | 13941 var y = this.visitValue(node.y); |
| 13942 if ($notnull_bool(x.get$isConst()) && $notnull_bool(y.get$isConst())) { | 13942 if ($notnull_bool(x.get$isConst()) && $notnull_bool(y.get$isConst())) { |
| 13943 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(x.get$actualValue(), y
.get$actualValue()) : $ne(x.get$actualValue(), y.get$actualValue()); | 13943 var xVal = x.get$actualValue(); |
| 13944 var yVal = y.get$actualValue(); |
| 13945 if ($notnull_bool(x.get$type().get$isString()) && $notnull_bool(y.get$type
().get$isString()) && $notnull_bool($ne(xVal.$index(0), yVal.$index(0)))) { |
| 13946 if ($notnull_bool($eq(xVal.$index(0), '"'))) { |
| 13947 xVal = xVal.substring$2(1, xVal.length - 1); |
| 13948 yVal = toDoubleQuote($assert_String(yVal.substring$2(1, yVal.length -
1))); |
| 13949 } |
| 13950 else { |
| 13951 xVal = toDoubleQuote($assert_String(xVal.substring$2(1, xVal.length -
1))); |
| 13952 yVal = yVal.substring$2(1, yVal.length - 1); |
| 13953 } |
| 13954 } |
| 13955 var value = kind == 50/*TokenKind.EQ_STRICT*/ ? $eq(xVal, yVal) : $ne(xVal
, yVal); |
| 13944 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v
alue, ("" + value), node.span); | 13956 return EvaluatedValue.EvaluatedValue$factory($globals.world.nonNullBool, v
alue, ("" + value), node.span); |
| 13945 } | 13957 } |
| 13946 if ($notnull_bool($eq(x.get$code(), 'null')) || $notnull_bool($eq(y.get$code
(), 'null'))) { | 13958 if ($notnull_bool($eq(x.get$code(), 'null')) || $notnull_bool($eq(y.get$code
(), 'null'))) { |
| 13947 var op = node.op.toString().substring(0, 2); | 13959 var op = node.op.toString().substring(0, 2); |
| 13948 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + op
+ ' ' + y.get$code()), node.span, true); | 13960 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + op
+ ' ' + y.get$code()), node.span, true); |
| 13949 } | 13961 } |
| 13950 else { | 13962 else { |
| 13951 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + no
de.op + ' ' + y.get$code()), node.span, true); | 13963 return new Value($globals.world.nonNullBool, ('' + x.get$code() + ' ' + no
de.op + ' ' + y.get$code()), node.span, true); |
| 13952 } | 13964 } |
| 13953 } | 13965 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14329 var u = (item && item.is$UnaryExpression()); | 14341 var u = (item && item.is$UnaryExpression()); |
| 14330 return u.op.kind == 16/*TokenKind.INCR*/ || u.op.kind == 17/*TokenKind.DECR*
/; | 14342 return u.op.kind == 16/*TokenKind.INCR*/ || u.op.kind == 17/*TokenKind.DECR*
/; |
| 14331 } | 14343 } |
| 14332 else { | 14344 else { |
| 14333 return false; | 14345 return false; |
| 14334 } | 14346 } |
| 14335 } | 14347 } |
| 14336 MethodGenerator.prototype.visitLiteralExpression = function(node) { | 14348 MethodGenerator.prototype.visitLiteralExpression = function(node) { |
| 14337 var $0; | 14349 var $0; |
| 14338 var type = node.type.type; | 14350 var type = node.type.type; |
| 14339 $assert($ne(type, null), "type != null", "gen.dart", 2250, 12); | 14351 $assert($ne(type, null), "type != null", "gen.dart", 2264, 12); |
| 14340 if (!!(($0 = node.value) && $0.is$List)) { | 14352 if (!!(($0 = node.value) && $0.is$List)) { |
| 14341 var items = []; | 14353 var items = []; |
| 14342 var $list = node.value; | 14354 var $list = node.value; |
| 14343 for (var $i = node.value.iterator$0(); $i.hasNext$0(); ) { | 14355 for (var $i = node.value.iterator$0(); $i.hasNext$0(); ) { |
| 14344 var item = $i.next$0(); | 14356 var item = $i.next$0(); |
| 14345 var val = this.visitValue((item && item.is$lang_Expression())); | 14357 var val = this.visitValue((item && item.is$lang_Expression())); |
| 14346 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY()); | 14358 val.invoke$4(this, 'toString', item, Arguments.get$EMPTY()); |
| 14347 var code = val.get$code(); | 14359 var code = val.get$code(); |
| 14348 if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpr
ession) || (item instanceof PostfixExpression) || $notnull_bool(this._isUnaryInc
rement((item && item.is$lang_Expression())))) { | 14360 if ((item instanceof BinaryExpression) || (item instanceof ConditionalExpr
ession) || (item instanceof PostfixExpression) || $notnull_bool(this._isUnaryInc
rement((item && item.is$lang_Expression())))) { |
| 14349 code = ('(' + code + ')'); | 14361 code = ('(' + code + ')'); |
| 14350 } | 14362 } |
| 14351 if ($notnull_bool($eq(items.length, 0)) || ($notnull_bool($ne(code, "''"))
&& $notnull_bool($ne(code, '""')))) { | 14363 if ($notnull_bool($eq(items.length, 0)) || ($notnull_bool($ne(code, "''"))
&& $notnull_bool($ne(code, '""')))) { |
| 14352 items.add$1(code); | 14364 items.add$1(code); |
| 14353 } | 14365 } |
| 14354 } | 14366 } |
| 14355 return new Value(type, ('(' + Strings.join((items && items.is$List_String())
, " + ") + ')'), node.span, true); | 14367 return new Value(type, ('(' + Strings.join((items && items.is$List_String())
, " + ") + ')'), node.span, true); |
| 14356 } | 14368 } |
| 14357 var text = node.text; | 14369 var text = node.text; |
| 14358 if ($notnull_bool(type.get$isString())) { | 14370 if ($notnull_bool(type.get$isString())) { |
| 14359 if ($notnull_bool(text.startsWith$1('@'))) { | 14371 if ($notnull_bool(text.startsWith$1('@'))) { |
| 14360 text = MethodGenerator._escapeString(parseStringLiteral($assert_String(tex
t))); | 14372 text = MethodGenerator._escapeString(parseStringLiteral($assert_String(tex
t))); |
| 14361 text = ('"' + text + '"'); | 14373 text = ('"' + text + '"'); |
| 14362 } | 14374 } |
| 14363 else if ($notnull_bool(isMultilineString($assert_String(text)))) { | 14375 else if ($notnull_bool(isMultilineString($assert_String(text)))) { |
| 14364 text = parseStringLiteral($assert_String(text)); | 14376 text = parseStringLiteral($assert_String(text)); |
| 14365 text = text.replaceAll$2('\n', '\\n'); | 14377 text = text.replaceAll$2('\n', '\\n'); |
| 14366 text = text.replaceAll$2('"', '\\"'); | 14378 text = toDoubleQuote($assert_String(text)); |
| 14367 text = ('"' + text + '"'); | 14379 text = ('"' + text + '"'); |
| 14368 } | 14380 } |
| 14369 if (text !== node.text) { | 14381 if (text !== node.text) { |
| 14370 node.value = text; | 14382 node.value = text; |
| 14371 node.text = $assert_String(text); | 14383 node.text = $assert_String(text); |
| 14372 } | 14384 } |
| 14373 } | 14385 } |
| 14374 return EvaluatedValue.EvaluatedValue$factory((type && type.is$lang_Type()), no
de.value, node.text, null); | 14386 return EvaluatedValue.EvaluatedValue$factory((type && type.is$lang_Type()), no
de.value, node.text, null); |
| 14375 } | 14387 } |
| 14376 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { | 14388 MethodGenerator.prototype.visitPostfixExpression$1 = function($0) { |
| (...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16032 var $list = this.declaringType.get$members().getValues(); | 16044 var $list = this.declaringType.get$members().getValues(); |
| 16033 for (var $i = this.declaringType.get$members().getValues().iterator$0(); $i.ha
sNext$0(); ) { | 16045 for (var $i = this.declaringType.get$members().getValues().iterator$0(); $i.ha
sNext$0(); ) { |
| 16034 var f = $i.next$0(); | 16046 var f = $i.next$0(); |
| 16035 if ((f instanceof FieldMember) && !$notnull_bool(f.get$isStatic()) && $notnu
ll_bool($ne(f.get$value(), null)) && !fields.containsKey(f.get$name())) { | 16047 if ((f instanceof FieldMember) && !$notnull_bool(f.get$isStatic()) && $notnu
ll_bool($ne(f.get$value(), null)) && !fields.containsKey(f.get$name())) { |
| 16036 fields.$setindex(f.get$name(), f.computeValue$0()); | 16048 fields.$setindex(f.get$name(), f.computeValue$0()); |
| 16037 } | 16049 } |
| 16038 } | 16050 } |
| 16039 return $globals.world.gen.globalForConst(ConstObjectValue.ConstObjectValue$fac
tory(target.type, fields, code, node.span), args.values); | 16051 return $globals.world.gen.globalForConst(ConstObjectValue.ConstObjectValue$fac
tory(target.type, fields, code, node.span), args.values); |
| 16040 } | 16052 } |
| 16041 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar
gsCode, isDynamic) { | 16053 MethodMember.prototype._invokeBuiltin = function(context, node, target, args, ar
gsCode, isDynamic) { |
| 16054 var $0; |
| 16042 var allConst = $notnull_bool(target.get$isConst()) && args.values.every((funct
ion (arg) { | 16055 var allConst = $notnull_bool(target.get$isConst()) && args.values.every((funct
ion (arg) { |
| 16043 return arg.get$isConst(); | 16056 return arg.get$isConst(); |
| 16044 }) | 16057 }) |
| 16045 ); | 16058 ); |
| 16046 if ($notnull_bool(this.declaringType.get$isNum())) { | 16059 if ($notnull_bool(this.declaringType.get$isNum())) { |
| 16047 if (!$notnull_bool(allConst)) { | 16060 if (!$notnull_bool(allConst)) { |
| 16048 var code; | 16061 var code; |
| 16049 if (this.name == '\$negate') { | 16062 if (this.name == '\$negate') { |
| 16050 code = ('-' + target.code); | 16063 code = ('-' + target.code); |
| 16051 } | 16064 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16175 } | 16188 } |
| 16176 return EvaluatedValue.EvaluatedValue$factory(this.get$inferredResult(), va
lue, ("" + value), node.span); | 16189 return EvaluatedValue.EvaluatedValue$factory(this.get$inferredResult(), va
lue, ("" + value), node.span); |
| 16177 } | 16190 } |
| 16178 } | 16191 } |
| 16179 else if ($notnull_bool(this.declaringType.get$isString())) { | 16192 else if ($notnull_bool(this.declaringType.get$isString())) { |
| 16180 if (this.name == '\$index') { | 16193 if (this.name == '\$index') { |
| 16181 return new Value(this.declaringType, ('' + target.code + '[' + argsCode.$i
ndex(0) + ']'), node.span, true); | 16194 return new Value(this.declaringType, ('' + target.code + '[' + argsCode.$i
ndex(0) + ']'), node.span, true); |
| 16182 } | 16195 } |
| 16183 else if (this.name == '\$add') { | 16196 else if (this.name == '\$add') { |
| 16184 if ($notnull_bool(allConst)) { | 16197 if ($notnull_bool(allConst)) { |
| 16185 var val0 = target.get$dynamic().get$actualValue(); | 16198 var value = this._normConcat(target, (($0 = args.values.$index(0)) && $0
.is$Value())); |
| 16186 val0 = val0.substring$2(1, val0.length - 1); | 16199 return EvaluatedValue.EvaluatedValue$factory($globals.world.stringType,
value, value, node.span); |
| 16187 var val1 = args.values.$index(0).get$dynamic().get$actualValue(); | |
| 16188 if ($notnull_bool(args.values.$index(0).get$type().get$isString())) { | |
| 16189 val1 = val1.substring$2(1, val1.length - 1); | |
| 16190 } | |
| 16191 var value = ('' + val0 + val1); | |
| 16192 value = '"' + value.replaceAll$2('"', '\\"') + '"'; | |
| 16193 return EvaluatedValue.EvaluatedValue$factory($globals.world.stringType,
value, $assert_String(value), node.span); | |
| 16194 } | 16200 } |
| 16195 return new Value(this.declaringType, ('' + target.code + ' + ' + argsCode.
$index(0)), node.span, true); | 16201 return new Value(this.declaringType, ('' + target.code + ' + ' + argsCode.
$index(0)), node.span, true); |
| 16196 } | 16202 } |
| 16197 } | 16203 } |
| 16198 else if ($notnull_bool(this.declaringType.get$isNative())) { | 16204 else if ($notnull_bool(this.declaringType.get$isNative())) { |
| 16199 if (this.name == '\$index') { | 16205 if (this.name == '\$index') { |
| 16200 return new Value(this.returnType, ('' + target.code + '[' + argsCode.$inde
x(0) + ']'), node.span, true); | 16206 return new Value(this.returnType, ('' + target.code + '[' + argsCode.$inde
x(0) + ']'), node.span, true); |
| 16201 } | 16207 } |
| 16202 else if (this.name == '\$setindex') { | 16208 else if (this.name == '\$setindex') { |
| 16203 return new Value(this.returnType, ('' + target.code + '[' + argsCode.$inde
x(0) + '] = ' + argsCode.$index(1)), node.span, true); | 16209 return new Value(this.returnType, ('' + target.code + '[' + argsCode.$inde
x(0) + '] = ' + argsCode.$index(1)), node.span, true); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 16229 } | 16235 } |
| 16230 if (this.name == '\$index') { | 16236 if (this.name == '\$index') { |
| 16231 $globals.world.gen.corejs.useIndex = true; | 16237 $globals.world.gen.corejs.useIndex = true; |
| 16232 } | 16238 } |
| 16233 else if (this.name == '\$setindex') { | 16239 else if (this.name == '\$setindex') { |
| 16234 $globals.world.gen.corejs.useSetIndex = true; | 16240 $globals.world.gen.corejs.useSetIndex = true; |
| 16235 } | 16241 } |
| 16236 var argsString = Strings.join((argsCode && argsCode.is$List_String()), ', '); | 16242 var argsString = Strings.join((argsCode && argsCode.is$List_String()), ', '); |
| 16237 return new Value(this.get$inferredResult(), ('' + target.code + '.' + this.get
$jsname() + '(' + argsString + ')'), node.span, true); | 16243 return new Value(this.get$inferredResult(), ('' + target.code + '.' + this.get
$jsname() + '(' + argsString + ')'), node.span, true); |
| 16238 } | 16244 } |
| 16245 MethodMember.prototype._normConcat = function(a, b) { |
| 16246 $assert(b.type.get$isString(), "b.type.isString", "member.dart", 1250, 12); |
| 16247 var val0 = a.get$dynamic().get$actualValue(); |
| 16248 var quote0 = val0.$index(0); |
| 16249 val0 = val0.substring$2(1, val0.length - 1); |
| 16250 var val1 = b.get$dynamic().get$actualValue(); |
| 16251 var quote1 = null; |
| 16252 if ($notnull_bool(b.type.get$isString())) { |
| 16253 quote1 = val1.$index(0); |
| 16254 val1 = val1.substring$2(1, val1.length - 1); |
| 16255 } |
| 16256 var value; |
| 16257 if ($notnull_bool($eq(quote0, quote1)) || $notnull_bool(quote1 == null)) { |
| 16258 value = ('' + quote0 + val0 + val1 + quote0); |
| 16259 } |
| 16260 else if ($notnull_bool($eq(quote0, '"'))) { |
| 16261 $assert($eq(quote1, "'"), "quote1 == \"'\"", "member.dart", 1268, 14); |
| 16262 value = ('' + quote0 + val0 + toDoubleQuote($assert_String(val1)) + quote0); |
| 16263 } |
| 16264 else { |
| 16265 $assert($eq(quote1, '"'), "quote1 == '\"'", "member.dart", 1271, 14); |
| 16266 value = ('' + quote1 + toDoubleQuote($assert_String(val0)) + val1 + quote1); |
| 16267 } |
| 16268 return $assert_String(value); |
| 16269 } |
| 16239 MethodMember.prototype.resolve = function() { | 16270 MethodMember.prototype.resolve = function() { |
| 16240 var $0; | 16271 var $0; |
| 16241 this.isStatic = this.declaringType.get$isTop(); | 16272 this.isStatic = this.declaringType.get$isTop(); |
| 16242 this.isConst = false; | 16273 this.isConst = false; |
| 16243 this.isFactory = false; | 16274 this.isFactory = false; |
| 16244 this.isAbstract = !$notnull_bool(this.declaringType.get$isClass()); | 16275 this.isAbstract = !$notnull_bool(this.declaringType.get$isClass()); |
| 16245 if (this.definition.modifiers != null) { | 16276 if (this.definition.modifiers != null) { |
| 16246 var $list = this.definition.modifiers; | 16277 var $list = this.definition.modifiers; |
| 16247 for (var $i = 0;$i < $list.length; $i++) { | 16278 for (var $i = 0;$i < $list.length; $i++) { |
| 16248 var mod = $list.$index($i); | 16279 var mod = $list.$index($i); |
| (...skipping 7365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 23614 values.add(map.$index(k)); | 23645 values.add(map.$index(k)); |
| 23615 } | 23646 } |
| 23616 return values; | 23647 return values; |
| 23617 } | 23648 } |
| 23618 function isMultilineString(text) { | 23649 function isMultilineString(text) { |
| 23619 return text.startsWith('"""') || text.startsWith("'''"); | 23650 return text.startsWith('"""') || text.startsWith("'''"); |
| 23620 } | 23651 } |
| 23621 function isRawMultilineString(text) { | 23652 function isRawMultilineString(text) { |
| 23622 return text.startsWith('@"""') || text.startsWith("@'''"); | 23653 return text.startsWith('@"""') || text.startsWith("@'''"); |
| 23623 } | 23654 } |
| 23655 function toDoubleQuote(s) { |
| 23656 return s.replaceAll('"', '\\"').replaceAll("\\'", "'"); |
| 23657 } |
| 23624 function parseStringLiteral(lit) { | 23658 function parseStringLiteral(lit) { |
| 23625 if (lit.startsWith('@')) { | 23659 if (lit.startsWith('@')) { |
| 23626 if ($notnull_bool(isRawMultilineString(lit))) { | 23660 if ($notnull_bool(isRawMultilineString(lit))) { |
| 23627 return stripLeadingNewline(lit.substring(4, lit.length - 3)); | 23661 return stripLeadingNewline(lit.substring(4, lit.length - 3)); |
| 23628 } | 23662 } |
| 23629 else { | 23663 else { |
| 23630 return lit.substring(2, lit.length - 1); | 23664 return lit.substring(2, lit.length - 1); |
| 23631 } | 23665 } |
| 23632 } | 23666 } |
| 23633 else if ($notnull_bool(isMultilineString(lit))) { | 23667 else if ($notnull_bool(isMultilineString(lit))) { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 24068 NATIVE, | 24102 NATIVE, |
| 24069 NEGATE, | 24103 NEGATE, |
| 24070 OPERATOR, | 24104 OPERATOR, |
| 24071 SET, | 24105 SET, |
| 24072 SOURCE, | 24106 SOURCE, |
| 24073 STATIC, | 24107 STATIC, |
| 24074 TYPEDEF ]*/; | 24108 TYPEDEF ]*/; |
| 24075 var $globals = {}; | 24109 var $globals = {}; |
| 24076 $static_init(); | 24110 $static_init(); |
| 24077 main(); | 24111 main(); |
| OLD | NEW |