virtual void visitCJump(V4IR::CJump *);
virtual void visitRet(V4IR::Ret *);
virtual void visitTry(V4IR::Try *);
- virtual void visitDebugAnnotation(V4IR::DebugAnnotation *) {}
virtual void callBuiltinInvalid(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result);
virtual void callBuiltinTypeofMember(V4IR::Temp *base, const QString &name, V4IR::Temp *result);
if (! _stmt->d->defs.contains(t->exceptionVar->index))
_stmt->d->defs.append(t->exceptionVar->index);
}
- virtual void visitDebugAnnotation(V4IR::DebugAnnotation *) {}
virtual void visitTemp(V4IR::Temp *e) {
if (e->index < 0 || e->scope != 0)
virtual void visitCJump(V4IR::CJump *s) { s->cond->accept(this); }
virtual void visitRet(V4IR::Ret *s) { s->expr->accept(this); }
virtual void visitTry(V4IR::Try *) {}
- virtual void visitDebugAnnotation(V4IR::DebugAnnotation *) {}
virtual void visitCall(V4IR::Call *e) {
e->base->accept(this);
virtual void visitCJump(V4IR::CJump *s) { s->cond->accept(this); }
virtual void visitRet(V4IR::Ret *s) { s->expr->accept(this); }
virtual void visitTry(V4IR::Try *t) { visitTemp(t->exceptionVar); }
- virtual void visitDebugAnnotation(V4IR::DebugAnnotation *) {}
virtual void visitTemp(V4IR::Temp *e) {
if (e->scope) // scoped local
void Codegen::statement(Statement *ast)
{
- _block->DEBUGANNOTATION(ast->firstSourceLocation());
+ _block->nextLocation = ast->firstSourceLocation();
accept(ast);
}
s->dump(out, V4IR::Stmt::MIR);
out.flush();
+ if (s->location.isValid())
+ qout << " // line: " << s->location.startLine << " column: " << s->location.startColumn << endl;
+
#ifndef QV4_NO_LIVENESS
for (int i = 60 - str.size(); i >= 0; --i)
str.append(' ');
}
foreach (V4IR::Stmt *s, block->statements) {
+ if (s->location.isValid())
+ _as->recordLineNumber(s->location.startLine);
s->accept(this);
}
}
_as->jump(Assembler::ReturnValueRegister);
}
-void InstructionSelection::visitDebugAnnotation(V4IR::DebugAnnotation *annotation)
-{
- _as->recordLineNumber(annotation->location.startLine);
-}
-
void InstructionSelection::callBuiltinFinishTry()
{
// This assumes that we're in code that was called by tryWrapper, so we return to try wrapper
virtual void visitCJump(V4IR::CJump *);
virtual void visitRet(V4IR::Ret *);
virtual void visitTry(V4IR::Try *);
- virtual void visitDebugAnnotation(V4IR::DebugAnnotation *);
private:
#define isel_stringIfyx(s) #s
// nothing to do for Try statements
}
- virtual void visitDebugAnnotation(DebugAnnotation *) {}
-
// expressions
virtual void visitConst(Const *) {}
virtual void visitString(String *) {}
out << " with the name " << exceptionVarName << " and go to L" << catchBlock->index << ';';
}
-void DebugAnnotation::dump(QTextStream &out, Mode mode)
-{
- out << "// line: " << location.startLine << " ; column: " << location.startColumn;
-}
-
Function *Module::newFunction(const QString &name, Function *outer)
{
Function *f = new Function(this, outer, name);
Exp *s = function->New<Exp>();
s->init(expr);
- statements.append(s);
+ appendStatement(s);
return s;
}
Enter *s = function->New<Enter>();
s->init(expr);
- statements.append(s);
+ appendStatement(s);
return s;
}
Leave *s = function->New<Leave>();
s->init();
- statements.append(s);
+ appendStatement(s);
return s;
}
Move *s = function->New<Move>();
s->init(target, source, op);
- statements.append(s);
+ appendStatement(s);
return s;
}
Jump *s = function->New<Jump>();
s->init(target);
- statements.append(s);
+ appendStatement(s);
assert(! out.contains(target));
out.append(target);
CJump *s = function->New<CJump>();
s->init(cond, iftrue, iffalse);
- statements.append(s);
+ appendStatement(s);
assert(! out.contains(iftrue));
out.append(iftrue);
Ret *s = function->New<Ret>();
s->init(expr);
- statements.append(s);
+ appendStatement(s);
return s;
}
Try *t = function->New<Try>();
t->init(tryBlock, catchBlock, exceptionVarName, exceptionVar);
- statements.append(t);
+ appendStatement(t);
assert(! out.contains(tryBlock));
out.append(tryBlock);
return t;
}
-Stmt *BasicBlock::DEBUGANNOTATION(const AST::SourceLocation &location)
-{
- if (isTerminated())
- return 0;
-
- DebugAnnotation *t = function->New<DebugAnnotation>();
- t->init(location);
- statements.append(t);
-}
-
void BasicBlock::dump(QTextStream &out, Stmt::Mode mode)
{
out << 'L' << index << ':' << endl;
foreach (Stmt *s, statements) {
out << '\t';
s->dump(out, mode);
+
+ if (s->location.isValid())
+ out << " // line: " << s->location.startLine << " ; column: " << s->location.startColumn;
+
out << endl;
}
}
+void BasicBlock::appendStatement(Stmt *statement)
+{
+ if (nextLocation.isValid()) {
+ statement->location = nextLocation;
+ nextLocation = AST::SourceLocation();
+ }
+ statements.append(statement);
+}
+
CloneExpr::CloneExpr(BasicBlock *block)
: block(block), cloned(0)
{
struct CJump;
struct Ret;
struct Try;
-struct DebugAnnotation;
enum AluOp {
OpInvalid = 0,
virtual void visitCJump(CJump *) = 0;
virtual void visitRet(Ret *) = 0;
virtual void visitTry(Try *) = 0;
- virtual void visitDebugAnnotation(DebugAnnotation *) = 0;
};
struct Expr {
};
Data *d;
+ AST::SourceLocation location;
Stmt(): d(0) {}
virtual ~Stmt() { Q_UNREACHABLE(); }
virtual CJump *asCJump() { return 0; }
virtual Ret *asRet() { return 0; }
virtual Try *asTry() { return 0; }
- virtual DebugAnnotation *asDebugAnnotation() { return 0; }
virtual void dump(QTextStream &out, Mode mode = HIR) = 0;
void destroyData() {
virtual void dump(QTextStream &out, Mode mode);
};
-struct DebugAnnotation: Stmt {
- AST::SourceLocation location;
-
- void init(const AST::SourceLocation &location)
- {
- this->location = location;
- }
-
- virtual void accept(StmtVisitor *v) { v->visitDebugAnnotation(this); }
- virtual DebugAnnotation *asDebugAnnotation() { return this; }
-
- virtual void dump(QTextStream &out, Mode mode);
-};
-
struct Q_QML_EXPORT Module {
MemoryPool pool;
QVector<Function *> functions;
QBitArray liveOut;
int index;
int offset;
+ AST::SourceLocation nextLocation;
BasicBlock(Function *function): function(function), index(-1), offset(-1) {}
~BasicBlock() {}
Stmt *CJUMP(Expr *cond, BasicBlock *iftrue, BasicBlock *iffalse);
Stmt *RET(Temp *expr);
Stmt *TRY(BasicBlock *tryBlock, BasicBlock *catchBlock, const QString &exceptionVarName, Temp *exceptionVar);
- Stmt *DEBUGANNOTATION(const AST::SourceLocation &location);
void dump(QTextStream &out, Stmt::Mode mode = Stmt::HIR);
+
+ void appendStatement(Stmt *statement);
};
class CloneExpr: protected V4IR::ExprVisitor