Skip to content

Commit

Permalink
Fixes for Python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed Dec 19, 2010
1 parent 3f83111 commit c6962d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
14 changes: 13 additions & 1 deletion ASTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions FastStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ class FastStack {
{ 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)
{
Expand Down
2 changes: 1 addition & 1 deletion object.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class PycRef {

/* 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;
Expand Down

0 comments on commit c6962d9

Please sign in to comment.