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

Unified Diff: sdk/lib/_internal/compiler/implementation/ssa/builder.dart

Issue 614993002: Rename Constant to ConstantValue and ConstExp to ConstantExpression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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: sdk/lib/_internal/compiler/implementation/ssa/builder.dart
diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
index 8f22091c59f4e1a1a5242bee2e349282e8b7b687..7db6212c1f749fdaf996a8c6272f07522ef02164 100644
--- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
+++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart
@@ -58,7 +58,7 @@ class SsaBuilderTask extends CompilerTask {
FunctionSignature signature = function.functionSignature;
signature.forEachOptionalParameter((ParameterElement parameter) {
// This ensures the default value will be computed.
- Constant constant =
+ ConstantValue constant =
backend.constants.getConstantForVariable(parameter).value;
CodegenRegistry registry = work.registry;
registry.registerCompileTimeConstant(constant);
@@ -1346,7 +1346,7 @@ class SsaBuilder extends ResolvedVisitor {
}
HInstruction handleConstantForOptionalParameter(Element parameter) {
- ConstExp constant =
+ ConstantExpression constant =
backend.constants.getConstantForVariable(parameter);
assert(invariant(parameter, constant != null,
message: 'No constant computed for $parameter'));
@@ -1385,8 +1385,8 @@ class SsaBuilder extends ResolvedVisitor {
bool inTryStatement = false;
- Constant getConstantForNode(ast.Node node) {
- ConstExp constant =
+ ConstantValue getConstantForNode(ast.Node node) {
+ ConstantExpression constant =
backend.constants.getConstantForNode(node, elements);
assert(invariant(node, constant != null,
message: 'No constant computed for $node'));
@@ -1398,7 +1398,7 @@ class SsaBuilder extends ResolvedVisitor {
}
bool isLazilyInitialized(VariableElement element) {
- ConstExp initialValue =
+ ConstantExpression initialValue =
backend.constants.getConstantForVariable(element);
return initialValue == null;
}
@@ -2059,8 +2059,8 @@ class SsaBuilder extends ResolvedVisitor {
if (remainingTypeVariables == 0) return false;
remainingTypeVariables--;
// Check that the index is the one we expect.
- IntConstant constant = index.constant;
- return constant.value == expectedIndex++;
+ IntConstantValue constant = index.constant;
+ return constant.primitiveValue == expectedIndex++;
}
List<HInstruction> typeArguments = <HInstruction>[];
@@ -2092,7 +2092,7 @@ class SsaBuilder extends ResolvedVisitor {
List bodyCallInputs = <HInstruction>[];
if (isNativeUpgradeFactory) {
if (interceptor == null) {
- Constant constant = new InterceptorConstant(classElement.thisType);
+ ConstantValue constant = new InterceptorConstantValue(classElement.thisType);
sigurdm 2014/10/01 07:46:48 Long line
Johnni Winther 2014/10/01 08:21:24 Done.
interceptor = graph.addConstant(constant, compiler);
}
bodyCallInputs.add(interceptor);
@@ -2999,7 +2999,7 @@ class SsaBuilder extends ResolvedVisitor {
if (operand is HConstant) {
UnaryOperation operation = constantSystem.lookupUnary(op.source);
HConstant constant = operand;
- Constant folded = operation.fold(constant.constant);
+ ConstantValue folded = operation.fold(constant.constant);
if (folded != null) {
stack.add(graph.addConstant(folded, compiler));
return;
@@ -3082,14 +3082,14 @@ class SsaBuilder extends ResolvedVisitor {
if (element != null && element.isForeign(backend)) {
visitForeignGetter(send);
} else if (Elements.isStaticOrTopLevelField(element)) {
- ConstExp constant;
+ ConstantExpression constant;
if (element.isField && !element.isAssignable) {
// A static final or const. Get its constant value and inline it if
// the value can be compiled eagerly.
constant = backend.constants.getConstantForVariable(element);
}
if (constant != null) {
- Constant value = constant.value;
+ ConstantValue value = constant.value;
HConstant instruction;
// Constants that are referred via a deferred prefix should be referred
// by reference.
@@ -3642,8 +3642,8 @@ class SsaBuilder extends ResolvedVisitor {
return;
}
HConstant hConstant = globalNameHNode;
- StringConstant constant = hConstant.constant;
- String globalName = constant.value.slowToString();
+ StringConstantValue constant = hConstant.constant;
+ String globalName = constant.primitiveValue.slowToString();
js.Template expr = js.js.expressionTemplateYielding(
backend.emitter.generateEmbeddedGlobalAccess(globalName));
native.NativeBehavior nativeBehavior =
@@ -3661,10 +3661,10 @@ class SsaBuilder extends ResolvedVisitor {
visit(argument);
HInstruction argumentInstruction = pop();
if (argumentInstruction is HConstant) {
- Constant argumentConstant = argumentInstruction.constant;
- if (argumentConstant is TypeConstant) {
- Constant constant =
- new InterceptorConstant(argumentConstant.representedType);
+ ConstantValue argumentConstant = argumentInstruction.constant;
+ if (argumentConstant is TypeConstantValue) {
+ ConstantValue constant =
+ new InterceptorConstantValue(argumentConstant.representedType);
HInstruction instruction = graph.addConstant(constant, compiler);
stack.add(instruction);
return;
@@ -3887,11 +3887,11 @@ class SsaBuilder extends ResolvedVisitor {
String publicName = name;
if (selector.isSetter) publicName += '=';
- Constant nameConstant = constantSystem.createString(
+ ConstantValue nameConstant = constantSystem.createString(
new ast.DartString.literal(publicName));
String internalName = backend.namer.invocationName(selector);
- Constant internalNameConstant =
+ ConstantValue internalNameConstant =
constantSystem.createString(new ast.DartString.literal(internalName));
Element createInvocationMirror = backend.getCreateInvocationMirror();
@@ -3900,14 +3900,14 @@ class SsaBuilder extends ResolvedVisitor {
var argumentNames = new List<HInstruction>();
for (String argumentName in selector.namedArguments) {
- Constant argumentNameConstant =
+ ConstantValue argumentNameConstant =
constantSystem.createString(new ast.DartString.literal(argumentName));
argumentNames.add(graph.addConstant(argumentNameConstant, compiler));
}
var argumentNamesInstruction = buildLiteralList(argumentNames);
add(argumentNamesInstruction);
- Constant kindConstant =
+ ConstantValue kindConstant =
constantSystem.createInt(selector.invocationMirrorKind);
pushInvokeStatic(null,
@@ -4252,7 +4252,7 @@ class SsaBuilder extends ResolvedVisitor {
bool canThrow = true;
if (inputs[0].isInteger(compiler) && inputs[0] is HConstant) {
var constant = inputs[0];
- if (constant.constant.value >= 0) canThrow = false;
+ if (constant.constant.primitiveValue >= 0) canThrow = false;
}
HForeign foreign = new HForeign(
code, elementType, inputs, nativeBehavior: behavior,
@@ -4441,7 +4441,7 @@ class SsaBuilder extends ResolvedVisitor {
HConstant addConstantString(String string) {
ast.DartString dartString = new ast.DartString.literal(string);
- Constant constant = constantSystem.createString(dartString);
+ ConstantValue constant = constantSystem.createString(dartString);
return graph.addConstant(constant, compiler);
}
@@ -4522,11 +4522,11 @@ class SsaBuilder extends ResolvedVisitor {
List<HInstruction> argumentValues,
List<String> existingArguments}) {
Element helper = backend.getThrowNoSuchMethod();
- Constant receiverConstant =
+ ConstantValue receiverConstant =
constantSystem.createString(new ast.DartString.empty());
HInstruction receiver = graph.addConstant(receiverConstant, compiler);
ast.DartString dartString = new ast.DartString.literal(methodName);
- Constant nameConstant = constantSystem.createString(dartString);
+ ConstantValue nameConstant = constantSystem.createString(dartString);
HInstruction name = graph.addConstant(nameConstant, compiler);
if (argumentValues == null) {
argumentValues = <HInstruction>[];
@@ -4596,8 +4596,8 @@ class SsaBuilder extends ResolvedVisitor {
} else if (node.isConst) {
stack.add(addConstant(node));
if (isSymbolConstructor) {
- ConstructedConstant symbol = getConstantForNode(node);
- StringConstant stringConstant = symbol.fields.single;
+ ConstructedConstantValue symbol = getConstantForNode(node);
+ StringConstantValue stringConstant = symbol.fields.single;
String nameString = stringConstant.toDartString().slowToString();
registry.registerConstSymbol(nameString);
}
@@ -5368,13 +5368,13 @@ class SsaBuilder extends ResolvedVisitor {
visit(node.expression);
}
- Map<ast.CaseMatch, Constant> buildSwitchCaseConstants(ast.SwitchStatement node) {
- Map<ast.CaseMatch, Constant> constants = new Map<ast.CaseMatch, Constant>();
+ Map<ast.CaseMatch, ConstantValue> buildSwitchCaseConstants(ast.SwitchStatement node) {
sigurdm 2014/10/01 07:46:48 Long line
Johnni Winther 2014/10/01 08:21:24 Done.
+ Map<ast.CaseMatch, ConstantValue> constants = new Map<ast.CaseMatch, ConstantValue>();
sigurdm 2014/10/01 07:46:48 Long line
Johnni Winther 2014/10/01 08:21:24 Done.
for (ast.SwitchCase switchCase in node.cases) {
for (ast.Node labelOrCase in switchCase.labelsAndCases) {
if (labelOrCase is ast.CaseMatch) {
ast.CaseMatch match = labelOrCase;
- Constant constant = getConstantForNode(match.expression);
+ ConstantValue constant = getConstantForNode(match.expression);
constants[labelOrCase] = constant;
}
}
@@ -5383,7 +5383,7 @@ class SsaBuilder extends ResolvedVisitor {
}
visitSwitchStatement(ast.SwitchStatement node) {
- Map<ast.CaseMatch, Constant> constants = buildSwitchCaseConstants(node);
+ Map<ast.CaseMatch, ConstantValue> constants = buildSwitchCaseConstants(node);
sigurdm 2014/10/01 07:46:48 Long line
Johnni Winther 2014/10/01 08:21:24 Done.
// The switch case indices must match those computed in
// [SwitchCaseJumpHandler].
@@ -5421,14 +5421,14 @@ class SsaBuilder extends ResolvedVisitor {
* statements to labeled switch cases.
*/
void buildSimpleSwitchStatement(ast.SwitchStatement node,
- Map<ast.CaseMatch, Constant> constants) {
+ Map<ast.CaseMatch, ConstantValue> constants) {
JumpHandler jumpHandler = createJumpHandler(node, isLoopJump: false);
HInstruction buildExpression() {
visit(node.expression);
return pop();
}
- Iterable<Constant> getConstants(ast.SwitchCase switchCase) {
- List<Constant> constantList = <Constant>[];
+ Iterable<ConstantValue> getConstants(ast.SwitchCase switchCase) {
+ List<ConstantValue> constantList = <ConstantValue>[];
for (ast.Node labelOrCase in switchCase.labelsAndCases) {
if (labelOrCase is ast.CaseMatch) {
constantList.add(constants[labelOrCase]);
@@ -5457,7 +5457,7 @@ class SsaBuilder extends ResolvedVisitor {
* statements to labeled switch cases.
*/
void buildComplexSwitchStatement(ast.SwitchStatement node,
- Map<ast.CaseMatch, Constant> constants,
+ Map<ast.CaseMatch, ConstantValue> constants,
Map<ast.SwitchCase, int> caseIndex,
bool hasDefault) {
// If the switch statement has switch cases targeted by continue
@@ -5504,8 +5504,8 @@ class SsaBuilder extends ResolvedVisitor {
visit(node.expression);
return pop();
}
- Iterable<Constant> getConstants(ast.SwitchCase switchCase) {
- List<Constant> constantList = <Constant>[];
+ Iterable<ConstantValue> getConstants(ast.SwitchCase switchCase) {
+ List<ConstantValue> constantList = <ConstantValue>[];
if (switchCase != null) {
for (ast.Node labelOrCase in switchCase.labelsAndCases) {
if (labelOrCase is ast.CaseMatch) {
@@ -5547,8 +5547,8 @@ class SsaBuilder extends ResolvedVisitor {
HInstruction buildExpression() {
return localsHandler.readLocal(switchTarget);
}
- Iterable<Constant> getConstants(ast.SwitchCase switchCase) {
- return <Constant>[constantSystem.createInt(caseIndex[switchCase])];
+ Iterable<ConstantValue> getConstants(ast.SwitchCase switchCase) {
+ return <ConstantValue>[constantSystem.createInt(caseIndex[switchCase])];
}
void buildSwitchCase(ast.SwitchCase switchCase) {
visit(switchCase.statements);
@@ -5607,10 +5607,10 @@ class SsaBuilder extends ResolvedVisitor {
JumpHandler jumpHandler,
HInstruction buildExpression(),
var switchCases,
- Iterable<Constant> getConstants(ast.SwitchCase switchCase),
+ Iterable<ConstantValue> getConstants(ast.SwitchCase switchCase),
sigurdm 2014/10/01 07:46:48 Long line
Johnni Winther 2014/10/01 08:21:24 Done.
bool isDefaultCase(ast.SwitchCase switchCase),
void buildSwitchCase(ast.SwitchCase switchCase)) {
- Map<ast.CaseMatch, Constant> constants = new Map<ast.CaseMatch, Constant>();
+ Map<ast.CaseMatch, ConstantValue> constants = new Map<ast.CaseMatch, ConstantValue>();
sigurdm 2014/10/01 07:46:48 Long line
Johnni Winther 2014/10/01 08:21:24 Done.
HBasicBlock expressionStart = openNewBlock();
HInstruction expression = buildExpression();
@@ -5630,7 +5630,7 @@ class SsaBuilder extends ResolvedVisitor {
while (caseIterator.hasNext) {
ast.SwitchCase switchCase = caseIterator.next();
HBasicBlock block = graph.addNewBlock();
- for (Constant constant in getConstants(switchCase)) {
+ for (ConstantValue constant in getConstants(switchCase)) {
HConstant hConstant = graph.addConstant(constant, compiler);
switchInstruction.inputs.add(hConstant);
hConstant.usedBy.add(switchInstruction);

Powered by Google App Engine
This is Rietveld 408576698