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

Unified Diff: pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart

Issue 2938193003: Revert "Towards compiling Hello World!" and "Compile and run Hello World!" (Closed)
Patch Set: Created 3 years, 6 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: pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart
diff --git a/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart
index 1754c5438bd2c69bc0a559c6a7b6a56ec72251ef..a018b6f5b3387e838537d6cede33166031361018 100644
--- a/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/parameter_stub_generator.dart
@@ -8,9 +8,18 @@ import '../closure.dart' show ClosureClassElement;
import '../common.dart';
import '../common_elements.dart';
import '../constants/values.dart';
+import '../elements/elements.dart'
+ show
+ ClassElement,
+ FunctionElement,
+ FunctionSignature,
+ MethodElement,
+ ParameterElement;
import '../elements/entities.dart';
import '../js/js.dart' as jsAst;
import '../js/js.dart' show js;
+import '../js_backend/constant_handler_javascript.dart'
+ show JavaScriptConstantCompiler;
import '../js_backend/namer.dart' show Namer;
import '../js_backend/native_data.dart';
import '../js_backend/interceptor_data.dart';
@@ -29,6 +38,7 @@ class ParameterStubGenerator {
final CommonElements _commonElements;
final CodeEmitterTask _emitterTask;
+ final JavaScriptConstantCompiler _constants;
final Namer _namer;
final NativeData _nativeData;
final InterceptorData _interceptorData;
@@ -38,6 +48,7 @@ class ParameterStubGenerator {
ParameterStubGenerator(
this._commonElements,
this._emitterTask,
+ this._constants,
this._namer,
this._nativeData,
this._interceptorData,
@@ -46,7 +57,7 @@ class ParameterStubGenerator {
Emitter get _emitter => _emitterTask.emitter;
- bool needsSuperGetter(FunctionEntity element) =>
+ bool needsSuperGetter(FunctionElement element) =>
_codegenWorldBuilder.methodsNeedingSuperGetter.contains(element);
/**
@@ -66,23 +77,21 @@ class ParameterStubGenerator {
* the input selector is non-null (and the member needs a stub).
*/
ParameterStubMethod generateParameterStub(
- FunctionEntity member, Selector selector, Selector callSelector) {
+ MethodElement member, Selector selector, Selector callSelector) {
CallStructure callStructure = selector.callStructure;
- ParameterStructure parameterStructure = member.parameterStructure;
+ FunctionSignature parameters = member.functionSignature;
int positionalArgumentCount = callStructure.positionalArgumentCount;
- if (positionalArgumentCount == parameterStructure.totalParameters) {
+ if (positionalArgumentCount == parameters.parameterCount) {
assert(callStructure.isUnnamed);
return null;
}
- if (parameterStructure.namedParameters.isNotEmpty &&
- callStructure.namedArgumentCount ==
- parameterStructure.namedParameters.length) {
+ if (parameters.optionalParametersAreNamed &&
+ callStructure.namedArgumentCount == parameters.optionalParameterCount) {
// If the selector has the same number of named arguments as the element,
// we don't need to add a stub. The call site will hit the method
// directly.
return null;
}
-
List<String> names = callStructure.getOrderedNamedArguments();
bool isInterceptedMethod = _interceptorData.isInterceptedMethod(member);
@@ -99,7 +108,7 @@ class ParameterStubGenerator {
new List<jsAst.Parameter>(selector.argumentCount + extraArgumentCount);
// The arguments that will be passed to the real method.
List<jsAst.Expression> argumentsBuffer = new List<jsAst.Expression>(
- parameterStructure.totalParameters + extraArgumentCount);
+ parameters.parameterCount + extraArgumentCount);
int count = 0;
if (isInterceptedMethod) {
@@ -112,15 +121,15 @@ class ParameterStubGenerator {
// Includes extra receiver argument when using interceptor convention
int indexOfLastOptionalArgumentInParameters = optionalParameterStart - 1;
- _codegenWorldBuilder.forEachParameter(member,
- (_, String name, ConstantValue value) {
- String jsName = _namer.safeVariableName(name);
+ parameters.orderedForEachParameter((_element) {
+ ParameterElement element = _element;
+ String jsName = _namer.safeVariableName(element.name);
assert(jsName != receiverArgumentName);
if (count < optionalParameterStart) {
parametersBuffer[count] = new jsAst.Parameter(jsName);
argumentsBuffer[count] = js('#', jsName);
} else {
- int index = names.indexOf(name);
+ int index = names.indexOf(element.name);
if (index != -1) {
indexOfLastOptionalArgumentInParameters = count;
// The order of the named arguments is not the same as the
@@ -129,6 +138,7 @@ class ParameterStubGenerator {
parametersBuffer[optionalParameterStart + index] =
new jsAst.Parameter(jsName);
} else {
+ ConstantValue value = _constants.getConstantValue(element.constant);
if (value == null) {
argumentsBuffer[count] =
_emitter.constantReference(new NullConstantValue());
@@ -156,7 +166,7 @@ class ParameterStubGenerator {
indexOfLastOptionalArgumentInParameters);
} else if (member.isInstanceMember) {
if (needsSuperGetter(member)) {
- ClassEntity superClass = member.enclosingClass;
+ ClassElement superClass = member.enclosingClass;
jsAst.Name methodName = _namer.instanceMethodName(member);
// When redirecting, we must ensure that we don't end up in a subclass.
// We thus can't just invoke `this.foo$1.call(filledInArguments)`.
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/native_emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/program_builder/collector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698