Fixes for Python 2.6

This commit is contained in:
Darryl Pogue
2010-12-18 22:18:32 -08:00
parent 3f8311122d
commit c6962d9f48
3 changed files with 21 additions and 4 deletions

View File

@@ -244,6 +244,8 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
stack.push(new ASTImport(new ASTName(code->getName(operand)), fromlist));
}
break;
case Pyc::IMPORT_FROM_A:
break;
case Pyc::IMPORT_STAR:
{
PycRef<ASTNode> import = stack.top();
@@ -317,7 +319,17 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
}
break;
case Pyc::LOAD_CONST_A:
stack.push(new ASTObject(code->getConst(operand)));
{
PycRef<ASTObject> t_ob = new ASTObject(code->getConst(operand));
if (t_ob->object()->type() == PycObject::TYPE_TUPLE &&
!t_ob->object().cast<PycTuple>()->values().size()) {
ASTTuple::value_t values;
stack.push(new ASTTuple(values));
} else {
stack.push(t_ob.cast<ASTNode>());
}
}
break;
case Pyc::LOAD_FAST_A:
if (mod->majorVer() == 1 && mod->minorVer() < 3)

View File

@@ -23,10 +23,15 @@ public:
{ m_stack[++m_ptr] = node; }
void pop()
{ m_stack[m_ptr--] = Node_NULL; }
{ if (m_ptr > -1) m_stack[m_ptr--] = Node_NULL; }
PycRef<ASTNode> top() const
{ return m_stack[m_ptr]; }
{
if (m_ptr > -1)
return m_stack[m_ptr];
else
return Node_NULL;
}
void replace(const FastStack& copy)
{

View File

@@ -36,7 +36,7 @@ public:
/* This is just for coding convenience -- no type checking is done! */
template <class _Cast>
PycRef<_Cast> cast() const { return (_Cast*)m_obj; }
PycRef<_Cast> cast() const { return static_cast<_Cast*>(m_obj); }
private:
_Obj* m_obj;