bool RegExpAssertion::IsAnchoredAtStart() {
- return type() == RegExpAssertion::START_OF_INPUT;
+ return assertion_type() == RegExpAssertion::START_OF_INPUT;
}
bool RegExpAssertion::IsAnchoredAtEnd() {
- return type() == RegExpAssertion::END_OF_INPUT;
+ return assertion_type() == RegExpAssertion::END_OF_INPUT;
}
void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) {
- switch (that->type()) {
+ switch (that->assertion_type()) {
case RegExpAssertion::START_OF_INPUT:
stream()->Add("@^i");
break;
#include "small-pointer-list.h"
#include "smart-pointers.h"
#include "token.h"
-#include "type-info.h"
+#include "type-info.h" // TODO(rossberg): this should eventually be removed
+#include "types.h"
#include "utils.h"
#include "variables.h"
#include "interface.h"
typedef ZoneList<Handle<Object> > ZoneObjectList;
-#define DECLARE_NODE_TYPE(type) \
- virtual void Accept(AstVisitor* v); \
- virtual AstNode::Type node_type() const { return AstNode::k##type; } \
+#define DECLARE_NODE_TYPE(type) \
+ virtual void Accept(AstVisitor* v); \
+ virtual AstNode::NodeType node_type() const { return AstNode::k##type; } \
template<class> friend class AstNodeFactory;
class AstNode: public ZoneObject {
public:
#define DECLARE_TYPE_ENUM(type) k##type,
- enum Type {
+ enum NodeType {
AST_NODE_LIST(DECLARE_TYPE_ENUM)
kInvalid = -1
};
virtual ~AstNode() { }
virtual void Accept(AstVisitor* v) = 0;
- virtual Type node_type() const = 0;
+ virtual NodeType node_type() const = 0;
// Type testing & conversion functions overridden by concrete subclasses.
#define DECLARE_NODE_FUNCTIONS(type) \
// True iff the expression is the undefined literal.
bool IsUndefinedLiteral();
+ // Expression type
+ Handle<Type> type() { return type_; }
+
// Type feedback information for assignments and properties.
virtual bool IsMonomorphic() {
UNREACHABLE();
protected:
explicit Expression(Isolate* isolate)
- : id_(GetNextId(isolate)),
+ : type_(Type::Any(), isolate),
+ id_(GetNextId(isolate)),
test_id_(GetNextId(isolate)) {}
private:
+ Handle<Type> type_;
byte to_boolean_types_;
const BailoutId id_;
class BreakableStatement: public Statement {
public:
- enum Type {
+ enum BreakableType {
TARGET_FOR_ANONYMOUS,
TARGET_FOR_NAMED_ONLY
};
Label* break_target() { return &break_target_; }
// Testers.
- bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; }
+ bool is_target_for_anonymous() const {
+ return breakable_type_ == TARGET_FOR_ANONYMOUS;
+ }
BailoutId EntryId() const { return entry_id_; }
BailoutId ExitId() const { return exit_id_; }
protected:
- BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type)
+ BreakableStatement(
+ Isolate* isolate, ZoneStringList* labels, BreakableType breakable_type)
: labels_(labels),
- type_(type),
+ breakable_type_(breakable_type),
entry_id_(GetNextId(isolate)),
exit_id_(GetNextId(isolate)) {
ASSERT(labels == NULL || labels->length() > 0);
private:
ZoneStringList* labels_;
- Type type_;
+ BreakableType breakable_type_;
Label break_target_;
const BailoutId entry_id_;
const BailoutId exit_id_;
// Virtual behaviour. TargetCollectors are never part of the AST.
virtual void Accept(AstVisitor* v) { UNREACHABLE(); }
- virtual Type node_type() const { return kInvalid; }
+ virtual NodeType node_type() const { return kInvalid; }
virtual TargetCollector* AsTargetCollector() { return this; }
ZoneList<Label*>* targets() { return &targets_; }
class FunctionLiteral: public Expression {
public:
- enum Type {
+ enum FunctionType {
ANONYMOUS_EXPRESSION,
NAMED_EXPRESSION,
DECLARATION
int expected_property_count,
int handler_count,
int parameter_count,
- Type type,
+ FunctionType function_type,
ParameterFlag has_duplicate_parameters,
IsFunctionFlag is_function,
IsParenthesizedFlag is_parenthesized,
parameter_count_(parameter_count),
function_token_position_(RelocInfo::kNoPosition) {
bitfield_ =
- IsExpression::encode(type != DECLARATION) |
- IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) |
+ IsExpression::encode(function_type != DECLARATION) |
+ IsAnonymous::encode(function_type == ANONYMOUS_EXPRESSION) |
Pretenure::encode(false) |
HasDuplicateParameters::encode(has_duplicate_parameters) |
IsFunction::encode(is_function) |
class RegExpAssertion: public RegExpTree {
public:
- enum Type {
+ enum AssertionType {
START_OF_LINE,
START_OF_INPUT,
END_OF_LINE,
BOUNDARY,
NON_BOUNDARY
};
- explicit RegExpAssertion(Type type) : type_(type) { }
+ explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { }
virtual void* Accept(RegExpVisitor* visitor, void* data);
virtual RegExpNode* ToNode(RegExpCompiler* compiler,
RegExpNode* on_success);
virtual bool IsAnchoredAtEnd();
virtual int min_match() { return 0; }
virtual int max_match() { return 0; }
- Type type() { return type_; }
+ AssertionType assertion_type() { return assertion_type_; }
private:
- Type type_;
+ AssertionType assertion_type_;
};
class RegExpQuantifier: public RegExpTree {
public:
- enum Type { GREEDY, NON_GREEDY, POSSESSIVE };
- RegExpQuantifier(int min, int max, Type type, RegExpTree* body)
+ enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE };
+ RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body)
: body_(body),
min_(min),
max_(max),
min_match_(min * body->min_match()),
- type_(type) {
+ quantifier_type_(type) {
if (max > 0 && body->max_match() > kInfinity / max) {
max_match_ = kInfinity;
} else {
virtual int max_match() { return max_match_; }
int min() { return min_; }
int max() { return max_; }
- bool is_possessive() { return type_ == POSSESSIVE; }
- bool is_non_greedy() { return type_ == NON_GREEDY; }
- bool is_greedy() { return type_ == GREEDY; }
+ bool is_possessive() { return quantifier_type_ == POSSESSIVE; }
+ bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; }
+ bool is_greedy() { return quantifier_type_ == GREEDY; }
RegExpTree* body() { return body_; }
private:
int max_;
int min_match_;
int max_match_;
- Type type_;
+ QuantifierType quantifier_type_;
};
int handler_count,
int parameter_count,
FunctionLiteral::ParameterFlag has_duplicate_parameters,
- FunctionLiteral::Type type,
+ FunctionLiteral::FunctionType function_type,
FunctionLiteral::IsFunctionFlag is_function,
FunctionLiteral::IsParenthesizedFlag is_parenthesized,
FunctionLiteral::IsGeneratorFlag is_generator) {
FunctionLiteral* lit = new(zone_) FunctionLiteral(
isolate_, name, scope, body,
materialized_literal_count, expected_property_count, handler_count,
- parameter_count, type, has_duplicate_parameters, is_function,
+ parameter_count, function_type, has_duplicate_parameters, is_function,
is_parenthesized, is_generator);
// Top-level literal doesn't count for the AST's properties.
if (is_function == FunctionLiteral::kIsFunction) {
}
-Handle<Object> Factory::NewTypeError(const char* type,
+Handle<Object> Factory::NewTypeError(const char* message,
Vector< Handle<Object> > args) {
- return NewError("MakeTypeError", type, args);
+ return NewError("MakeTypeError", message, args);
}
}
-Handle<Object> Factory::NewRangeError(const char* type,
+Handle<Object> Factory::NewRangeError(const char* message,
Vector< Handle<Object> > args) {
- return NewError("MakeRangeError", type, args);
+ return NewError("MakeRangeError", message, args);
}
}
-Handle<Object> Factory::NewSyntaxError(const char* type, Handle<JSArray> args) {
- return NewError("MakeSyntaxError", type, args);
+Handle<Object> Factory::NewSyntaxError(const char* message,
+ Handle<JSArray> args) {
+ return NewError("MakeSyntaxError", message, args);
}
}
-Handle<Object> Factory::NewReferenceError(const char* type,
+Handle<Object> Factory::NewReferenceError(const char* message,
Vector< Handle<Object> > args) {
- return NewError("MakeReferenceError", type, args);
+ return NewError("MakeReferenceError", message, args);
}
Handle<Object> Factory::NewError(const char* maker,
- const char* type,
+ const char* message,
Vector< Handle<Object> > args) {
// Instantiate a closeable HandleScope for EscapeFrom.
v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate()));
array->set(i, *args[i]);
}
Handle<JSArray> object = NewJSArrayWithElements(array);
- Handle<Object> result = NewError(maker, type, object);
+ Handle<Object> result = NewError(maker, message, object);
return result.EscapeFrom(&scope);
}
-Handle<Object> Factory::NewEvalError(const char* type,
+Handle<Object> Factory::NewEvalError(const char* message,
Vector< Handle<Object> > args) {
- return NewError("MakeEvalError", type, args);
+ return NewError("MakeEvalError", message, args);
}
-Handle<Object> Factory::NewError(const char* type,
+Handle<Object> Factory::NewError(const char* message,
Vector< Handle<Object> > args) {
- return NewError("MakeError", type, args);
+ return NewError("MakeError", message, args);
}
-Handle<String> Factory::EmergencyNewError(const char* type,
+Handle<String> Factory::EmergencyNewError(const char* message,
Handle<JSArray> args) {
const int kBufferSize = 1000;
char buffer[kBufferSize];
char* p = &buffer[0];
Vector<char> v(buffer, kBufferSize);
- OS::StrNCpy(v, type, space);
- space -= Min(space, strlen(type));
+ OS::StrNCpy(v, message, space);
+ space -= Min(space, strlen(message));
p = &buffer[kBufferSize] - space;
for (unsigned i = 0; i < ARRAY_SIZE(args); i++) {
Handle<Object> Factory::NewError(const char* maker,
- const char* type,
+ const char* message,
Handle<JSArray> args) {
Handle<String> make_str = InternalizeUtf8String(maker);
Handle<Object> fun_obj(
// If the builtins haven't been properly configured yet this error
// constructor may not have been defined. Bail out.
if (!fun_obj->IsJSFunction()) {
- return EmergencyNewError(type, args);
+ return EmergencyNewError(message, args);
}
Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj);
- Handle<Object> type_obj = InternalizeUtf8String(type);
- Handle<Object> argv[] = { type_obj, args };
+ Handle<Object> message_obj = InternalizeUtf8String(message);
+ Handle<Object> argv[] = { message_obj, args };
// Invoke the JavaScript factory method. If an exception is thrown while
// running the factory method, use the exception as the result.
// Interface for creating error objects.
- Handle<Object> NewError(const char* maker, const char* type,
+ Handle<Object> NewError(const char* maker, const char* message,
Handle<JSArray> args);
- Handle<String> EmergencyNewError(const char* type, Handle<JSArray> args);
- Handle<Object> NewError(const char* maker, const char* type,
+ Handle<String> EmergencyNewError(const char* message, Handle<JSArray> args);
+ Handle<Object> NewError(const char* maker, const char* message,
Vector< Handle<Object> > args);
- Handle<Object> NewError(const char* type,
+ Handle<Object> NewError(const char* message,
Vector< Handle<Object> > args);
Handle<Object> NewError(Handle<String> message);
Handle<Object> NewError(const char* constructor,
Handle<String> message);
- Handle<Object> NewTypeError(const char* type,
+ Handle<Object> NewTypeError(const char* message,
Vector< Handle<Object> > args);
Handle<Object> NewTypeError(Handle<String> message);
- Handle<Object> NewRangeError(const char* type,
+ Handle<Object> NewRangeError(const char* message,
Vector< Handle<Object> > args);
Handle<Object> NewRangeError(Handle<String> message);
- Handle<Object> NewSyntaxError(const char* type, Handle<JSArray> args);
+ Handle<Object> NewSyntaxError(const char* message, Handle<JSArray> args);
Handle<Object> NewSyntaxError(Handle<String> message);
- Handle<Object> NewReferenceError(const char* type,
+ Handle<Object> NewReferenceError(const char* message,
Vector< Handle<Object> > args);
Handle<Object> NewReferenceError(Handle<String> message);
- Handle<Object> NewEvalError(const char* type,
+ Handle<Object> NewEvalError(const char* message,
Vector< Handle<Object> > args);
int TextElement::length() {
- if (type == ATOM) {
+ if (text_type == ATOM) {
return data.u_atom->length();
} else {
- ASSERT(type == CHAR_CLASS);
+ ASSERT(text_type == CHAR_CLASS);
return 1;
}
}
bool Trace::DeferredAction::Mentions(int that) {
- if (type() == ActionNode::CLEAR_CAPTURES) {
+ if (action_type() == ActionNode::CLEAR_CAPTURES) {
Interval range = static_cast<DeferredClearCaptures*>(this)->range();
return range.Contains(that);
} else {
action != NULL;
action = action->next()) {
if (action->Mentions(reg)) {
- if (action->type() == ActionNode::STORE_POSITION) {
+ if (action->action_type() == ActionNode::STORE_POSITION) {
*cp_offset = static_cast<DeferredCapture*>(action)->cp_offset();
return true;
} else {
for (DeferredAction* action = actions_;
action != NULL;
action = action->next()) {
- if (action->type() == ActionNode::CLEAR_CAPTURES) {
+ if (action->action_type() == ActionNode::CLEAR_CAPTURES) {
Interval range = static_cast<DeferredClearCaptures*>(action)->range();
for (int i = range.from(); i <= range.to(); i++)
affected_registers->Set(i, zone);
action != NULL;
action = action->next()) {
if (action->Mentions(reg)) {
- switch (action->type()) {
+ switch (action->action_type()) {
case ActionNode::SET_REGISTER: {
Trace::DeferredSetRegister* psr =
static_cast<Trace::DeferredSetRegister*>(action);
int budget,
bool not_at_start) {
if (budget <= 0) return 0;
- if (type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input!
+ if (action_type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input!
return on_success()->EatsAtLeast(still_to_find,
budget - 1,
not_at_start);
int budget,
BoyerMooreLookahead* bm,
bool not_at_start) {
- if (type_ == BEGIN_SUBMATCH) {
+ if (action_type_ == BEGIN_SUBMATCH) {
bm->SetRest(offset);
- } else if (type_ != POSITIVE_SUBMATCH_SUCCESS) {
+ } else if (action_type_ != POSITIVE_SUBMATCH_SUCCESS) {
on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start);
}
SaveBMInfo(bm, not_at_start, offset);
// implies false. So lets just return the max answer (still_to_find) since
// that won't prevent us from preloading a lot of characters for the other
// branches in the node graph.
- if (type() == AT_START && not_at_start) return still_to_find;
+ if (assertion_type() == AT_START && not_at_start) return still_to_find;
return on_success()->EatsAtLeast(still_to_find,
budget - 1,
not_at_start);
BoyerMooreLookahead* bm,
bool not_at_start) {
// Match the behaviour of EatsAtLeast on this node.
- if (type() == AT_START && not_at_start) return;
+ if (assertion_type() == AT_START && not_at_start) return;
on_success()->FillInBMInfo(offset, budget - 1, bm, not_at_start);
SaveBMInfo(bm, not_at_start, offset);
}
}
for (int k = 0; k < elms_->length(); k++) {
TextElement elm = elms_->at(k);
- if (elm.type == TextElement::ATOM) {
+ if (elm.text_type == TextElement::ATOM) {
Vector<const uc16> quarks = elm.data.u_atom->data();
for (int i = 0; i < characters && i < quarks.length(); i++) {
QuickCheckDetails::Position* pos =
int element_count = elms_->length();
for (int i = 0; i < element_count; i++) {
TextElement elm = elms_->at(i);
- if (elm.type == TextElement::ATOM) {
+ if (elm.text_type == TextElement::ATOM) {
Vector<const uc16> quarks = elm.data.u_atom->data();
for (int j = 0; j < quarks.length(); j++) {
uint16_t c = quarks[j];
copy[j] = converted;
}
} else {
- ASSERT(elm.type == TextElement::CHAR_CLASS);
+ ASSERT(elm.text_type == TextElement::CHAR_CLASS);
RegExpCharacterClass* cc = elm.data.u_char_class;
ZoneList<CharacterRange>* ranges = cc->ranges(zone());
if (!CharacterRange::IsCanonical(ranges)) {
if (lookahead->at(0)->is_non_word()) next_is_word_character = Trace::FALSE;
if (lookahead->at(0)->is_word()) next_is_word_character = Trace::TRUE;
}
- bool at_boundary = (type_ == AssertionNode::AT_BOUNDARY);
+ bool at_boundary = (assertion_type_ == AssertionNode::AT_BOUNDARY);
if (next_is_word_character == Trace::UNKNOWN) {
Label before_non_word;
Label before_word;
RegExpCompiler* compiler,
int filled_in,
bool not_at_start) {
- if (type_ == AT_START && not_at_start) {
+ if (assertion_type_ == AT_START && not_at_start) {
details->set_cannot_match();
return;
}
void AssertionNode::Emit(RegExpCompiler* compiler, Trace* trace) {
RegExpMacroAssembler* assembler = compiler->macro_assembler();
- switch (type_) {
+ switch (assertion_type_) {
case AT_END: {
Label ok;
assembler->CheckPosition(trace->cp_offset(), &ok);
for (int i = preloaded ? 0 : element_count - 1; i >= 0; i--) {
TextElement elm = elms_->at(i);
int cp_offset = trace->cp_offset() + elm.cp_offset;
- if (elm.type == TextElement::ATOM) {
+ if (elm.text_type == TextElement::ATOM) {
Vector<const uc16> quarks = elm.data.u_atom->data();
for (int j = preloaded ? 0 : quarks.length() - 1; j >= 0; j--) {
if (first_element_checked && i == 0 && j == 0) continue;
}
}
} else {
- ASSERT_EQ(elm.type, TextElement::CHAR_CLASS);
+ ASSERT_EQ(elm.text_type, TextElement::CHAR_CLASS);
if (pass == CHARACTER_CLASS_MATCH) {
if (first_element_checked && i == 0) continue;
if (DeterminedAlready(quick_check, elm.cp_offset)) continue;
int TextNode::Length() {
TextElement elm = elms_->last();
ASSERT(elm.cp_offset >= 0);
- if (elm.type == TextElement::ATOM) {
+ if (elm.text_type == TextElement::ATOM) {
return elm.cp_offset + elm.data.u_atom->data().length();
} else {
return elm.cp_offset + 1;
int element_count = elms_->length();
for (int i = 0; i < element_count; i++) {
TextElement elm = elms_->at(i);
- if (elm.type == TextElement::CHAR_CLASS) {
+ if (elm.text_type == TextElement::CHAR_CLASS) {
RegExpCharacterClass* cc = elm.data.u_char_class;
// None of the standard character classes is different in the case
// independent case and it slows us down if we don't know that.
int TextNode::GreedyLoopTextLength() {
TextElement elm = elms_->at(elms_->length() - 1);
- if (elm.type == TextElement::CHAR_CLASS) {
+ if (elm.text_type == TextElement::CHAR_CLASS) {
return elm.cp_offset + 1;
} else {
return elm.cp_offset + elm.data.u_atom->data().length();
RegExpCompiler* compiler) {
if (elms_->length() != 1) return NULL;
TextElement elm = elms_->at(0);
- if (elm.type != TextElement::CHAR_CLASS) return NULL;
+ if (elm.text_type != TextElement::CHAR_CLASS) return NULL;
RegExpCharacterClass* node = elm.data.u_char_class;
ZoneList<CharacterRange>* ranges = node->ranges(zone());
if (!CharacterRange::IsCanonical(ranges)) {
RecursionCheck rc(compiler);
- switch (type_) {
+ switch (action_type_) {
case STORE_POSITION: {
Trace::DeferredCapture
new_capture(data_.u_position_register.reg,
for (int i = 0; i < that->elements()->length(); i++) {
if (i > 0) stream()->Add(" ");
TextElement elm = that->elements()->at(i);
- switch (elm.type) {
+ switch (elm.text_type) {
case TextElement::ATOM: {
stream()->Add("'%w'", elm.data.u_atom->data());
break;
void DotPrinter::VisitAssertion(AssertionNode* that) {
stream()->Add(" n%p [", that);
- switch (that->type()) {
+ switch (that->assertion_type()) {
case AssertionNode::AT_END:
stream()->Add("label=\"$\", shape=septagon");
break;
void DotPrinter::VisitAction(ActionNode* that) {
stream()->Add(" n%p [", that);
- switch (that->type_) {
+ switch (that->action_type_) {
case ActionNode::SET_REGISTER:
stream()->Add("label=\"$%i:=%i\", shape=octagon",
that->data_.u_store_register.reg,
NodeInfo info;
Zone* zone = compiler->zone();
- switch (type()) {
+ switch (assertion_type()) {
case START_OF_LINE:
return AssertionNode::AfterNewline(on_success);
case START_OF_INPUT:
for (int i = 0; i < element_count; i++) {
TextElement& elm = elements()->at(i);
elm.cp_offset = cp_offset;
- if (elm.type == TextElement::ATOM) {
+ if (elm.text_type == TextElement::ATOM) {
cp_offset += elm.data.u_atom->data().length();
} else {
cp_offset++;
return;
}
TextElement text = elements()->at(i);
- if (text.type == TextElement::ATOM) {
+ if (text.text_type == TextElement::ATOM) {
RegExpAtom* atom = text.data.u_atom;
for (int j = 0; j < atom->length(); j++, offset++) {
if (offset >= bm->length()) {
}
}
} else {
- ASSERT(text.type == TextElement::CHAR_CLASS);
+ ASSERT(text.text_type == TextElement::CHAR_CLASS);
RegExpCharacterClass* char_class = text.data.u_char_class;
ZoneList<CharacterRange>* ranges = char_class->ranges(zone());
if (char_class->is_negated()) {
void DispatchTableConstructor::VisitText(TextNode* that) {
TextElement elm = that->elements()->at(0);
- switch (elm.type) {
+ switch (elm.text_type) {
case TextElement::ATOM: {
uc16 c = elm.data.u_atom->data()[0];
AddRange(CharacterRange(c, c));
class TextElement {
public:
- enum Type {UNINITIALIZED, ATOM, CHAR_CLASS};
- TextElement() : type(UNINITIALIZED) { }
- explicit TextElement(Type t) : type(t), cp_offset(-1) { }
+ enum TextType {UNINITIALIZED, ATOM, CHAR_CLASS};
+ TextElement() : text_type(UNINITIALIZED) { }
+ explicit TextElement(TextType t) : text_type(t), cp_offset(-1) { }
static TextElement Atom(RegExpAtom* atom);
static TextElement CharClass(RegExpCharacterClass* char_class);
int length();
- Type type;
+ TextType text_type;
union {
RegExpAtom* u_atom;
RegExpCharacterClass* u_char_class;
class ActionNode: public SeqRegExpNode {
public:
- enum Type {
+ enum ActionType {
SET_REGISTER,
INCREMENT_REGISTER,
STORE_POSITION,
int budget,
BoyerMooreLookahead* bm,
bool not_at_start);
- Type type() { return type_; }
+ ActionType action_type() { return action_type_; }
// TODO(erikcorry): We should allow some action nodes in greedy loops.
virtual int GreedyLoopTextLength() { return kNodeIsTooComplexForGreedyLoops; }
int range_to;
} u_clear_captures;
} data_;
- ActionNode(Type type, RegExpNode* on_success)
+ ActionNode(ActionType action_type, RegExpNode* on_success)
: SeqRegExpNode(on_success),
- type_(type) { }
- Type type_;
+ action_type_(action_type) { }
+ ActionType action_type_;
friend class DotPrinter;
};
class AssertionNode: public SeqRegExpNode {
public:
- enum AssertionNodeType {
+ enum AssertionType {
AT_END,
AT_START,
AT_BOUNDARY,
int budget,
BoyerMooreLookahead* bm,
bool not_at_start);
- AssertionNodeType type() { return type_; }
- void set_type(AssertionNodeType type) { type_ = type; }
+ AssertionType assertion_type() { return assertion_type_; }
private:
void EmitBoundaryCheck(RegExpCompiler* compiler, Trace* trace);
void BacktrackIfPrevious(RegExpCompiler* compiler,
Trace* trace,
IfPrevious backtrack_if_previous);
- AssertionNode(AssertionNodeType t, RegExpNode* on_success)
- : SeqRegExpNode(on_success), type_(t) { }
- AssertionNodeType type_;
+ AssertionNode(AssertionType t, RegExpNode* on_success)
+ : SeqRegExpNode(on_success), assertion_type_(t) { }
+ AssertionType assertion_type_;
};
class DeferredAction {
public:
- DeferredAction(ActionNode::Type type, int reg)
- : type_(type), reg_(reg), next_(NULL) { }
+ DeferredAction(ActionNode::ActionType action_type, int reg)
+ : action_type_(action_type), reg_(reg), next_(NULL) { }
DeferredAction* next() { return next_; }
bool Mentions(int reg);
int reg() { return reg_; }
- ActionNode::Type type() { return type_; }
+ ActionNode::ActionType action_type() { return action_type_; }
private:
- ActionNode::Type type_;
+ ActionNode::ActionType action_type_;
int reg_;
DeferredAction* next_;
friend class Trace;
static inline ScopeInfo* cast(Object* object);
// Return the type of this scope.
- ScopeType Type();
+ ScopeType scope_type();
// Does this scope call eval?
bool CallsEval();
};
// Properties of scopes.
- class TypeField: public BitField<ScopeType, 0, 3> {};
+ class ScopeTypeField: public BitField<ScopeType, 0, 3> {};
class CallsEvalField: public BitField<bool, 3, 1> {};
class LanguageModeField: public BitField<LanguageMode, 4, 2> {};
class FunctionVariableField: public BitField<FunctionVariableInfo, 6, 2> {};
}
-void RegExpBuilder::AddQuantifierToAtom(int min,
- int max,
- RegExpQuantifier::Type type) {
+void RegExpBuilder::AddQuantifierToAtom(
+ int min, int max, RegExpQuantifier::QuantifierType quantifier_type) {
if (pending_empty_) {
pending_empty_ = false;
return;
UNREACHABLE();
return;
}
- terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom), zone());
+ terms_.Add(
+ new(zone()) RegExpQuantifier(min, max, quantifier_type, atom), zone());
LAST(ADD_TERM);
}
}
-Scope* Parser::NewScope(Scope* parent, ScopeType type) {
- Scope* result = new(zone()) Scope(parent, type, zone());
+Scope* Parser::NewScope(Scope* parent, ScopeType scope_type) {
+ Scope* result = new(zone()) Scope(parent, scope_type, zone());
result->Initialize();
return result;
}
info()->is_extended_mode());
ASSERT(info()->language_mode() == shared_info->language_mode());
scope->SetLanguageMode(shared_info->language_mode());
- FunctionLiteral::Type type = shared_info->is_expression()
+ FunctionLiteral::FunctionType function_type = shared_info->is_expression()
? (shared_info->is_anonymous()
? FunctionLiteral::ANONYMOUS_EXPRESSION
: FunctionLiteral::NAMED_EXPRESSION)
false, // Strict mode name already checked.
shared_info->is_generator(),
RelocInfo::kNoPosition,
- type,
+ function_type,
&ok);
// Make sure the results agree.
ASSERT(ok == (result != NULL));
}
-void Parser::ReportMessage(const char* type, Vector<const char*> args) {
+void Parser::ReportMessage(const char* message, Vector<const char*> args) {
Scanner::Location source_location = scanner().location();
- ReportMessageAt(source_location, type, args);
+ ReportMessageAt(source_location, message, args);
}
-void Parser::ReportMessage(const char* type, Vector<Handle<String> > args) {
+void Parser::ReportMessage(const char* message, Vector<Handle<String> > args) {
Scanner::Location source_location = scanner().location();
- ReportMessageAt(source_location, type, args);
+ ReportMessageAt(source_location, message, args);
}
void Parser::ReportMessageAt(Scanner::Location source_location,
- const char* type,
+ const char* message,
Vector<const char*> args) {
MessageLocation location(script_,
source_location.beg_pos,
elements->set(i, *arg_string);
}
Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
- Handle<Object> result = factory->NewSyntaxError(type, array);
+ Handle<Object> result = factory->NewSyntaxError(message, array);
isolate()->Throw(*result, &location);
}
void Parser::ReportMessageAt(Scanner::Location source_location,
- const char* type,
+ const char* message,
Vector<Handle<String> > args) {
MessageLocation location(script_,
source_location.beg_pos,
elements->set(i, *args[i]);
}
Handle<JSArray> array = factory->NewJSArrayWithElements(elements);
- Handle<Object> result = factory->NewSyntaxError(type, array);
+ Handle<Object> result = factory->NewSyntaxError(message, array);
isolate()->Throw(*result, &location);
}
*ok = false;
return;
}
- Handle<String> type_string =
+ Handle<String> message_string =
isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"),
TENURED);
Expression* expression =
NewThrowTypeError(isolate()->factory()->redeclaration_string(),
- type_string, name);
+ message_string, name);
declaration_scope->SetIllegalRedeclaration(expression);
}
}
Scope* declaration_scope = top_scope_->DeclarationScope();
if (declaration_scope->is_global_scope() ||
declaration_scope->is_eval_scope()) {
- Handle<String> type = isolate()->factory()->illegal_return_string();
- Expression* throw_error = NewThrowSyntaxError(type, Handle<Object>::null());
+ Handle<String> message = isolate()->factory()->illegal_return_string();
+ Expression* throw_error =
+ NewThrowSyntaxError(message, Handle<Object>::null());
return factory()->NewExpressionStatement(throw_error);
}
return result;
// error here but for compatibility with JSC we choose to report
// the error at runtime.
if (expression == NULL || !expression->IsValidLeftHandSide()) {
- Handle<String> type =
+ Handle<String> message =
isolate()->factory()->invalid_lhs_in_for_in_string();
- expression = NewThrowReferenceError(type);
+ expression = NewThrowReferenceError(message);
}
ForInStatement* loop = factory()->NewForInStatement(labels);
Target target(&this->target_stack_, loop);
// runtime.
// TODO(ES5): Should change parsing for spec conformance.
if (expression == NULL || !expression->IsValidLeftHandSide()) {
- Handle<String> type =
+ Handle<String> message =
isolate()->factory()->invalid_lhs_in_assignment_string();
- expression = NewThrowReferenceError(type);
+ expression = NewThrowReferenceError(message);
}
if (!top_scope_->is_classic_mode()) {
// error here but for compatibility with JSC we choose to report the
// error at runtime.
if (expression == NULL || !expression->IsValidLeftHandSide()) {
- Handle<String> type =
+ Handle<String> message =
isolate()->factory()->invalid_lhs_in_prefix_op_string();
- expression = NewThrowReferenceError(type);
+ expression = NewThrowReferenceError(message);
}
if (!top_scope_->is_classic_mode()) {
// error here but for compatibility with JSC we choose to report the
// error at runtime.
if (expression == NULL || !expression->IsValidLeftHandSide()) {
- Handle<String> type =
+ Handle<String> message =
isolate()->factory()->invalid_lhs_in_postfix_op_string();
- expression = NewThrowReferenceError(type);
+ expression = NewThrowReferenceError(message);
}
if (!top_scope_->is_classic_mode()) {
name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name,
CHECK_OK);
}
- FunctionLiteral::Type type = name.is_null()
+ FunctionLiteral::FunctionType function_type = name.is_null()
? FunctionLiteral::ANONYMOUS_EXPRESSION
: FunctionLiteral::NAMED_EXPRESSION;
result = ParseFunctionLiteral(name,
is_strict_reserved_name,
is_generator,
function_token_position,
- type,
+ function_type,
CHECK_OK);
} else {
result = ParsePrimaryExpression(CHECK_OK);
if (object_literal != NULL) {
ASSERT(object_literal->is_simple());
if (object_literal->fast_elements()) {
- result->set(kTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS));
+ result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS));
} else {
- result->set(kTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
+ result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS));
}
result->set(kElementsSlot, *object_literal->constant_properties());
} else {
ArrayLiteral* array_literal = expression->AsArrayLiteral();
ASSERT(array_literal != NULL && array_literal->is_simple());
- result->set(kTypeSlot, Smi::FromInt(ARRAY_LITERAL));
+ result->set(kLiteralTypeSlot, Smi::FromInt(ARRAY_LITERAL));
result->set(kElementsSlot, *array_literal->constant_elements());
}
return result;
}
-CompileTimeValue::Type CompileTimeValue::GetType(Handle<FixedArray> value) {
- Smi* type_value = Smi::cast(value->get(kTypeSlot));
- return static_cast<Type>(type_value->value());
+CompileTimeValue::LiteralType CompileTimeValue::GetLiteralType(
+ Handle<FixedArray> value) {
+ Smi* literal_type = Smi::cast(value->get(kLiteralTypeSlot));
+ return static_cast<LiteralType>(literal_type->value());
}
};
-FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
- bool name_is_strict_reserved,
- bool is_generator,
- int function_token_position,
- FunctionLiteral::Type type,
- bool* ok) {
+FunctionLiteral* Parser::ParseFunctionLiteral(
+ Handle<String> function_name,
+ bool name_is_strict_reserved,
+ bool is_generator,
+ int function_token_position,
+ FunctionLiteral::FunctionType function_type,
+ bool* ok) {
// Function ::
// '(' FormalParameterList? ')' '{' FunctionBody '}'
// Function declarations are function scoped in normal mode, so they are
// hoisted. In harmony block scoping mode they are block scoped, so they
// are not hoisted.
- Scope* scope = (type == FunctionLiteral::DECLARATION && !is_extended_mode())
+ Scope* scope =
+ (function_type == FunctionLiteral::DECLARATION && !is_extended_mode())
? NewScope(top_scope_->DeclarationScope(), FUNCTION_SCOPE)
: NewScope(top_scope_, FUNCTION_SCOPE);
ZoneList<Statement*>* body = NULL;
// instead of Variables and Proxis as is the case now.
Variable* fvar = NULL;
Token::Value fvar_init_op = Token::INIT_CONST;
- if (type == FunctionLiteral::NAMED_EXPRESSION) {
+ if (function_type == FunctionLiteral::NAMED_EXPRESSION) {
if (is_extended_mode()) fvar_init_op = Token::INIT_CONST_HARMONY;
VariableMode fvar_mode = is_extended_mode() ? CONST_HARMONY : CONST;
fvar = new(zone()) Variable(top_scope_,
handler_count,
num_parameters,
duplicate_parameters,
- type,
+ function_type,
FunctionLiteral::kIsFunction,
parenthesized,
generator);
}
-Expression* Parser::NewThrowReferenceError(Handle<String> type) {
+Expression* Parser::NewThrowReferenceError(Handle<String> message) {
return NewThrowError(isolate()->factory()->MakeReferenceError_string(),
- type, HandleVector<Object>(NULL, 0));
+ message, HandleVector<Object>(NULL, 0));
}
-Expression* Parser::NewThrowSyntaxError(Handle<String> type,
+Expression* Parser::NewThrowSyntaxError(Handle<String> message,
Handle<Object> first) {
int argc = first.is_null() ? 0 : 1;
Vector< Handle<Object> > arguments = HandleVector<Object>(&first, argc);
return NewThrowError(
- isolate()->factory()->MakeSyntaxError_string(), type, arguments);
+ isolate()->factory()->MakeSyntaxError_string(), message, arguments);
}
-Expression* Parser::NewThrowTypeError(Handle<String> type,
+Expression* Parser::NewThrowTypeError(Handle<String> message,
Handle<Object> first,
Handle<Object> second) {
ASSERT(!first.is_null() && !second.is_null());
Vector< Handle<Object> > arguments =
HandleVector<Object>(elements, ARRAY_SIZE(elements));
return NewThrowError(
- isolate()->factory()->MakeTypeError_string(), type, arguments);
+ isolate()->factory()->MakeTypeError_string(), message, arguments);
}
Expression* Parser::NewThrowError(Handle<String> constructor,
- Handle<String> type,
+ Handle<String> message,
Vector< Handle<Object> > arguments) {
int argc = arguments.length();
Handle<FixedArray> elements = isolate()->factory()->NewFixedArray(argc,
elements, FAST_ELEMENTS, TENURED);
ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2, zone());
- args->Add(factory()->NewLiteral(type), zone());
+ args->Add(factory()->NewLiteral(message), zone());
args->Add(factory()->NewLiteral(array), zone());
CallRuntime* call_constructor =
factory()->NewCallRuntime(constructor, NULL, args);
int end_capture_index = captures_started();
int capture_index = stored_state->capture_index();
- SubexpressionType type = stored_state->group_type();
+ SubexpressionType group_type = stored_state->group_type();
// Restore previous state.
stored_state = stored_state->previous_state();
builder = stored_state->builder();
// Build result of subexpression.
- if (type == CAPTURE) {
+ if (group_type == CAPTURE) {
RegExpCapture* capture = new(zone()) RegExpCapture(body, capture_index);
captures_->at(capture_index - 1) = capture;
body = capture;
- } else if (type != GROUPING) {
- ASSERT(type == POSITIVE_LOOKAHEAD || type == NEGATIVE_LOOKAHEAD);
- bool is_positive = (type == POSITIVE_LOOKAHEAD);
+ } else if (group_type != GROUPING) {
+ ASSERT(group_type == POSITIVE_LOOKAHEAD ||
+ group_type == NEGATIVE_LOOKAHEAD);
+ bool is_positive = (group_type == POSITIVE_LOOKAHEAD);
body = new(zone()) RegExpLookahead(body,
is_positive,
end_capture_index - capture_index,
}
case '$': {
Advance();
- RegExpAssertion::Type type =
+ RegExpAssertion::AssertionType assertion_type =
multiline_ ? RegExpAssertion::END_OF_LINE :
RegExpAssertion::END_OF_INPUT;
- builder->AddAssertion(new(zone()) RegExpAssertion(type));
+ builder->AddAssertion(new(zone()) RegExpAssertion(assertion_type));
continue;
}
case '.': {
break;
}
case '(': {
- SubexpressionType type = CAPTURE;
+ SubexpressionType subexpr_type = CAPTURE;
Advance();
if (current() == '?') {
switch (Next()) {
case ':':
- type = GROUPING;
+ subexpr_type = GROUPING;
break;
case '=':
- type = POSITIVE_LOOKAHEAD;
+ subexpr_type = POSITIVE_LOOKAHEAD;
break;
case '!':
- type = NEGATIVE_LOOKAHEAD;
+ subexpr_type = NEGATIVE_LOOKAHEAD;
break;
default:
ReportError(CStrVector("Invalid group") CHECK_FAILED);
captures_->Add(NULL, zone());
}
// Store current state and begin new disjunction parsing.
- stored_state = new(zone()) RegExpParserState(stored_state, type,
+ stored_state = new(zone()) RegExpParserState(stored_state, subexpr_type,
captures_started(), zone());
builder = stored_state->builder();
continue;
default:
continue;
}
- RegExpQuantifier::Type type = RegExpQuantifier::GREEDY;
+ RegExpQuantifier::QuantifierType quantifier_type = RegExpQuantifier::GREEDY;
if (current() == '?') {
- type = RegExpQuantifier::NON_GREEDY;
+ quantifier_type = RegExpQuantifier::NON_GREEDY;
Advance();
} else if (FLAG_regexp_possessive_quantifier && current() == '+') {
// FLAG_regexp_possessive_quantifier is a debug-only flag.
- type = RegExpQuantifier::POSSESSIVE;
+ quantifier_type = RegExpQuantifier::POSSESSIVE;
Advance();
}
- builder->AddQuantifierToAtom(min, max, type);
+ builder->AddQuantifierToAtom(min, max, quantifier_type);
}
}
void AddAtom(RegExpTree* tree);
void AddAssertion(RegExpTree* tree);
void NewAlternative(); // '|'
- void AddQuantifierToAtom(int min, int max, RegExpQuantifier::Type type);
+ void AddQuantifierToAtom(
+ int min, int max, RegExpQuantifier::QuantifierType type);
RegExpTree* ToRegExp();
private:
bool name_is_reserved,
bool is_generator,
int function_token_position,
- FunctionLiteral::Type type,
+ FunctionLiteral::FunctionType type,
bool* ok);
// can be fully handled at compile time.
class CompileTimeValue: public AllStatic {
public:
- enum Type {
+ enum LiteralType {
OBJECT_LITERAL_FAST_ELEMENTS,
OBJECT_LITERAL_SLOW_ELEMENTS,
ARRAY_LITERAL
static Handle<FixedArray> GetValue(Expression* expression);
// Get the type of a compile time value returned by GetValue().
- static Type GetType(Handle<FixedArray> value);
+ static LiteralType GetLiteralType(Handle<FixedArray> value);
// Get the elements array of a compile time value returned by GetValue().
static Handle<FixedArray> GetElements(Handle<FixedArray> value);
private:
- static const int kTypeSlot = 0;
+ static const int kLiteralTypeSlot = 0;
static const int kElementsSlot = 1;
DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
Handle<FixedArray> array) {
Handle<FixedArray> elements = CompileTimeValue::GetElements(array);
const bool kHasNoFunctionLiteral = false;
- switch (CompileTimeValue::GetType(array)) {
+ switch (CompileTimeValue::GetLiteralType(array)) {
case CompileTimeValue::OBJECT_LITERAL_FAST_ELEMENTS:
return CreateObjectLiteralBoilerplate(isolate,
literals,
context_ = Handle<Context>(context_->previous(), isolate_);
}
}
- if (scope_info->Type() != EVAL_SCOPE) nested_scope_chain_.Add(scope_info);
+ if (scope_info->scope_type() != EVAL_SCOPE) {
+ nested_scope_chain_.Add(scope_info);
+ }
} else {
// Reparse the code and analyze the scopes.
Handle<Script> script(Script::cast(shared_info->script()));
// Check whether we are in global, eval or function code.
Handle<ScopeInfo> scope_info(shared_info->scope_info());
- if (scope_info->Type() != FUNCTION_SCOPE) {
+ if (scope_info->scope_type() != FUNCTION_SCOPE) {
// Global or eval code.
CompilationInfoWithZone info(script);
- if (scope_info->Type() == GLOBAL_SCOPE) {
+ if (scope_info->scope_type() == GLOBAL_SCOPE) {
info.MarkAsGlobal();
} else {
- ASSERT(scope_info->Type() == EVAL_SCOPE);
+ ASSERT(scope_info->scope_type() == EVAL_SCOPE);
info.MarkAsEval();
info.SetContext(Handle<Context>(function_->context()));
}
ASSERT(!failed_);
if (!nested_scope_chain_.is_empty()) {
Handle<ScopeInfo> scope_info = nested_scope_chain_.last();
- switch (scope_info->Type()) {
+ switch (scope_info->scope_type()) {
case FUNCTION_SCOPE:
ASSERT(context_->IsFunctionContext() ||
!scope_info->HasContext());
Handle<Context> current = context_chain.RemoveLast();
ASSERT(!(scope_info->HasContext() & current.is_null()));
- if (scope_info->Type() == CATCH_SCOPE) {
+ if (scope_info->scope_type() == CATCH_SCOPE) {
ASSERT(current->IsCatchContext());
Handle<String> name(String::cast(current->extension()));
Handle<Object> thrown_object(current->get(Context::THROWN_OBJECT_INDEX),
context,
name,
thrown_object);
- } else if (scope_info->Type() == BLOCK_SCOPE) {
+ } else if (scope_info->scope_type() == BLOCK_SCOPE) {
// Materialize the contents of the block scope into a JSObject.
ASSERT(current->IsBlockContext());
Handle<JSObject> block_scope_object =
new_context->set_previous(*context);
context = new_context;
} else {
- ASSERT(scope_info->Type() == WITH_SCOPE);
+ ASSERT(scope_info->scope_type() == WITH_SCOPE);
ASSERT(current->IsWithContext());
Handle<JSObject> extension(JSObject::cast(current->extension()));
context =
Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length);
// Encode the flags.
- int flags = TypeField::encode(scope->type()) |
+ int flags = ScopeTypeField::encode(scope->scope_type()) |
CallsEvalField::encode(scope->calls_eval()) |
LanguageModeField::encode(scope->language_mode()) |
FunctionVariableField::encode(function_name_info) |
}
-ScopeType ScopeInfo::Type() {
+ScopeType ScopeInfo::scope_type() {
ASSERT(length() > 0);
- return TypeField::decode(Flags());
+ return ScopeTypeField::decode(Flags());
}
FunctionVariableField::decode(Flags()) == CONTEXT;
bool has_context = context_locals > 0 ||
function_name_context_slot ||
- Type() == WITH_SCOPE ||
- (Type() == FUNCTION_SCOPE && CallsEval()) ||
- Type() == MODULE_SCOPE;
+ scope_type() == WITH_SCOPE ||
+ (scope_type() == FUNCTION_SCOPE && CallsEval()) ||
+ scope_type() == MODULE_SCOPE;
if (has_context) {
return Context::MIN_CONTEXT_SLOTS + context_locals +
(function_name_context_slot ? 1 : 0);
// ----------------------------------------------------------------------------
// Implementation of Scope
-Scope::Scope(Scope* outer_scope, ScopeType type, Zone* zone)
+Scope::Scope(Scope* outer_scope, ScopeType scope_type, Zone* zone)
: isolate_(zone->isolate()),
inner_scopes_(4, zone),
variables_(zone),
unresolved_(16, zone),
decls_(4, zone),
interface_(FLAG_harmony_modules &&
- (type == MODULE_SCOPE || type == GLOBAL_SCOPE)
+ (scope_type == MODULE_SCOPE || scope_type == GLOBAL_SCOPE)
? Interface::NewModule(zone) : NULL),
already_resolved_(false),
zone_(zone) {
- SetDefaults(type, outer_scope, Handle<ScopeInfo>::null());
+ SetDefaults(scope_type, outer_scope, Handle<ScopeInfo>::null());
// The outermost scope must be a global scope.
- ASSERT(type == GLOBAL_SCOPE || outer_scope != NULL);
+ ASSERT(scope_type == GLOBAL_SCOPE || outer_scope != NULL);
ASSERT(!HasIllegalRedeclaration());
}
Scope::Scope(Scope* inner_scope,
- ScopeType type,
+ ScopeType scope_type,
Handle<ScopeInfo> scope_info,
Zone* zone)
: isolate_(Isolate::Current()),
interface_(NULL),
already_resolved_(true),
zone_(zone) {
- SetDefaults(type, NULL, scope_info);
+ SetDefaults(scope_type, NULL, scope_info);
if (!scope_info.is_null()) {
num_heap_slots_ = scope_info_->ContextLength();
}
}
-void Scope::SetDefaults(ScopeType type,
+void Scope::SetDefaults(ScopeType scope_type,
Scope* outer_scope,
Handle<ScopeInfo> scope_info) {
outer_scope_ = outer_scope;
- type_ = type;
+ scope_type_ = scope_type;
scope_name_ = isolate_->factory()->empty_string();
dynamics_ = NULL;
receiver_ = NULL;
#ifdef DEBUG
-static const char* Header(ScopeType type) {
- switch (type) {
+static const char* Header(ScopeType scope_type) {
+ switch (scope_type) {
case EVAL_SCOPE: return "eval";
case FUNCTION_SCOPE: return "function";
case MODULE_SCOPE: return "module";
int n1 = n0 + 2; // indentation
// Print header.
- Indent(n0, Header(type_));
+ Indent(n0, Header(scope_type_));
if (scope_name_->length() > 0) {
PrintF(" ");
PrintName(scope_name_);
// ---------------------------------------------------------------------------
// Construction
- Scope(Scope* outer_scope, ScopeType type, Zone* zone);
+ Scope(Scope* outer_scope, ScopeType scope_type, Zone* zone);
// Compute top scope and allocate variables. For lazy compilation the top
// scope only contains the single lazily compiled function, so this
// Predicates.
// Specific scope types.
- bool is_eval_scope() const { return type_ == EVAL_SCOPE; }
- bool is_function_scope() const { return type_ == FUNCTION_SCOPE; }
- bool is_module_scope() const { return type_ == MODULE_SCOPE; }
- bool is_global_scope() const { return type_ == GLOBAL_SCOPE; }
- bool is_catch_scope() const { return type_ == CATCH_SCOPE; }
- bool is_block_scope() const { return type_ == BLOCK_SCOPE; }
- bool is_with_scope() const { return type_ == WITH_SCOPE; }
+ bool is_eval_scope() const { return scope_type_ == EVAL_SCOPE; }
+ bool is_function_scope() const { return scope_type_ == FUNCTION_SCOPE; }
+ bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; }
+ bool is_global_scope() const { return scope_type_ == GLOBAL_SCOPE; }
+ bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
+ bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
+ bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
bool is_declaration_scope() const {
return is_eval_scope() || is_function_scope() ||
is_module_scope() || is_global_scope();
// Accessors.
// The type of this scope.
- ScopeType type() const { return type_; }
+ ScopeType scope_type() const { return scope_type_; }
// The language mode of this scope.
LanguageMode language_mode() const { return language_mode_; }
ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
// The scope type.
- ScopeType type_;
+ ScopeType scope_type_;
// Debugging support.
Handle<String> scope_name_;
CHECK_EQ(scope->inner_scopes()->length(), 1);
i::Scope* inner_scope = scope->inner_scopes()->at(0);
- CHECK_EQ(inner_scope->type(), source_data[i].scope_type);
+ CHECK_EQ(inner_scope->scope_type(), source_data[i].scope_type);
CHECK_EQ(inner_scope->start_position(), kPrefixLen);
// The end position of a token is one position after the last
// character belonging to that token.