説明を見る。00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "v8.h"
00029
00030 #include "ast.h"
00031 #include "scopes.h"
00032
00033 namespace v8 { namespace internal {
00034
00035
00036 VariableProxySentinel VariableProxySentinel::this_proxy_(true);
00037 VariableProxySentinel VariableProxySentinel::identifier_proxy_(false);
00038 ValidLeftHandSideSentinel ValidLeftHandSideSentinel::instance_;
00039 Property Property::this_property_(VariableProxySentinel::this_proxy(), NULL, 0);
00040 Call Call::sentinel_(NULL, NULL, false, 0);
00041
00042
00043
00044
00045
00046 #define DECL_ACCEPT(type) \
00047 void type::Accept(Visitor* v) { \
00048 if (v->CheckStackOverflow()) return; \
00049 v->Visit##type(this); \
00050 }
00051 NODE_LIST(DECL_ACCEPT)
00052 #undef DECL_ACCEPT
00053
00054
00055
00056
00057
00058 VariableProxy::VariableProxy(Handle<String> name,
00059 bool is_this,
00060 bool inside_with)
00061 : name_(name),
00062 var_(NULL),
00063 is_this_(is_this),
00064 inside_with_(inside_with) {
00065
00066 ASSERT(name->IsSymbol());
00067
00068 var_uses_.RecordAccess(1);
00069 }
00070
00071
00072 VariableProxy::VariableProxy(bool is_this)
00073 : is_this_(is_this) {
00074 }
00075
00076
00077 void VariableProxy::BindTo(Variable* var) {
00078 ASSERT(var_ == NULL);
00079 ASSERT(var != NULL);
00080 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name()));
00081
00082
00083
00084
00085
00086 var_ = var;
00087 var->var_uses()->RecordUses(&var_uses_);
00088 var->obj_uses()->RecordUses(&obj_uses_);
00089 }
00090
00091
00092 #ifdef DEBUG
00093
00094 const char* LoopStatement::OperatorString() const {
00095 switch (type()) {
00096 case DO_LOOP: return "DO";
00097 case FOR_LOOP: return "FOR";
00098 case WHILE_LOOP: return "WHILE";
00099 }
00100 return NULL;
00101 }
00102
00103 #endif // DEBUG
00104
00105
00106 Token::Value Assignment::binary_op() const {
00107 switch (op_) {
00108 case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
00109 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR;
00110 case Token::ASSIGN_BIT_AND: return Token::BIT_AND;
00111 case Token::ASSIGN_SHL: return Token::SHL;
00112 case Token::ASSIGN_SAR: return Token::SAR;
00113 case Token::ASSIGN_SHR: return Token::SHR;
00114 case Token::ASSIGN_ADD: return Token::ADD;
00115 case Token::ASSIGN_SUB: return Token::SUB;
00116 case Token::ASSIGN_MUL: return Token::MUL;
00117 case Token::ASSIGN_DIV: return Token::DIV;
00118 case Token::ASSIGN_MOD: return Token::MOD;
00119 default: UNREACHABLE();
00120 }
00121 return Token::ILLEGAL;
00122 }
00123
00124
00125 bool FunctionLiteral::AllowsLazyCompilation() {
00126 return scope()->AllowsLazyCompilation();
00127 }
00128
00129
00130 ObjectLiteral::Property::Property(Literal* key, Expression* value) {
00131 key_ = key;
00132 value_ = value;
00133 Object* k = *key->handle();
00134 if (k->IsSymbol() && Heap::Proto_symbol()->Equals(String::cast(k))) {
00135 kind_ = PROTOTYPE;
00136 } else {
00137 kind_ = value_->AsLiteral() == NULL ? COMPUTED : CONSTANT;
00138 }
00139 }
00140
00141
00142 ObjectLiteral::Property::Property(bool is_getter, FunctionLiteral* value) {
00143 key_ = new Literal(value->name());
00144 value_ = value;
00145 kind_ = is_getter ? GETTER : SETTER;
00146 }
00147
00148
00149 void LabelCollector::AddLabel(Label* label) {
00150
00151 int length = labels_->length();
00152 for (int i = 0; i < length; i++) {
00153 if (labels_->at(i) == label) return;
00154 }
00155 labels_->Add(label);
00156 }
00157
00158
00159
00160
00161
00162
00163 void Visitor::VisitStatements(ZoneList<Statement*>* statements) {
00164 for (int i = 0; i < statements->length(); i++) {
00165 Visit(statements->at(i));
00166 }
00167 }
00168
00169
00170 void Visitor::VisitExpressions(ZoneList<Expression*>* expressions) {
00171 for (int i = 0; i < expressions->length(); i++) {
00172
00173
00174
00175
00176 Expression* expression = expressions->at(i);
00177 if (expression != NULL) Visit(expression);
00178 }
00179 }
00180
00181
00182 } }