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

Unified Diff: src/ast/compile-time-value.cc

Issue 2305883002: Remove unnessary includes of parser.h (Closed)
Patch Set: More fixes in asm-js.h Created 4 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
« no previous file with comments | « src/ast/compile-time-value.h ('k') | src/background-parsing-task.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/compile-time-value.cc
diff --git a/src/ast/compile-time-value.cc b/src/ast/compile-time-value.cc
new file mode 100644
index 0000000000000000000000000000000000000000..eda536b7167e052ce9ee9adac50b26c2a70e6280
--- /dev/null
+++ b/src/ast/compile-time-value.cc
@@ -0,0 +1,56 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/ast/compile-time-value.h"
+
+#include "src/ast/ast.h"
+#include "src/factory.h"
+#include "src/handles-inl.h"
+#include "src/isolate.h"
+#include "src/objects-inl.h"
+
+namespace v8 {
+namespace internal {
+
+bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
+ if (expression->IsLiteral()) return true;
+ MaterializedLiteral* lit = expression->AsMaterializedLiteral();
+ return lit != NULL && lit->is_simple();
+}
+
+Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate,
+ Expression* expression) {
+ Factory* factory = isolate->factory();
+ DCHECK(IsCompileTimeValue(expression));
+ Handle<FixedArray> result = factory->NewFixedArray(2, TENURED);
+ ObjectLiteral* object_literal = expression->AsObjectLiteral();
+ if (object_literal != NULL) {
+ DCHECK(object_literal->is_simple());
+ if (object_literal->fast_elements()) {
+ result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS));
+ } else {
+ result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
+ }
+ result->set(kElementsSlot, *object_literal->constant_properties());
+ } else {
+ ArrayLiteral* array_literal = expression->AsArrayLiteral();
+ DCHECK(array_literal != NULL && array_literal->is_simple());
+ result->set(kLiteralTypeSlot, Smi::FromInt(ARRAY_LITERAL));
+ result->set(kElementsSlot, *array_literal->constant_elements());
+ }
+ return result;
+}
+
+CompileTimeValue::LiteralType CompileTimeValue::GetLiteralType(
+ Handle<FixedArray> value) {
+ Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot));
+ return static_cast<LiteralType>(literal_type->value());
+}
+
+Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) {
+ return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot)));
+}
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/ast/compile-time-value.h ('k') | src/background-parsing-task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698