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 19260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19271 this.span = span; | 19271 this.span = span; |
19272 this.isSuper = isSuper; | 19272 this.isSuper = isSuper; |
19273 this.needsTemp = needsTemp; | 19273 this.needsTemp = needsTemp; |
19274 this.isType = isType; | 19274 this.isType = isType; |
19275 // Initializers done | 19275 // Initializers done |
19276 if ($notnull_bool(this.type == null)) this.type = world.varType; | 19276 if ($notnull_bool(this.type == null)) this.type = world.varType; |
19277 } | 19277 } |
19278 Value.prototype.is$Value = function(){return this;}; | 19278 Value.prototype.is$Value = function(){return this;}; |
19279 Value.prototype.get$span = function() { return this.span; }; | 19279 Value.prototype.get$span = function() { return this.span; }; |
19280 Value.prototype.set$span = function(value) { return this.span = value; }; | 19280 Value.prototype.set$span = function(value) { return this.span = value; }; |
| 19281 Value.prototype.get$_typeIsVarOrParameterType = function() { |
| 19282 return this.type.get$isVar() || (this.type instanceof ParameterType); |
| 19283 } |
19281 Value.prototype.get$isConst = function() { | 19284 Value.prototype.get$isConst = function() { |
19282 return false; | 19285 return false; |
19283 } | 19286 } |
19284 Value.prototype.get_ = function(context, name, node) { | 19287 Value.prototype.get_ = function(context, name, node) { |
19285 var member = this._resolveMember(context, name, node, false); | 19288 var member = this._resolveMember(context, name, node, false); |
19286 if ($notnull_bool($ne(member, null))) { | 19289 if ($notnull_bool($ne(member, null))) { |
19287 return member._get$3(context, node, this); | 19290 return member._get$3(context, node, this); |
19288 } | 19291 } |
19289 else { | 19292 else { |
19290 return this.invokeNoSuchMethod(context, ('get:' + name + ''), node); | 19293 return this.invokeNoSuchMethod(context, ('get:' + name + ''), node); |
19291 } | 19294 } |
19292 } | 19295 } |
19293 Value.prototype.set_ = function(context, name, node, value, isDynamic) { | 19296 Value.prototype.set_ = function(context, name, node, value, isDynamic) { |
19294 var member = this._resolveMember(context, name, node, isDynamic); | 19297 var member = this._resolveMember(context, name, node, isDynamic); |
19295 if ($notnull_bool($ne(member, null))) { | 19298 if ($notnull_bool($ne(member, null))) { |
19296 return member._set(context, node, this, value, isDynamic); | 19299 return member._set(context, node, this, value, isDynamic); |
19297 } | 19300 } |
19298 else { | 19301 else { |
19299 return this.invokeNoSuchMethod(context, ('set:' + name + ''), node, new Argu
ments(null, [value])); | 19302 return this.invokeNoSuchMethod(context, ('set:' + name + ''), node, new Argu
ments(null, [value])); |
19300 } | 19303 } |
19301 } | 19304 } |
19302 Value.prototype.invoke = function(context, name, node, args, isDynamic) { | 19305 Value.prototype.invoke = function(context, name, node, args, isDynamic) { |
19303 if ($notnull_bool(this.type.get$isVar() && name == '\$ne')) { | 19306 if ($notnull_bool(this.get$_typeIsVarOrParameterType() && name == '\$ne')) { |
19304 if ($notnull_bool(args.values.length != 1)) { | 19307 if ($notnull_bool(args.values.length != 1)) { |
19305 world.warning('wrong number of arguments for !=', node.span); | 19308 world.warning('wrong number of arguments for !=', node.span); |
19306 } | 19309 } |
19307 world.gen.corejs.useOperator('\$ne'); | 19310 world.gen.corejs.useOperator('\$ne'); |
19308 return new Value(null, ('\$ne(' + this.code + ', ' + args.values.$index(0).c
ode + ')'), node.span, false, true, false); | 19311 return new Value(null, ('\$ne(' + this.code + ', ' + args.values.$index(0).c
ode + ')'), node.span, false, true, false); |
19309 } | 19312 } |
19310 if ($notnull_bool(name == '\$call')) { | 19313 if ($notnull_bool(name == '\$call')) { |
19311 if ($notnull_bool(this.isType)) { | 19314 if ($notnull_bool(this.isType)) { |
19312 world.error('must use "new" or "const" to construct a new instance', node.
span); | 19315 world.error('must use "new" or "const" to construct a new instance', node.
span); |
19313 } | 19316 } |
19314 if ($notnull_bool(this.type.needsVarCall(args))) { | 19317 if ($notnull_bool(this.type.needsVarCall(args))) { |
19315 return this._varCall(context, args); | 19318 return this._varCall(context, args); |
19316 } | 19319 } |
19317 } | 19320 } |
19318 var member = this._resolveMember(context, name, node, isDynamic); | 19321 var member = this._resolveMember(context, name, node, isDynamic); |
19319 if ($notnull_bool(member == null)) { | 19322 if ($notnull_bool(member == null)) { |
19320 return this.invokeNoSuchMethod(context, name, node, args); | 19323 return this.invokeNoSuchMethod(context, name, node, args); |
19321 } | 19324 } |
19322 else { | 19325 else { |
19323 return member.invoke(context, node, this, args, isDynamic); | 19326 return member.invoke(context, node, this, args, isDynamic); |
19324 } | 19327 } |
19325 } | 19328 } |
19326 Value.prototype.canInvoke = function(context, name, args) { | 19329 Value.prototype.canInvoke = function(context, name, args) { |
19327 if ($notnull_bool(this.type.get$isVar() && name == '\$ne')) { | 19330 if ($notnull_bool(this.get$_typeIsVarOrParameterType() && name == '\$ne')) { |
19328 return true; | 19331 return true; |
19329 } | 19332 } |
19330 if ($notnull_bool(this.type.get$isVarOrFunction() && name == '\$call')) { | 19333 if ($notnull_bool(this.type.get$isVarOrFunction() && name == '\$call')) { |
19331 return true; | 19334 return true; |
19332 } | 19335 } |
19333 var member = this._resolveMember(context, name, null, true); | 19336 var member = this._resolveMember(context, name, null, true); |
19334 return $ne(member, null) && member.canInvoke(context, args); | 19337 return $ne(member, null) && member.canInvoke(context, args); |
19335 } | 19338 } |
19336 Value.prototype._hasOverriddenNoSuchMethod = function() { | 19339 Value.prototype._hasOverriddenNoSuchMethod = function() { |
19337 if ($notnull_bool(this.isSuper)) { | 19340 if ($notnull_bool(this.isSuper)) { |
19338 var m = this.type.getMember('noSuchMethod'); | 19341 var m = this.type.getMember('noSuchMethod'); |
19339 return $ne(m, null) && !$notnull_bool(m.declaringType.get$isObject()); | 19342 return $ne(m, null) && !$notnull_bool(m.declaringType.get$isObject()); |
19340 } | 19343 } |
19341 else { | 19344 else { |
19342 return this.type.resolveMember('noSuchMethod').members.length > 1; | 19345 return this.type.resolveMember('noSuchMethod').members.length > 1; |
19343 } | 19346 } |
19344 } | 19347 } |
19345 Value.prototype._tryResolveMember = function(context, name) { | 19348 Value.prototype._tryResolveMember = function(context, name) { |
19346 if ($notnull_bool(this.isSuper)) { | 19349 if ($notnull_bool(this.isSuper)) { |
19347 return this.type.getMember(name); | 19350 return this.type.getMember(name); |
19348 } | 19351 } |
19349 else { | 19352 else { |
19350 return this.type.resolveMember(name); | 19353 return this.type.resolveMember(name); |
19351 } | 19354 } |
19352 } | 19355 } |
19353 Value.prototype._resolveMember = function(context, name, node, isDynamic) { | 19356 Value.prototype._resolveMember = function(context, name, node, isDynamic) { |
19354 var member; | 19357 var member; |
19355 if ($notnull_bool(!$notnull_bool(this.type.get$isVar()) && !(this.type instanc
eof ParameterType))) { | 19358 if ($notnull_bool(!$notnull_bool(this.get$_typeIsVarOrParameterType()))) { |
19356 member = this._tryResolveMember(context, name); | 19359 member = this._tryResolveMember(context, name); |
19357 if ($notnull_bool($ne(member, null) && this.isType && !$notnull_bool(member.
get$isStatic()))) { | 19360 if ($notnull_bool($ne(member, null) && this.isType && !$notnull_bool(member.
get$isStatic()))) { |
19358 if ($notnull_bool(!$notnull_bool(isDynamic))) { | 19361 if ($notnull_bool(!$notnull_bool(isDynamic))) { |
19359 world.error('can not refer to instance member as static', node.span); | 19362 world.error('can not refer to instance member as static', node.span); |
19360 } | 19363 } |
19361 return null; | 19364 return null; |
19362 } | 19365 } |
19363 if ($notnull_bool(member == null && !$notnull_bool(isDynamic) && !$notnull_b
ool(this._hasOverriddenNoSuchMethod()))) { | 19366 if ($notnull_bool(member == null && !$notnull_bool(isDynamic) && !$notnull_b
ool(this._hasOverriddenNoSuchMethod()))) { |
19364 var typeName = $notnull_bool(this.type.name == null) ? this.type.get$libra
ry().name : this.type.name; | 19367 var typeName = $notnull_bool(this.type.name == null) ? this.type.get$libra
ry().name : this.type.name; |
19365 var message = ('can not resolve "' + name + '" on "' + typeName + '"'); | 19368 var message = ('can not resolve "' + name + '" on "' + typeName + '"'); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19538 for (var i = 0; | 19541 for (var i = 0; |
19539 $notnull_bool(i < args.get$length()); i++) { | 19542 $notnull_bool(i < args.get$length()); i++) { |
19540 argsCode.add(args.values.$index(i).code); | 19543 argsCode.add(args.values.$index(i).code); |
19541 } | 19544 } |
19542 pos = Strings.join((argsCode && argsCode.is$List$String()), ", "); | 19545 pos = Strings.join((argsCode && argsCode.is$List$String()), ", "); |
19543 } | 19546 } |
19544 var noSuchArgs = [new Value(world.stringType, ('"' + name + '"'), node.span, f
alse, true, false), new Value(world.listType, ('[' + pos + ']'), node.span, fals
e, true, false)]; | 19547 var noSuchArgs = [new Value(world.stringType, ('"' + name + '"'), node.span, f
alse, true, false), new Value(world.listType, ('[' + pos + ']'), node.span, fals
e, true, false)]; |
19545 return this._resolveMember(context, 'noSuchMethod', node, false).invoke$4(cont
ext, node, this, new Arguments(null, noSuchArgs)); | 19548 return this._resolveMember(context, 'noSuchMethod', node, false).invoke$4(cont
ext, node, this, new Arguments(null, noSuchArgs)); |
19546 } | 19549 } |
19547 Value.prototype.invokeSpecial = function(name, args, returnType) { | 19550 Value.prototype.invokeSpecial = function(name, args, returnType) { |
19548 $assert(name.startsWith('\$'), "name.startsWith('\\$')", "value.dart", 446, 12
); | 19551 $assert(name.startsWith('\$'), "name.startsWith('\\$')", "value.dart", 447, 12
); |
19549 $assert(!$notnull_bool(args.get$hasNames()), "!args.hasNames", "value.dart", 4
47, 12); | 19552 $assert(!$notnull_bool(args.get$hasNames()), "!args.hasNames", "value.dart", 4
48, 12); |
19550 var argsString = args.getCode(); | 19553 var argsString = args.getCode(); |
19551 if ($notnull_bool(name == '\$index' || name == '\$setindex')) { | 19554 if ($notnull_bool(name == '\$index' || name == '\$setindex')) { |
19552 return new Value(returnType, ('' + this.code + '.' + name + '(' + argsString
+ ')'), this.span, false, true, false); | 19555 return new Value(returnType, ('' + this.code + '.' + name + '(' + argsString
+ ')'), this.span, false, true, false); |
19553 } | 19556 } |
19554 else { | 19557 else { |
19555 if ($notnull_bool(argsString.length > 0)) argsString = (', ' + argsString +
''); | 19558 if ($notnull_bool(argsString.length > 0)) argsString = (', ' + argsString +
''); |
19556 world.gen.corejs.useOperator(name); | 19559 world.gen.corejs.useOperator(name); |
19557 return new Value(returnType, ('' + name + '(' + this.code + '' + argsString
+ ')'), this.span, false, true, false); | 19560 return new Value(returnType, ('' + name + '(' + this.code + '' + argsString
+ ')'), this.span, false, true, false); |
19558 } | 19561 } |
19559 } | 19562 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19700 } | 19703 } |
19701 } | 19704 } |
19702 // ********** Code for BareValue ************** | 19705 // ********** Code for BareValue ************** |
19703 function BareValue(home, outermost, span) { | 19706 function BareValue(home, outermost, span) { |
19704 this.home = home; | 19707 this.home = home; |
19705 Value.call(this, outermost.method.declaringType, null, span, false, false, out
ermost.get$isStatic()); | 19708 Value.call(this, outermost.method.declaringType, null, span, false, false, out
ermost.get$isStatic()); |
19706 // Initializers done | 19709 // Initializers done |
19707 } | 19710 } |
19708 $inherits(BareValue, Value); | 19711 $inherits(BareValue, Value); |
19709 BareValue.prototype._tryResolveMember = function(context, name) { | 19712 BareValue.prototype._tryResolveMember = function(context, name) { |
19710 $assert($eq(context, this.home), "context == home", "value.dart", 650, 12); | 19713 $assert($eq(context, this.home), "context == home", "value.dart", 651, 12); |
19711 var member = this.type.resolveMember(name); | 19714 var member = this.type.resolveMember(name); |
19712 if ($notnull_bool($ne(member, null))) { | 19715 if ($notnull_bool($ne(member, null))) { |
19713 $assert(this.code == null, "code == null", "value.dart", 655, 14); | 19716 $assert(this.code == null, "code == null", "value.dart", 656, 14); |
19714 if ($notnull_bool(this.isType)) { | 19717 if ($notnull_bool(this.isType)) { |
19715 this.code = this.type.get$jsname(); | 19718 this.code = this.type.get$jsname(); |
19716 } | 19719 } |
19717 else { | 19720 else { |
19718 this.code = this.home._makeThisCode(); | 19721 this.code = this.home._makeThisCode(); |
19719 } | 19722 } |
19720 return member; | 19723 return member; |
19721 } | 19724 } |
19722 member = this.home.get$library().lookup(name, this.span); | 19725 member = this.home.get$library().lookup(name, this.span); |
19723 if ($notnull_bool($ne(member, null))) { | 19726 if ($notnull_bool($ne(member, null))) { |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20623 INTERFACE, | 20626 INTERFACE, |
20624 LIBRARY, | 20627 LIBRARY, |
20625 NATIVE, | 20628 NATIVE, |
20626 NEGATE, | 20629 NEGATE, |
20627 OPERATOR, | 20630 OPERATOR, |
20628 SET, | 20631 SET, |
20629 SOURCE, | 20632 SOURCE, |
20630 STATIC, | 20633 STATIC, |
20631 TYPEDEF ]*/; | 20634 TYPEDEF ]*/; |
20632 RunEntry(function () {main();}, []); | 20635 RunEntry(function () {main();}, []); |
OLD | NEW |