@@ -12,7 +12,7 @@ class ASTNode {
12
12
NODE_INVALID, NODE_NODELIST, NODE_OBJECT, NODE_UNARY, NODE_BINARY,
13
13
NODE_COMPARE, NODE_STORE, NODE_RETURN, NODE_NAME, NODE_DELETE,
14
14
NODE_FUNCTION, NODE_CLASS, NODE_CALL, NODE_IMPORT, NODE_TUPLE,
15
- NODE_LIST, NODE_MAP, NODE_SUBSCR, NODE_PRINT, NODE_JUMP,
15
+ NODE_LIST, NODE_MAP, NODE_SUBSCR, NODE_PRINT, NODE_JUMP, NODE_BLOCK,
16
16
17
17
// Empty nodes
18
18
NODE_PASS, NODE_LOCALS
@@ -331,4 +331,33 @@ class ASTJump : public ASTNode {
331
331
Condition m_jtype;
332
332
PycRef<ASTNode> m_cond;
333
333
};
334
+
335
+ class ASTBlock : public ASTNode {
336
+ public:
337
+ typedef std::list<PycRef<ASTNode> > list_t ;
338
+
339
+ enum Type {
340
+ BLK_MAIN, BLK_TRY, BLK_EXCEPT, BLK_FINALLY, BLK_WHILE, BLK_FOR
341
+ };
342
+
343
+ ASTBlock (Type type, unsigned int start = 0 , unsigned int end = 0 )
344
+ : ASTNode(NODE_BLOCK), m_type(type), m_start(start), m_end(end)
345
+ { }
346
+
347
+ Type type () const { return m_type; }
348
+ unsigned int start () const { return m_start; }
349
+ unsigned int end () const { return m_end; }
350
+ const list_t & nodes () const { return m_nodes; }
351
+ void removeFirst ();
352
+ void removeLast ();
353
+ void append (PycRef<ASTNode> node) { m_nodes.push_back (node); }
354
+ const char * type_str () const ;
355
+
356
+ private:
357
+ Type m_type;
358
+ unsigned int m_start;
359
+ unsigned int m_end;
360
+ list_t m_nodes;
361
+ };
362
+
334
363
#endif
0 commit comments