Package analysis :: Package output :: Package visitors :: Module C :: Class CVisitor
[show private | hide private]
[frames | no frames]

Class CVisitor

ASTVisitor --+    
             |    
       Visitor --+
                 |
                CVisitor


A simple C-emitting visitor.
Method Summary
  __init__(self, generator, header_generator, module_names)
Initialise the visitor with the given 'generator' to which the final output is sent.
  default(self, node)
Handle a 'node' not explicitly handled elsewhere.
  in_function(self)
  process_binary_operator(self, node)
Produce this:
  process_sequence_operator(self, node)
  process_unary_operator(self, node)
  visitAnd(self, node)
  visitAssAttr(self, node)
  visitAssign(self, node)
  visitAssList(self, node)
  visitAssName(self, node)
  visitAssTuple(self, node)
  visitAugAssign(self, node)
  visitCallFunc(self, node)
Translate this...
  visitClass(self, node)
  visitCompare(self, node)
  visitConst(self, node)
  visitDiscard(self, node)
  visitFor(self, node)
  visitFunction(self, node)
  visitGetattr(self, node)
  visitGlobal(self, node)
  visitIf(self, node)
  visitImport(self, node)
  visitList(self, node)
  visitModule(self, node)
  visitName(self, node)
  visitNot(self, node)
  visitOr(self, node)
  visitPass(self, node)
  visitPrintnl(self, node)
  visitRaise(self, node)
  visitReturn(self, node)
  visitStmt(self, node)
  visitTuple(self, node)
  visitWhile(self, node)
  _ltype(self, node)
  _visitAssAttr(self, node)
    Inherited from Visitor
  is_builtin_module(self, node)
  is_native(self, node)
  uses_call(self, node)
    Inherited from ASTVisitor
  dispatch(self, node, *args)
  preorder(self, tree, visitor, *args)
Do preorder walk of tree using visitor

Class Variable Summary
int constant_start = 0                                                                     
    Inherited from ASTVisitor
int VERBOSE = 0                                                                     

Method Details

__init__(self, generator, header_generator, module_names)
(Constructor)

Initialise the visitor with the given 'generator' to which the final output is sent. Note that the visitor itself maintains a number of generators, controlled internally.

The specified 'header_generator' is used to accept declarations sent by the visitor in order to produce a header file which can be referenced by other modules in the same program.

The 'module_names' consist of the names of the entire set of modules used in the program.
Overrides:
analysis.output.visitors.common.Visitor.__init__

default(self, node)

Handle a 'node' not explicitly handled elsewhere.
Overrides:
compiler.visitor.ASTVisitor.default

process_binary_operator(self, node)

Produce this:

(PUSH(left)) && (PUSH(right)) && (PUSH(fn(left, right)) ? top : top

visitCallFunc(self, node)

Translate this...

expr(x, y, z)

...into this:

(_tmp = expr) ? (TYPEOF(_tmp) == C) ? new(C, 3) : (TYPEOF(_tmp) == D) ? new(D, 4) : 0 : 0

...or this:

(_tmp = expr) ? (FNAME(_tmp) == FNAME(f)) ? f(x, y, z) : (FNAME(_tmp) == FNAME(g)) ? g(x, y, z) : 0 : 0

Class Variable Details

constant_start

Type:
int
Value:
0                                                                     

Generated by Epydoc 2.1 on Fri May 19 01:52:26 2006 http://epydoc.sf.net