Remove old attempts at try handling.
This commit is contained in:
31
ASTNode.h
31
ASTNode.h
@@ -471,35 +471,4 @@ private:
|
||||
PycRef<ASTNode> m_idx;
|
||||
};
|
||||
|
||||
|
||||
/* Okay, prepare for a bit of illogic:
|
||||
* We store a try block.
|
||||
* We store the except and finally blocks INSIDE that try block.
|
||||
*
|
||||
* In implementation it gets a bit weirder, but given the way the opcodes
|
||||
* work, this is the most straightforward way of doing it.
|
||||
* Heh, "straightforward"...
|
||||
*/
|
||||
class ASTTryBlock : public ASTBlock {
|
||||
public:
|
||||
ASTTryBlock(unsigned int end, int finally = 0, int except = 0)
|
||||
: ASTBlock(BLK_TRY, end), m_finally_pos(finally), m_finally(), m_except_pos(except), m_except() { }
|
||||
|
||||
int finallyStart() const { return m_finally_pos; }
|
||||
int exceptStart() const { return m_except_pos; }
|
||||
PycRef<ASTBlock> finally() const { return m_finally; }
|
||||
const list_t& except() const { return m_except; }
|
||||
|
||||
void setFinallyStart(int finally) { m_finally_pos = finally; }
|
||||
void setExceptStart(int except) { m_except_pos = except; }
|
||||
void setFinally(PycRef<ASTBlock> finally) { m_finally = finally; }
|
||||
void setExcept(const list_t& except) { m_except = except; }
|
||||
|
||||
private:
|
||||
int m_finally_pos;
|
||||
PycRef<ASTBlock> m_finally;
|
||||
int m_except_pos;
|
||||
list_t m_except;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
49
ASTree.cpp
49
ASTree.cpp
@@ -439,30 +439,6 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
||||
break;
|
||||
case Pyc::END_FINALLY:
|
||||
{
|
||||
if (curblock->blktype() == ASTBlock::BLK_FINALLY) {
|
||||
PycRef<ASTBlock> finally = curblock;
|
||||
blocks.pop();
|
||||
|
||||
curblock = blocks.top();
|
||||
if (curblock->blktype() == ASTBlock::BLK_TRY) {
|
||||
PycRef<ASTTryBlock> parent = curblock.cast<ASTTryBlock>();
|
||||
parent->setFinally(finally);
|
||||
} else {
|
||||
fprintf(stderr, "Something TERRIBLE happened.\n");
|
||||
}
|
||||
blocks.pop();
|
||||
blocks.top()->append(curblock.cast<ASTNode>());
|
||||
|
||||
curblock = blocks.top();
|
||||
} else if (curblock->blktype() == ASTBlock::BLK_ELSE) {
|
||||
/* All except statements have an "else" block that
|
||||
bubbles the exception up... ignore it */
|
||||
if (curblock->size() == 0) {
|
||||
blocks.pop();
|
||||
}
|
||||
|
||||
curblock = blocks.top();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Pyc::EXEC_STMT:
|
||||
@@ -987,31 +963,14 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
||||
case Pyc::SET_LINENO_A:
|
||||
// Ignore
|
||||
break;
|
||||
/*case Pyc::SETUP_EXCEPT_A:
|
||||
case Pyc::SETUP_EXCEPT_A:
|
||||
{
|
||||
if (curblock->blktype() == ASTBlock::BLK_TRY) {
|
||||
PycRef<ASTTryBlock> tryblk = curblock.cast<ASTTryBlock>();
|
||||
if (tryblk->finally() && tryblk->except() == 0) {
|
||||
tryblk->set_except(pos+operand);
|
||||
} else {
|
||||
tryblk = new ASTTryBlock(pos, pos+operand, pos+operand, 0);
|
||||
blocks.push(tryblk.cast<ASTBlock>());
|
||||
curblock = blocks.top();
|
||||
}
|
||||
} else {
|
||||
PycRef<ASTBlock> tryblk = new ASTTryBlock(pos, pos+operand, pos+operand, 0);
|
||||
blocks.push(tryblk.cast<ASTBlock>());
|
||||
curblock = blocks.top();
|
||||
}
|
||||
}
|
||||
break;*/
|
||||
/*case Pyc::SETUP_FINALLY_A:
|
||||
break;
|
||||
case Pyc::SETUP_FINALLY_A:
|
||||
{
|
||||
PycRef<ASTBlock> tryblk = new ASTTryBlock(pos, pos+operand, 0, pos+operand);
|
||||
blocks.push(tryblk.cast<ASTBlock>());
|
||||
curblock = blocks.top();
|
||||
}
|
||||
break;*/
|
||||
break;
|
||||
case Pyc::SETUP_LOOP_A:
|
||||
{
|
||||
PycRef<ASTBlock> next = new ASTCondBlock(ASTBlock::BLK_WHILE, pos+operand, Node_NULL, false);
|
||||
|
Reference in New Issue
Block a user