From 40d98dc7efeba2e6a4a3afd7648a9feb52c95c88 Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Fri, 3 Aug 2012 07:19:15 +0300 Subject: [PATCH] optimization of constant expressions. will be useful only when frontend does good job --- .../src/org/jetbrains/jet/codegen/ExpressionCodegen.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index dc5bc7c00ead6..c369aa4fa35f9 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -177,6 +177,13 @@ public StackValue genQualified(StackValue receiver, JetElement selector) { } public StackValue gen(JetElement expr) { + if (expr instanceof JetExpression) { + JetExpression expression = (JetExpression) expr; + CompileTimeConstant constant = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression); + if (constant != null) { + return StackValue.constant(constant.getValue(), expressionType(expression)); + } + } return genQualified(StackValue.none(), expr); }