From 91d4a023000c2f77bdbf0cdf5981d2b20aa71aa2 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 30 Jul 2013 16:39:11 +0200 Subject: [PATCH] Make some clone methods statically accessible. Change-Id: I5943c30d239a26869fefec608cb8e4a27a31aaaa Reviewed-by: Lars Knoll --- src/qml/compiler/qv4jsir.cpp | 11 +++-------- src/qml/compiler/qv4jsir_p.h | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/qml/compiler/qv4jsir.cpp b/src/qml/compiler/qv4jsir.cpp index aea696d..f10c869 100644 --- a/src/qml/compiler/qv4jsir.cpp +++ b/src/qml/compiler/qv4jsir.cpp @@ -950,7 +950,7 @@ ExprList *CloneExpr::clone(ExprList *list) void CloneExpr::visitConst(Const *e) { - cloned = block->CONST(e->type, e->value); + cloned = cloneConst(e, block->function); } void CloneExpr::visitString(String *e) @@ -965,17 +965,12 @@ void CloneExpr::visitRegExp(RegExp *e) void CloneExpr::visitName(Name *e) { - if (e->id) - cloned = block->NAME(*e->id, e->line, e->column); - else - cloned = block->NAME(e->builtin, e->line, e->column); + cloned = cloneName(e, block->function); } void CloneExpr::visitTemp(Temp *e) { - Temp *t = block->function->New(); - t->init(e->kind, e->index, e->scope); - cloned = t; + cloned = cloneTemp(e, block->function); } void CloneExpr::visitClosure(Closure *e) diff --git a/src/qml/compiler/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h index 4b1a334..30e9074 100644 --- a/src/qml/compiler/qv4jsir_p.h +++ b/src/qml/compiler/qv4jsir_p.h @@ -855,6 +855,33 @@ public: return static_cast<_Expr *>(c); } + static Const *cloneConst(Const *c, Function *f) + { + Const *newConst = f->New(); + newConst->init(c->type, c->value); + return newConst; + } + + static Name *cloneName(Name *n, Function *f) + { + Name *newName = f->New(); + newName->type = n->type; + newName->id = n->id; + newName->builtin = n->builtin; + newName->global = n->global; + newName->line = n->line; + newName->column = n->column; + return newName; + } + + static Temp *cloneTemp(Temp *t, Function *f) + { + Temp *newTemp = f->New(); + newTemp->init(t->kind, t->index, t->scope); + newTemp->type = t->type; + return newTemp; + } + protected: V4IR::ExprList *clone(V4IR::ExprList *list); -- 2.7.4