return DoubleToBoolean(number_);
case SMI:
return smi_ != 0;
- case STRING_ARRAY:
- UNREACHABLE();
- break;
case BOOLEAN:
return bool_;
case NULL_TYPE:
value_ = isolate->factory()->false_value();
}
break;
- case STRING_ARRAY: {
- DCHECK(strings_ != NULL);
- Factory* factory = isolate->factory();
- int len = strings_->length();
- Handle<FixedArray> elements = factory->NewFixedArray(len, TENURED);
- for (int i = 0; i < len; i++) {
- const AstRawString* string = (*strings_)[i];
- Handle<Object> element = string->string();
- // Strings are already internalized.
- DCHECK(!element.is_null());
- elements->set(i, *element);
- }
- value_ =
- factory->NewJSArrayWithElements(elements, FAST_ELEMENTS, TENURED);
- break;
- }
case NULL_TYPE:
value_ = isolate->factory()->null_value();
break;
}
-const AstValue* AstValueFactory::NewStringList(
- ZoneList<const AstRawString*>* strings) {
- AstValue* value = new (zone_) AstValue(strings);
- if (isolate_) {
- value->Internalize(isolate_);
- }
- values_.Add(value);
- return value;
-}
-
-
const AstValue* AstValueFactory::NewNull() {
GENERATE_VALUE_GETTER(null_value_, AstValue::NULL_TYPE);
}
NUMBER,
SMI,
BOOLEAN,
- STRING_ARRAY,
NULL_TYPE,
UNDEFINED,
THE_HOLE
explicit AstValue(bool b) : type_(BOOLEAN) { bool_ = b; }
- explicit AstValue(ZoneList<const AstRawString*>* s) : type_(STRING_ARRAY) {
- strings_ = s;
- }
-
explicit AstValue(Type t) : type_(t) {
DCHECK(t == NULL_TYPE || t == UNDEFINED || t == THE_HOLE);
}
// For generating constants.
-#define STRING_CONSTANTS(F) \
- F(anonymous_function, "(anonymous function)") \
- F(arguments, "arguments") \
- F(constructor, "constructor") \
- F(done, "done") \
- F(dot, ".") \
- F(dot_for, ".for") \
- F(dot_generator, ".generator") \
- F(dot_generator_object, ".generator_object") \
- F(dot_iterator, ".iterator") \
- F(dot_module, ".module") \
- F(dot_result, ".result") \
- F(empty, "") \
- F(eval, "eval") \
- F(initialize_const_global, "initializeConstGlobal") \
- F(initialize_var_global, "initializeVarGlobal") \
- F(make_reference_error, "MakeReferenceError") \
- F(make_syntax_error, "MakeSyntaxError") \
- F(make_type_error, "MakeTypeError") \
- F(module, "module") \
- F(native, "native") \
- F(next, "next") \
- F(proto, "__proto__") \
- F(prototype, "prototype") \
- F(this, "this") \
- F(use_asm, "use asm") \
- F(use_strict, "use strict") \
+#define STRING_CONSTANTS(F) \
+ F(anonymous_function, "(anonymous function)") \
+ F(arguments, "arguments") \
+ F(constructor, "constructor") \
+ F(done, "done") \
+ F(dot, ".") \
+ F(dot_for, ".for") \
+ F(dot_generator, ".generator") \
+ F(dot_generator_object, ".generator_object") \
+ F(dot_iterator, ".iterator") \
+ F(dot_module, ".module") \
+ F(dot_result, ".result") \
+ F(empty, "") \
+ F(eval, "eval") \
+ F(initialize_const_global, "initializeConstGlobal") \
+ F(initialize_var_global, "initializeVarGlobal") \
+ F(make_reference_error, "MakeReferenceErrorEmbedded") \
+ F(make_syntax_error, "MakeSyntaxErrorEmbedded") \
+ F(make_type_error, "MakeTypeErrorEmbedded") \
+ F(module, "module") \
+ F(native, "native") \
+ F(next, "next") \
+ F(proto, "__proto__") \
+ F(prototype, "prototype") \
+ F(this, "this") \
+ F(use_asm, "use asm") \
+ F(use_strict, "use strict") \
F(value, "value")
#define OTHER_CONSTANTS(F) \
VISIT_AND_RETURN(Literal, lit)
}
- Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings,
- int pos) {
- Literal* lit = new (zone_)
- Literal(zone_, ast_value_factory_->NewStringList(strings), pos);
- VISIT_AND_RETURN(Literal, lit)
- }
-
Literal* NewNullLiteral(int pos) {
Literal* lit =
new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos);
return MakeGenericError($Error, type, args);
}
+
+// The embedded versions are called from unoptimized code, with embedded
+// arguments. Those arguments cannot be arrays, which are context-dependent.
+function MakeTypeErrorEmbedded(type, arg) {
+ return MakeGenericError($TypeError, type, [arg]);
+}
+
+
+function MakeSyntaxErrorEmbedded(type, arg) {
+ return MakeGenericError($SyntaxError, type, [arg]);
+}
+
+
+function MakeReferenceErrorEmbedded(type, arg) {
+ return MakeGenericError($ReferenceError, type, [arg]);
+}
+
/**
* Find a line number given a specific source position.
* @param {number} position The source position.
Expression* ParserTraits::NewThrowReferenceError(const char* message, int pos) {
return NewThrowError(
parser_->ast_value_factory()->make_reference_error_string(), message,
- NULL, pos);
+ parser_->ast_value_factory()->empty_string(), pos);
}
const AstRawString* constructor, const char* message,
const AstRawString* arg, int pos) {
Zone* zone = parser_->zone();
- int argc = arg != NULL ? 1 : 0;
const AstRawString* type =
parser_->ast_value_factory()->GetOneByteString(message);
- ZoneList<const AstRawString*>* array =
- new (zone) ZoneList<const AstRawString*>(argc, zone);
- if (arg != NULL) {
- array->Add(arg, zone);
- }
ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(2, zone);
args->Add(parser_->factory()->NewStringLiteral(type, pos), zone);
- args->Add(parser_->factory()->NewStringListLiteral(array, pos), zone);
+ args->Add(parser_->factory()->NewStringLiteral(arg, pos), zone);
CallRuntime* call_constructor =
parser_->factory()->NewCallRuntime(constructor, NULL, args, pos);
return parser_->factory()->NewThrow(call_constructor, pos);
--- /dev/null
+// Copyright 2014 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.
+
+// --serialize-toplevel --cache=code
+
+var caught = false;
+try {
+ parseInt() = 0;
+} catch(e) {
+ caught = true;
+}
+assertTrue(caught);