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

Unified Diff: src/ast.cc

Issue 620113002: Removed the Isolate* field from literal nodes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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.h ('k') | src/ast-value-factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index d7724f9027380450758aeb553804727e00561330..2d96f3f2164ba36b322437734624755f62a14564 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -1126,20 +1126,19 @@ void AstConstructionVisitor::VisitCallRuntime(CallRuntime* node) {
#undef DONT_CACHE_NODE
-Handle<String> Literal::ToString() {
- if (value_->IsString()) return value_->AsString()->string();
- DCHECK(value_->IsNumber());
- char arr[100];
- Vector<char> buffer(arr, arraysize(arr));
- const char* str;
- if (value()->IsSmi()) {
- // Optimization only, the heap number case would subsume this.
- SNPrintF(buffer, "%d", Smi::cast(*value())->value());
- str = arr;
- } else {
- str = DoubleToCString(value()->Number(), buffer);
- }
- return isolate_->factory()->NewStringFromAsciiChecked(str);
+uint32_t Literal::Hash() {
+ return raw_value()->IsString()
+ ? raw_value()->AsString()->hash()
+ : ComputeLongHash(double_to_uint64(raw_value()->AsNumber()));
+}
+
+
+// static
+bool Literal::Match(void* literal1, void* literal2) {
+ const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
+ const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
+ return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) ||
+ (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
}
« no previous file with comments | « src/ast.h ('k') | src/ast-value-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698