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

Side by Side Diff: src/parser.cc

Issue 17576005: Rename Literal::handle to Literal::value (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/prettyprinter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 continue; 882 continue;
883 } 883 }
884 884
885 if (directive_prologue) { 885 if (directive_prologue) {
886 // A shot at a directive. 886 // A shot at a directive.
887 ExpressionStatement* e_stat; 887 ExpressionStatement* e_stat;
888 Literal* literal; 888 Literal* literal;
889 // Still processing directive prologue? 889 // Still processing directive prologue?
890 if ((e_stat = stat->AsExpressionStatement()) != NULL && 890 if ((e_stat = stat->AsExpressionStatement()) != NULL &&
891 (literal = e_stat->expression()->AsLiteral()) != NULL && 891 (literal = e_stat->expression()->AsLiteral()) != NULL &&
892 literal->handle()->IsString()) { 892 literal->value()->IsString()) {
893 Handle<String> directive = Handle<String>::cast(literal->handle()); 893 Handle<String> directive = Handle<String>::cast(literal->value());
894 894
895 // Check "use strict" directive (ES5 14.1). 895 // Check "use strict" directive (ES5 14.1).
896 if (top_scope_->is_classic_mode() && 896 if (top_scope_->is_classic_mode() &&
897 directive->Equals(isolate()->heap()->use_strict_string()) && 897 directive->Equals(isolate()->heap()->use_strict_string()) &&
898 token_loc.end_pos - token_loc.beg_pos == 898 token_loc.end_pos - token_loc.beg_pos ==
899 isolate()->heap()->use_strict_string()->length() + 2) { 899 isolate()->heap()->use_strict_string()->length() + 2) {
900 // TODO(mstarzinger): Global strict eval calls, need their own scope 900 // TODO(mstarzinger): Global strict eval calls, need their own scope
901 // as specified in ES5 10.4.2(3). The correct fix would be to always 901 // as specified in ES5 10.4.2(3). The correct fix would be to always
902 // add this scope in DoParseProgram(), but that requires adaptations 902 // add this scope in DoParseProgram(), but that requires adaptations
903 // all over the code base, so we go with a quick-fix for now. 903 // all over the code base, so we go with a quick-fix for now.
(...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after
3060 ASSERT(prec >= 4); 3060 ASSERT(prec >= 4);
3061 Expression* x = ParseUnaryExpression(CHECK_OK); 3061 Expression* x = ParseUnaryExpression(CHECK_OK);
3062 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { 3062 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
3063 // prec1 >= 4 3063 // prec1 >= 4
3064 while (Precedence(peek(), accept_IN) == prec1) { 3064 while (Precedence(peek(), accept_IN) == prec1) {
3065 Token::Value op = Next(); 3065 Token::Value op = Next();
3066 int position = scanner().location().beg_pos; 3066 int position = scanner().location().beg_pos;
3067 Expression* y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); 3067 Expression* y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK);
3068 3068
3069 // Compute some expressions involving only number literals. 3069 // Compute some expressions involving only number literals.
3070 if (x && x->AsLiteral() && x->AsLiteral()->handle()->IsNumber() && 3070 if (x && x->AsLiteral() && x->AsLiteral()->value()->IsNumber() &&
3071 y && y->AsLiteral() && y->AsLiteral()->handle()->IsNumber()) { 3071 y && y->AsLiteral() && y->AsLiteral()->value()->IsNumber()) {
3072 double x_val = x->AsLiteral()->handle()->Number(); 3072 double x_val = x->AsLiteral()->value()->Number();
3073 double y_val = y->AsLiteral()->handle()->Number(); 3073 double y_val = y->AsLiteral()->value()->Number();
3074 3074
3075 switch (op) { 3075 switch (op) {
3076 case Token::ADD: 3076 case Token::ADD:
3077 x = factory()->NewNumberLiteral(x_val + y_val); 3077 x = factory()->NewNumberLiteral(x_val + y_val);
3078 continue; 3078 continue;
3079 case Token::SUB: 3079 case Token::SUB:
3080 x = factory()->NewNumberLiteral(x_val - y_val); 3080 x = factory()->NewNumberLiteral(x_val - y_val);
3081 continue; 3081 continue;
3082 case Token::MUL: 3082 case Token::MUL:
3083 x = factory()->NewNumberLiteral(x_val * y_val); 3083 x = factory()->NewNumberLiteral(x_val * y_val);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 // '~' UnaryExpression 3162 // '~' UnaryExpression
3163 // '!' UnaryExpression 3163 // '!' UnaryExpression
3164 3164
3165 Token::Value op = peek(); 3165 Token::Value op = peek();
3166 if (Token::IsUnaryOp(op)) { 3166 if (Token::IsUnaryOp(op)) {
3167 op = Next(); 3167 op = Next();
3168 int position = scanner().location().beg_pos; 3168 int position = scanner().location().beg_pos;
3169 Expression* expression = ParseUnaryExpression(CHECK_OK); 3169 Expression* expression = ParseUnaryExpression(CHECK_OK);
3170 3170
3171 if (expression != NULL && (expression->AsLiteral() != NULL)) { 3171 if (expression != NULL && (expression->AsLiteral() != NULL)) {
3172 Handle<Object> literal = expression->AsLiteral()->handle(); 3172 Handle<Object> literal = expression->AsLiteral()->value();
3173 if (op == Token::NOT) { 3173 if (op == Token::NOT) {
3174 // Convert the literal to a boolean condition and negate it. 3174 // Convert the literal to a boolean condition and negate it.
3175 bool condition = literal->BooleanValue(); 3175 bool condition = literal->BooleanValue();
3176 Handle<Object> result(isolate()->heap()->ToBoolean(!condition), 3176 Handle<Object> result(isolate()->heap()->ToBoolean(!condition),
3177 isolate()); 3177 isolate());
3178 return factory()->NewLiteral(result); 3178 return factory()->NewLiteral(result);
3179 } else if (literal->IsNumber()) { 3179 } else if (literal->IsNumber()) {
3180 // Compute some expressions involving only number literals. 3180 // Compute some expressions involving only number literals.
3181 double value = literal->Number(); 3181 double value = literal->Number();
3182 switch (op) { 3182 switch (op) {
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
3776 } 3776 }
3777 3777
3778 3778
3779 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { 3779 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) {
3780 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); 3780 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot)));
3781 } 3781 }
3782 3782
3783 3783
3784 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { 3784 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) {
3785 if (expression->AsLiteral() != NULL) { 3785 if (expression->AsLiteral() != NULL) {
3786 return expression->AsLiteral()->handle(); 3786 return expression->AsLiteral()->value();
3787 } 3787 }
3788 if (CompileTimeValue::IsCompileTimeValue(expression)) { 3788 if (CompileTimeValue::IsCompileTimeValue(expression)) {
3789 return CompileTimeValue::GetValue(expression); 3789 return CompileTimeValue::GetValue(expression);
3790 } 3790 }
3791 return isolate()->factory()->uninitialized_value(); 3791 return isolate()->factory()->uninitialized_value();
3792 } 3792 }
3793 3793
3794 // Validation per 11.1.5 Object Initialiser 3794 // Validation per 11.1.5 Object Initialiser
3795 class ObjectLiteralPropertyChecker { 3795 class ObjectLiteralPropertyChecker {
3796 public: 3796 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 continue; 3889 continue;
3890 } 3890 }
3891 MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral(); 3891 MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral();
3892 if (m_literal != NULL && m_literal->depth() >= depth_acc) { 3892 if (m_literal != NULL && m_literal->depth() >= depth_acc) {
3893 depth_acc = m_literal->depth() + 1; 3893 depth_acc = m_literal->depth() + 1;
3894 } 3894 }
3895 3895
3896 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined 3896 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined
3897 // value for COMPUTED properties, the real value is filled in at 3897 // value for COMPUTED properties, the real value is filled in at
3898 // runtime. The enumeration order is maintained. 3898 // runtime. The enumeration order is maintained.
3899 Handle<Object> key = property->key()->handle(); 3899 Handle<Object> key = property->key()->value();
3900 Handle<Object> value = GetBoilerplateValue(property->value()); 3900 Handle<Object> value = GetBoilerplateValue(property->value());
3901 3901
3902 // Ensure objects that may, at any point in time, contain fields with double 3902 // Ensure objects that may, at any point in time, contain fields with double
3903 // representation are always treated as nested objects. This is true for 3903 // representation are always treated as nested objects. This is true for
3904 // computed fields (value is undefined), and smi and double literals 3904 // computed fields (value is undefined), and smi and double literals
3905 // (value->IsNumber()). 3905 // (value->IsNumber()).
3906 // TODO(verwaest): Remove once we can store them inline. 3906 // TODO(verwaest): Remove once we can store them inline.
3907 if (FLAG_track_double_fields && 3907 if (FLAG_track_double_fields &&
3908 (value->IsNumber() || value->IsUninitialized())) { 3908 (value->IsNumber() || value->IsUninitialized())) {
3909 *may_store_doubles = true; 3909 *may_store_doubles = true;
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
5937 ASSERT(info()->isolate()->has_pending_exception()); 5937 ASSERT(info()->isolate()->has_pending_exception());
5938 } else { 5938 } else {
5939 result = ParseProgram(); 5939 result = ParseProgram();
5940 } 5940 }
5941 } 5941 }
5942 info()->SetFunction(result); 5942 info()->SetFunction(result);
5943 return (result != NULL); 5943 return (result != NULL);
5944 } 5944 }
5945 5945
5946 } } // namespace v8::internal 5946 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698