Commit 919d64ad authored by rossberg@chromium.org's avatar rossberg@chromium.org

Add type field to AST expression nodes

More importantly, do a bunch of renamings of incidental existing "types" to avoid actual and potential name clashes (and also to improve consistency).

R=svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/16549002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 701f356b
......@@ -792,12 +792,12 @@ Interval RegExpQuantifier::CaptureRegisters() {
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;
}
......@@ -929,7 +929,7 @@ void* RegExpUnparser::VisitCharacterClass(RegExpCharacterClass* that,
void* RegExpUnparser::VisitAssertion(RegExpAssertion* that, void* data) {
switch (that->type()) {
switch (that->assertion_type()) {
case RegExpAssertion::START_OF_INPUT:
stream()->Add("@^i");
break;
......
......@@ -39,7 +39,8 @@
#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"
......@@ -163,9 +164,9 @@ typedef ZoneList<Handle<String> > ZoneStringList;
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;
......@@ -197,7 +198,7 @@ class AstProperties BASE_EMBEDDED {
class AstNode: public ZoneObject {
public:
#define DECLARE_TYPE_ENUM(type) k##type,
enum Type {
enum NodeType {
AST_NODE_LIST(DECLARE_TYPE_ENUM)
kInvalid = -1
};
......@@ -212,7 +213,7 @@ class AstNode: public ZoneObject {
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) \
......@@ -354,6 +355,9 @@ class Expression: public AstNode {
// 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();
......@@ -383,10 +387,12 @@ class Expression: public AstNode {
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_;
......@@ -396,7 +402,7 @@ class Expression: public AstNode {
class BreakableStatement: public Statement {
public:
enum Type {
enum BreakableType {
TARGET_FOR_ANONYMOUS,
TARGET_FOR_NAMED_ONLY
};
......@@ -412,15 +418,18 @@ class BreakableStatement: public Statement {
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);
......@@ -429,7 +438,7 @@ class BreakableStatement: public Statement {
private:
ZoneStringList* labels_;
Type type_;
BreakableType breakable_type_;
Label break_target_;
const BailoutId entry_id_;
const BailoutId exit_id_;
......@@ -1123,7 +1132,7 @@ class TargetCollector: public AstNode {
// 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_; }
......@@ -2117,7 +2126,7 @@ class Throw: public Expression {
class FunctionLiteral: public Expression {
public:
enum Type {
enum FunctionType {
ANONYMOUS_EXPRESSION,
NAMED_EXPRESSION,
DECLARATION
......@@ -2216,7 +2225,7 @@ class FunctionLiteral: public Expression {
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,
......@@ -2232,8 +2241,8 @@ class FunctionLiteral: public Expression {
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) |
......@@ -2379,7 +2388,7 @@ class RegExpAlternative: public RegExpTree {
class RegExpAssertion: public RegExpTree {
public:
enum Type {
enum AssertionType {
START_OF_LINE,
START_OF_INPUT,
END_OF_LINE,
......@@ -2387,7 +2396,7 @@ class RegExpAssertion: public RegExpTree {
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);
......@@ -2397,9 +2406,9 @@ class RegExpAssertion: public RegExpTree {
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_;
};
......@@ -2512,13 +2521,13 @@ class RegExpText: public RegExpTree {
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 {
......@@ -2542,9 +2551,9 @@ class RegExpQuantifier: public RegExpTree {
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:
......@@ -2553,7 +2562,7 @@ class RegExpQuantifier: public RegExpTree {
int max_;
int min_match_;
int max_match_;
Type type_;
QuantifierType quantifier_type_;
};
......@@ -3086,14 +3095,14 @@ class AstNodeFactory BASE_EMBEDDED {
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) {
......
......@@ -676,9 +676,9 @@ Handle<JSObject> Factory::NewNeanderObject() {
}
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);
}
......@@ -687,9 +687,9 @@ Handle<Object> Factory::NewTypeError(Handle<String> message) {
}
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);
}
......@@ -698,8 +698,9 @@ Handle<Object> Factory::NewRangeError(Handle<String> message) {
}
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);
}
......@@ -708,9 +709,9 @@ Handle<Object> Factory::NewSyntaxError(Handle<String> message) {
}
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);
}
......@@ -720,7 +721,7 @@ Handle<Object> Factory::NewReferenceError(Handle<String> message) {
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()));
......@@ -729,24 +730,24 @@ Handle<Object> Factory::NewError(const char* maker,
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];
......@@ -754,8 +755,8 @@ Handle<String> Factory::EmergencyNewError(const char* type,
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++) {
......@@ -784,7 +785,7 @@ Handle<String> Factory::EmergencyNewError(const char* type,
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(
......@@ -793,11 +794,11 @@ Handle<Object> Factory::NewError(const char* maker,
// 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.
......
......@@ -369,33 +369,33 @@ class Factory {
// 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);
......
This diff is collapsed.
......@@ -429,13 +429,13 @@ FOR_EACH_REG_EXP_TREE_TYPE(FORWARD_DECLARE)
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;
......@@ -739,7 +739,7 @@ class SeqRegExpNode: public RegExpNode {
class ActionNode: public SeqRegExpNode {
public:
enum Type {
enum ActionType {
SET_REGISTER,
INCREMENT_REGISTER,
STORE_POSITION,
......@@ -780,7 +780,7 @@ class ActionNode: public SeqRegExpNode {
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; }
......@@ -813,10 +813,10 @@ class ActionNode: public SeqRegExpNode {
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;
};
......@@ -876,7 +876,7 @@ class TextNode: public SeqRegExpNode {
class AssertionNode: public SeqRegExpNode {
public:
enum AssertionNodeType {
enum AssertionType {
AT_END,
AT_START,
AT_BOUNDARY,
......@@ -909,8 +909,7 @@ class AssertionNode: public SeqRegExpNode {
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);
......@@ -918,9 +917,9 @@ class AssertionNode: public SeqRegExpNode {
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_;
};
......@@ -1337,14 +1336,14 @@ class Trace {
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;
......
......@@ -3677,7 +3677,7 @@ class ScopeInfo : public FixedArray {
static inline ScopeInfo* cast(Object* object);
// Return the type of this scope.
ScopeType Type();
ScopeType scope_type();
// Does this scope call eval?
bool CallsEval();
......@@ -3860,7 +3860,7 @@ class ScopeInfo : public FixedArray {
};
// 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> {};
......
This diff is collapsed.
......@@ -269,7 +269,8 @@ class RegExpBuilder: public ZoneObject {
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:
......@@ -690,7 +691,7 @@ class Parser BASE_EMBEDDED {
bool name_is_reserved,
bool is_generator,
int function_token_position,
FunctionLiteral::Type type,
FunctionLiteral::FunctionType type,
bool* ok);
......@@ -867,7 +868,7 @@ class Parser BASE_EMBEDDED {
// 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
......@@ -881,13 +882,13 @@ class CompileTimeValue: public AllStatic {
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);
......
......@@ -425,7 +425,7 @@ static Handle<Object> CreateLiteralBoilerplate(
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,
......@@ -11234,7 +11234,9 @@ class ScopeIterator {
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()));
......@@ -11242,13 +11244,13 @@ class ScopeIterator {
// 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()));
}
......@@ -11314,7 +11316,7 @@ class ScopeIterator {
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());
......@@ -12022,7 +12024,7 @@ static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate,
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),
......@@ -12032,7 +12034,7 @@ static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate,
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 =
......@@ -12047,7 +12049,7 @@ static Handle<Context> CopyNestedScopeContextChain(Isolate* isolate,
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 =
......
......@@ -78,7 +78,7 @@ Handle<ScopeInfo> ScopeInfo::Create(Scope* scope, Zone* zone) {
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) |
......@@ -155,9 +155,9 @@ ScopeInfo* ScopeInfo::Empty(Isolate* isolate) {
}
ScopeType ScopeInfo::Type() {
ScopeType ScopeInfo::scope_type() {
ASSERT(length() > 0);
return TypeField::decode(Flags());
return ScopeTypeField::decode(Flags());
}
......@@ -193,9 +193,9 @@ int ScopeInfo::ContextLength() {
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);
......
......@@ -104,7 +104,7 @@ Variable* VariableMap::Lookup(Handle<String> name) {
// ----------------------------------------------------------------------------
// 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),
......@@ -114,19 +114,19 @@ Scope::Scope(Scope* outer_scope, ScopeType type, Zone* 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()),
......@@ -140,7 +140,7 @@ Scope::Scope(Scope* inner_scope,
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();
}
......@@ -177,11 +177,11 @@ Scope::Scope(Scope* inner_scope, Handle<String> catch_variable_name, Zone* zone)
}
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;
......@@ -780,8 +780,8 @@ void Scope::GetNestedScopeChain(
#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";
......@@ -855,7 +855,7 @@ void Scope::Print(int n) {
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_);
......
......@@ -97,7 +97,7 @@ class Scope: public ZoneObject {
// ---------------------------------------------------------------------------
// 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
......@@ -282,13 +282,13 @@ class Scope: public ZoneObject {
// 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();
......@@ -321,7 +321,7 @@ class Scope: public ZoneObject {
// 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_; }
......@@ -449,7 +449,7 @@ class Scope: public ZoneObject {
ZoneList<Scope*> inner_scopes_; // the immediately enclosed inner scopes
// The scope type.
ScopeType type_;
ScopeType scope_type_;
// Debugging support.
Handle<String> scope_name_;
......
......@@ -1036,7 +1036,7 @@ TEST(ScopePositions) {
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment