From: Stefan S. <se...@sy...> - 2004-06-01 15:03:18
|
Hi Brian, Brian Kahne wrote: > One feature that would be really nice (perhaps this is possible- please > let me know if it is!) would be to get the type of an arbitrary > expression. For example, if I wanted to implement a "let" block, e.g. > > let (i = <expr>, j = <expr>) { > > } > > it would be really nice if I could directly query the ptree object > storing <expr> for its return type so that I could transform this code > into normal C++ declarations. yes, that would be possible with typed ptree nodes, as then the 'Walker' classes would not only act as a traversal, but also as a visitor, i.e. one could use the double-dispatch mechanism to resolve the type that is part of of ptree nodes being traversed. Right now the parent ptree node has to detect the sub-node's type by inspecting the node's topology, i.e. instead of if (node->Car()->IsLeaf()) do_something(); one would write if (if_statement->else_block) // access the *typed* 'else' statement, as 'this' // is a visitor with various 'visit_statement(Statement *)' methods if_statement->else_block->accept(this); You get the idea... > I think that releasing the code as a library would be very helpful, but > keeping the occ executable would still be a good idea- it's a very > convenient way to use the tool. I agree. As a convenience tool it covers the majority of the use cases, so it surely has its use. Regards, Stefan |