⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ast.h.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
  Expression* expression_;};class WithExitStatement: public Statement { public:  WithExitStatement() { }  virtual void Accept(Visitor* v);};class CaseClause: public ZoneObject { public:  CaseClause(Expression* label, ZoneList<Statement*>* statements)      : label_(label), statements_(statements) { }  bool is_default() const  { return label_ == NULL; }  Expression* label() const  {    CHECK(!is_default());    return label_;  }  ZoneList<Statement*>* statements() const  { return statements_; } private:  Expression* label_;  ZoneList<Statement*>* statements_;};class SwitchStatement: public BreakableStatement { public:  explicit SwitchStatement(ZoneStringList* labels)      : BreakableStatement(labels, TARGET_FOR_ANONYMOUS),        tag_(NULL), cases_(NULL) { }  void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {    tag_ = tag;    cases_ = cases;  }  virtual void Accept(Visitor* v);  Expression* tag() const  { return tag_; }  ZoneList<CaseClause*>* cases() const  { return cases_; } private:  Expression* tag_;  ZoneList<CaseClause*>* cases_;};// If-statements always have non-null references to their then- and// else-parts. When parsing if-statements with no explicit else-part,// the parser implicitly creates an empty statement. Use the// HasThenStatement() and HasElseStatement() functions to check if a// given if-statement has a then- or an else-part containing code.class IfStatement: public Statement { public:  IfStatement(Expression* condition,              Statement* then_statement,              Statement* else_statement)      : condition_(condition),        then_statement_(then_statement),        else_statement_(else_statement) { }  virtual void Accept(Visitor* v);  bool HasThenStatement() const { return !then_statement()->IsEmpty(); }  bool HasElseStatement() const { return !else_statement()->IsEmpty(); }  Expression* condition() const { return condition_; }  Statement* then_statement() const { return then_statement_; }  Statement* else_statement() const { return else_statement_; } private:  Expression* condition_;  Statement* then_statement_;  Statement* else_statement_;};// NOTE: LabelCollectors are represented as nodes to fit in the target// stack in the compiler; this should probably be reworked.class LabelCollector: public Node { public:  explicit LabelCollector(ZoneList<Label*>* labels) : labels_(labels) { }  // Adds a label to the collector. The collector stores a pointer not  // a copy of the label to make binding work, so make sure not to  // pass in references to something on the stack.  void AddLabel(Label* label);  // Virtual behaviour. LabelCollectors are never part of the AST.  virtual void Accept(Visitor* v) { UNREACHABLE(); }  virtual LabelCollector* AsLabelCollector() { return this; }  ZoneList<Label*>* labels() { return labels_; } private:  ZoneList<Label*>* labels_;};class TryStatement: public Statement { public:  explicit TryStatement(Block* try_block)      : try_block_(try_block), escaping_labels_(NULL) { }  void set_escaping_labels(ZoneList<Label*>* labels) {    escaping_labels_ = labels;  }  Block* try_block() const { return try_block_; }  ZoneList<Label*>* escaping_labels() const { return escaping_labels_; } private:  Block* try_block_;  ZoneList<Label*>* escaping_labels_;};class TryCatch: public TryStatement { public:  TryCatch(Block* try_block, Expression* catch_var, Block* catch_block)      : TryStatement(try_block),        catch_var_(catch_var),        catch_block_(catch_block) {    ASSERT(catch_var->AsVariableProxy() != NULL);  }  virtual void Accept(Visitor* v);  Expression* catch_var() const  { return catch_var_; }  Block* catch_block() const  { return catch_block_; } private:  Expression* catch_var_;  Block* catch_block_;};class TryFinally: public TryStatement { public:  TryFinally(Block* try_block, Expression* finally_var, Block* finally_block)      : TryStatement(try_block),        finally_var_(finally_var),        finally_block_(finally_block) { }  virtual void Accept(Visitor* v);  // If the finally block is non-trivial it may be problematic to have  // extra stuff on the expression stack while evaluating it. The  // finally variable is used to hold the state instead of storing it  // on the stack. It may be NULL in which case the state is stored on  // the stack.  Expression* finally_var() const { return finally_var_; }  Block* finally_block() const { return finally_block_; } private:  Expression* finally_var_;  Block* finally_block_;};class DebuggerStatement: public Statement { public:  virtual void Accept(Visitor* v);};class EmptyStatement: public Statement { public:  virtual void Accept(Visitor* v);  // Type testing & conversion.  virtual EmptyStatement* AsEmptyStatement() { return this; }};class Literal: public Expression { public:  explicit Literal(Handle<Object> handle) : handle_(handle) { }  virtual void Accept(Visitor* v);  // Type testing & conversion.  virtual Literal* AsLiteral() { return this; }  // Check if this literal is identical to the other literal.  bool IsIdenticalTo(const Literal* other) const {    return handle_.is_identical_to(other->handle_);  }  // Identity testers.  bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); }  bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); }  bool IsFalse() const {    return handle_.is_identical_to(Factory::false_value());  }  Handle<Object> handle() const { return handle_; } private:  Handle<Object> handle_;};// Base class for literals that needs space in the corresponding JSFunction.class MaterializedLiteral: public Expression { public:  explicit MaterializedLiteral(int literal_index)      : literal_index_(literal_index) {}  int literal_index() { return literal_index_; } private:  int literal_index_;};// An object literal has a boilerplate object that is used// for minimizing the work when constructing it at runtime.class ObjectLiteral: public MaterializedLiteral { public:  // Property is used for passing information  // about an object literal's properties from the parser  // to the code generator.  class Property: public ZoneObject {   public:    enum Kind {      CONSTANT,       // Property with constant value (at compile time).      COMPUTED,       // Property with computed value (at execution time).      GETTER, SETTER,  // Property is an accessor function.      PROTOTYPE       // Property is __proto__.    };    Property(Literal* key, Expression* value);    Property(bool is_getter, FunctionLiteral* value);    Literal* key() { return key_; }    Expression* value() { return value_; }    Kind kind() { return kind_; }   private:    Literal* key_;    Expression* value_;    Kind kind_;  };  ObjectLiteral(Handle<FixedArray> constant_properties,                ZoneList<Property*>* properties,                int literal_index)      : MaterializedLiteral(literal_index),        constant_properties_(constant_properties),        properties_(properties) {  }  virtual void Accept(Visitor* v);  Handle<FixedArray> constant_properties() const {    return constant_properties_;  }  ZoneList<Property*>* properties() const { return properties_; } private:  Handle<FixedArray> constant_properties_;  ZoneList<Property*>* properties_;};// Node for capturing a regexp literal.class RegExpLiteral: public MaterializedLiteral { public:  RegExpLiteral(Handle<String> pattern,                Handle<String> flags,                int literal_index)      : MaterializedLiteral(literal_index),        pattern_(pattern),        flags_(flags) {}  virtual void Accept(Visitor* v);  Handle<String> pattern() const { return pattern_; }  Handle<String> flags() const { return flags_; } private:  Handle<String> pattern_;  Handle<String> flags_;};// An array literal has a literals object that is used// used for minimizing the work when contructing it at runtime.class ArrayLiteral: public Expression { public:  ArrayLiteral(Handle<FixedArray> literals,               ZoneList<Expression*>* values)      : literals_(literals), values_(values) {  }  virtual void Accept(Visitor* v);  Handle<FixedArray> literals() const { return literals_; }  ZoneList<Expression*>* values() const { return values_; } private:  Handle<FixedArray> literals_;  ZoneList<Expression*>* values_;};class VariableProxy: public Expression { public:  virtual void Accept(Visitor* v);  // Type testing & conversion  virtual Property* AsProperty() {    return var_ == NULL ? NULL : var_->AsProperty();  }  virtual VariableProxy* AsVariableProxy()  { return this; }  Variable* AsVariable() {    return this == NULL || var_ == NULL ? NULL : var_->AsVariable();  }  virtual bool IsValidLeftHandSide() {    return var_ == NULL ? true : var_->IsValidLeftHandSide();  }  bool IsVariable(Handle<String> n) {    return !is_this() && name().is_identical_to(n);  }  // If this assertion fails it means that some code has tried to  // treat the special "this" variable as an ordinary variable with  // the name "this".  Handle<String> name() const  { return name_; }  Variable* var() const  { return var_; }  UseCount* var_uses()  { return &var_uses_; }  UseCount* obj_uses()  { return &obj_uses_; }  bool is_this() const  { return is_this_; }  bool inside_with() const  { return inside_with_; }  // Bind this proxy to the variable var.  void BindTo(Variable* var);  // Generate code to store into an expression evaluated as the left-hand  // side of an assignment.  The code will expect the stored value on top of  // the expression stack, and a reference containing the expression  // immediately below that.  virtual void GenerateStoreCode(MacroAssembler* masm,                                 Scope* scope,                                 Reference* ref,                                 InitState init_state); protected:  Handle<String> name_;  Variable* var_;  // resolved variable, or NULL  bool is_this_;  bool inside_with_;  // VariableProxy usage info.  UseCount var_uses_;  // uses of the variable value  UseCount obj_uses_;  // uses of the object the variable points to  VariableProxy(Handle<String> name, bool is_this, bool inside_with);  explicit VariableProxy(bool is_this);  friend class Scope;};class VariableProxySentinel: public VariableProxy { public:  virtual bool IsValidLeftHandSide() { return !is_this(); }  static VariableProxySentinel* this_proxy() { return &this_proxy_; }  static VariableProxySentinel* identifier_proxy() {    return &identifier_proxy_;  } private:  explicit VariableProxySentinel(bool is_this) : VariableProxy(is_this) { }  static VariableProxySentinel this_proxy_;  static VariableProxySentinel identifier_proxy_;};class Slot: public Expression { public:  enum Type {    // A slot in the parameter section on the stack. index() is    // the parameter index, counting left-to-right, starting at 0.    PARAMETER,    // A slot in the local section on the stack. index() is    // the variable index in the stack frame, starting at 0.    LOCAL,    // An indexed slot in a heap context. index() is the    // variable index in the context object on the heap,    // starting at 0. var()->scope() is the corresponding    // scope.    CONTEXT,    // A named slot in a heap context. var()->name() is the    // variable name in the context object on the heap,    // with lookup starting at the current context. index()    // is invalid.    LOOKUP,    // A property in the global object. var()->name() is    // the property name.    GLOBAL  };  Slot(Variable* var, Type type, int index)    : var_(var), type_(type), index_(index) {    ASSERT(var != NULL);  }  virtual void Accept(Visitor* v);  // Type testing & conversion  virtual Slot* AsSlot()  { return this; }  // Accessors  Variable* var() const  { return var_; }  Type type() const  { return type_; }  int index() const  { return index_; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -