'''
Created on 07.05.2017

@author: Mr. Jones
'''

'''receive values from a given node and add them to the given dictionary'''
class ExtractValueVisitor():
        
    def __init__(self):
        self.optimization = 0
        self.values = {}

    def visit(self, node,parent):
        method = 'visit_%s' % node.__class__.__name__
        return getattr(self, method, self.generic_visit)(node,parent)

    def generic_visit(self, node,parent):
        for child in node:
            self.visit(child,parent)
            
    def visit_VarDecl(self, node):
        identifier = node.identifier.value
        self.values[identifier] = node.initializer