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

Side by Side Diff: frog/value.dart

Issue 8481023: cleanup errors and fix a couple field negative tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « frog/type.dart ('k') | frog/world.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * Represents a meta-value for code generation. 6 * Represents a meta-value for code generation.
7 */ 7 */
8 class Value { 8 class Value {
9 /** The [Type] of the [Value]. */ 9 /** The [Type] of the [Value]. */
10 Type type; 10 Type type;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 if (type.isVarOrFunction && name == '\$call') { 104 if (type.isVarOrFunction && name == '\$call') {
105 return true; 105 return true;
106 } 106 }
107 107
108 var member = _tryResolveMember(context, name); 108 var member = _tryResolveMember(context, name);
109 return member != null && member.canInvoke(context, args); 109 return member != null && member.canInvoke(context, args);
110 } 110 }
111 111
112 // TODO(jimhug): Better type here - currently is union(Member, MemberSet)
112 _tryResolveMember(MethodGenerator context, String name) { 113 _tryResolveMember(MethodGenerator context, String name) {
113 var member = null; 114 var member = null;
114 if (!type.isVar) { 115 if (!type.isVar) {
115 if (isSuper) { 116 if (isSuper) {
116 return type.getMember(name); 117 return type.getMember(name);
117 } else { 118 } else {
118 member = type.resolveMember(name); 119 member = type.resolveMember(name);
119 } 120 }
120 } 121 }
122
121 if (member == null) { 123 if (member == null) {
122 // TODO(jmesserly): shouldn't look in world except for "var" 124 // TODO(jmesserly): shouldn't look in world except for "var"
123 member = context.findMembers(name); 125 member = context.findMembers(name);
124 } 126 }
125 return member; 127 return member;
126 } 128 }
127 129
128 _resolveMember(MethodGenerator context, String name, Node node) { 130 _resolveMember(MethodGenerator context, String name, Node node) {
129 var member = _tryResolveMember(context, name); 131 var member = _tryResolveMember(context, name);
130 if (member == null) { 132 if (member != null) {
133 if (isType && !member.isStatic) {
134 world.error('can not refer to instance member as static', node.span);
135 }
136 return member;
137 } else {
131 // TODO(jmesserly): we suppress warnings if someone has overridden 138 // TODO(jmesserly): we suppress warnings if someone has overridden
132 // noSuchMethod, and we know it will call their version. Is that right? 139 // noSuchMethod, and we know it will call their version. Is that right?
133 if (_tryResolveMember(context, 'noSuchMethod').members.length > 1) { 140 if (_tryResolveMember(context, 'noSuchMethod').members.length > 1) {
134 return null; 141 return null;
135 } 142 }
136 143
137 var typeName = type.name == null ? type.library.name : type.name; 144 var typeName = type.name == null ? type.library.name : type.name;
138 var message = 'can not resolve "$name" on "${typeName}"'; 145 var message = 'can not resolve "$name" on "${typeName}"';
139 if (isType) { 146 if (isType) {
140 world.error(message, node.span); 147 world.error(message, node.span);
141 } else { 148 } else {
142 world.warning(message, node.span); 149 world.warning(message, node.span);
143 } 150 }
144 // TODO(jmesserly): isn't this condition always true if we got here? 151 // TODO(jmesserly): isn't this condition always true if we got here?
145 if (context.findMembers(name) == null) { 152 if (context.findMembers(name) == null) {
146 world.warning('$name is not defined anywhere in the world.', node.span); 153 world.warning('$name is not defined anywhere in the world.', node.span);
147 } 154 }
155 return null;
148 } 156 }
149 return member;
150 } 157 }
151 158
152 checkFirstClass(SourceSpan span) { 159 checkFirstClass(SourceSpan span) {
153 if (isType) { 160 if (isType) {
154 world.error('Types are not first class', span); 161 world.error('Types are not first class', span);
155 } 162 }
156 } 163 }
157 164
158 /** Generate a call to an unknown function type. */ 165 /** Generate a call to an unknown function type. */
159 Value _varCall(MethodGenerator context, Arguments args) { 166 Value _varCall(MethodGenerator context, Arguments args) {
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 return 1; 598 return 1;
592 } else if (name != null && other.name == null) { 599 } else if (name != null && other.name == null) {
593 return -1; 600 return -1;
594 } else if (name != null) { 601 } else if (name != null) {
595 return name.compareTo(other.name); 602 return name.compareTo(other.name);
596 } else { 603 } else {
597 return field.name.compareTo(other.field.name); 604 return field.name.compareTo(other.field.name);
598 } 605 }
599 } 606 }
600 } 607 }
OLDNEW
« no previous file with comments | « frog/type.dart ('k') | frog/world.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698