| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Top level generator object for writing code and keeping track of | 6 * Top level generator object for writing code and keeping track of |
| 7 * dependencies. | 7 * dependencies. |
| 8 * | 8 * |
| 9 * Should have two compilation models, but only one implemented so far. | 9 * Should have two compilation models, but only one implemented so far. |
| 10 * | 10 * |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 } else if (init is BinaryExpression | 840 } else if (init is BinaryExpression |
| 841 && TokenKind.kindFromAssign(init.op.kind) == 0) { | 841 && TokenKind.kindFromAssign(init.op.kind) == 0) { |
| 842 | 842 |
| 843 var left = init.x; | 843 var left = init.x; |
| 844 if (!(left is DotExpression && left.self is ThisExpression | 844 if (!(left is DotExpression && left.self is ThisExpression |
| 845 || left is VarExpression)) { | 845 || left is VarExpression)) { |
| 846 world.error('invalid left side of initializer', left.span); | 846 world.error('invalid left side of initializer', left.span); |
| 847 continue; | 847 continue; |
| 848 } | 848 } |
| 849 | 849 |
| 850 initializedFields.add(left.name.name); | 850 var f = method.declaringType.getMember(left.name.name); |
| 851 var assign = _makeThisValue(null).set_( | 851 if (f == null) { |
| 852 this, left.name.name, left.name, visitValue(init.y)); | 852 world.error('bad initializer - no matching field', left.span); |
| 853 writer.writeln('${assign.code};'); | 853 continue; |
| 854 } else if (!f.isField) { |
| 855 world.error('"${left.name.name}" does not refer to a field', |
| 856 left.span); |
| 857 continue; |
| 858 } |
| 859 |
| 860 initializedFields.add(f.name); |
| 861 writer.writeln('this.${f.jsname} = ${visitValue(init.y).code};'); |
| 854 } else { | 862 } else { |
| 855 world.error('invalid initializer', init.span); | 863 world.error('invalid initializer', init.span); |
| 856 } | 864 } |
| 857 } | 865 } |
| 858 | 866 |
| 859 if (initializerCall != null) { | 867 if (initializerCall != null) { |
| 860 var target = _writeInitializerCall(initializerCall); | 868 var target = _writeInitializerCall(initializerCall); |
| 861 if (!target.isSuper) { | 869 if (!target.isSuper) { |
| 862 // when calling another constructor on the same class | 870 // when calling another constructor on the same class |
| 863 // no other initialization is allowed | 871 // no other initialization is allowed |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); | 2234 result.add(new Value(world.varType, '\$$i', null, /*needsTemp:*/false)); |
| 2227 } | 2235 } |
| 2228 for (int i = bareCount; i < length; i++) { | 2236 for (int i = bareCount; i < length; i++) { |
| 2229 var name = getName(i); | 2237 var name = getName(i); |
| 2230 if (name == null) name = '\$$i'; | 2238 if (name == null) name = '\$$i'; |
| 2231 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); | 2239 result.add(new Value(world.varType, name, null, /*needsTemp:*/false)); |
| 2232 } | 2240 } |
| 2233 return new Arguments(nodes, result); | 2241 return new Arguments(nodes, result); |
| 2234 } | 2242 } |
| 2235 } | 2243 } |
| OLD | NEW |