virtual void MarkAsStatement() { /* do nothing */ }
// Static type information for this expression.
- SmiAnalysis* type() { return &type_; }
+ StaticType* type() { return &type_; }
Context context() { return context_; }
void set_context(Context context) { context_ = context; }
private:
- SmiAnalysis type_;
+ StaticType type_;
Context context_;
};
void CodeGenerator::GenericBinaryOperation(Token::Value op,
- SmiAnalysis* type,
+ StaticType* type,
OverwriteMode overwrite_mode) {
Comment cmnt(masm_, "[ BinaryOperation");
Comment cmnt_token(masm_, Token::String(op));
void CodeGenerator::ConstantSmiBinaryOperation(Token::Value op,
Result* operand,
Handle<Object> value,
- SmiAnalysis* type,
+ StaticType* type,
bool reversed,
OverwriteMode overwrite_mode) {
// NOTE: This is an attempt to inline (a bit) more of the code for
// a loop and the key is likely to be a smi.
Property* property = expression()->AsProperty();
ASSERT(property != NULL);
- SmiAnalysis* key_smi_analysis = property->key()->type();
+ StaticType* key_smi_analysis = property->key()->type();
if (cgen_->loop_nesting() > 0 && key_smi_analysis->IsLikelySmi()) {
Comment cmnt(masm, "[ Inlined store to keyed Property");
void GenericBinaryOperation(
Token::Value op,
- SmiAnalysis* type,
+ StaticType* type,
OverwriteMode overwrite_mode);
// If possible, combine two constant smi values using op to produce
void ConstantSmiBinaryOperation(Token::Value op,
Result* operand,
Handle<Object> constant_operand,
- SmiAnalysis* type,
+ StaticType* type,
bool reversed,
OverwriteMode overwrite_mode);
ast_printer_->inc_indent();
}
- explicit IndentedScope(const char* txt, SmiAnalysis* type = NULL) {
+ explicit IndentedScope(const char* txt, StaticType* type = NULL) {
ast_printer_->PrintIndented(txt);
if ((type != NULL) && (type->IsKnown())) {
ast_printer_->Print(" (type = ");
- ast_printer_->Print(SmiAnalysis::Type2String(type));
+ ast_printer_->Print(StaticType::Type2String(type));
ast_printer_->Print(")");
}
ast_printer_->Print("\n");
void AstPrinter::PrintLiteralWithModeIndented(const char* info,
Variable* var,
Handle<Object> value,
- SmiAnalysis* type) {
+ StaticType* type) {
if (var == NULL) {
PrintLiteralIndented(info, value, true);
} else {
if (type->IsKnown()) {
OS::SNPrintF(buf, "%s (mode = %s, type = %s)", info,
Variable::Mode2String(var->mode()),
- SmiAnalysis::Type2String(type));
+ StaticType::Type2String(type));
} else {
OS::SNPrintF(buf, "%s (mode = %s)", info,
Variable::Mode2String(var->mode()));
OS::SNPrintF(buf, "%s %s (type = %s)",
(node->is_prefix() ? "PRE" : "POST"),
Token::Name(node->op()),
- SmiAnalysis::Type2String(node->type()));
+ StaticType::Type2String(node->type()));
} else {
OS::SNPrintF(buf, "%s %s", (node->is_prefix() ? "PRE" : "POST"),
Token::Name(node->op()));
void PrintLiteralWithModeIndented(const char* info,
Variable* var,
Handle<Object> value,
- SmiAnalysis* type);
+ StaticType* type);
void PrintLabelsIndented(const char* info, ZoneStringList* labels);
void inc_indent() { indent_++; }
if (proxy != NULL) {
Variable* var = proxy->AsVariable();
if (var != NULL) {
- SmiAnalysis* var_type = var->type();
+ StaticType* var_type = var->type();
if (var_type->IsUnknown()) {
var_type->CopyFrom(node->type());
} else if (var_type->IsLikelySmi()) {
// ----------------------------------------------------------------------------
-// Implementation SmiAnalysis.
+// Implementation StaticType.
-const char* SmiAnalysis::Type2String(SmiAnalysis* type) {
+const char* StaticType::Type2String(StaticType* type) {
switch (type->kind_) {
case UNKNOWN:
return "UNKNOWN";
// Variables and AST expression nodes can track their "type" to enable
// optimizations and removal of redundant checks when generating code.
-class SmiAnalysis {
+class StaticType {
public:
enum Kind {
UNKNOWN,
LIKELY_SMI
};
- SmiAnalysis() : kind_(UNKNOWN) {}
+ StaticType() : kind_(UNKNOWN) {}
bool Is(Kind kind) const { return kind_ == kind; }
bool IsUnknown() const { return Is(UNKNOWN); }
bool IsLikelySmi() const { return Is(LIKELY_SMI); }
- void CopyFrom(SmiAnalysis* other) {
+ void CopyFrom(StaticType* other) {
kind_ = other->kind_;
}
- static const char* Type2String(SmiAnalysis* type);
+ static const char* Type2String(StaticType* type);
// LIKELY_SMI accessors
void SetAsLikelySmi() {
private:
Kind kind_;
- DISALLOW_COPY_AND_ASSIGN(SmiAnalysis);
+ DISALLOW_COPY_AND_ASSIGN(StaticType);
};
Expression* rewrite() const { return rewrite_; }
Slot* slot() const;
- SmiAnalysis* type() { return &type_; }
+ StaticType* type() { return &type_; }
private:
Scope* scope_;
UseCount obj_uses_; // uses of the object the variable points to
// Static type information
- SmiAnalysis type_;
+ StaticType type_;
// Code generation.
// rewrite_ is usually a Slot or a Property, but may be any expression.