コード例 #1
0
def addForDebug(parent, child, index):
    if nodeType(parent) != 'Compound':
        return
    preFor = [ASTModifier.makeScopeInLog(child.coord)]
    postFor = [ASTModifier.makeScopeOutLog(child.coord)]
    if nodeType(child.init) == 'DeclList':
        for (name, decl) in child.init.children():
            newDecl = ASTModifier.makeVarDecl(decl, decl.init)
            ASTModifier.addVar(decl)
            ASTModifier.addVar(newDecl)
            preFor.append(newDecl)
            preFor.append(ASTModifier.makeDeclLog(child.coord,
                                                getTypeName(getType(decl))))
            preFor.append(ASTModifier.makeAssignLog(child.coord,
                                                    getTypeName(getType(decl)),
                                                    getTypeName(getType(newDecl))))
            decl.init = ASTModifier.makeID(newDecl)
    else:
        child.init = makeAssignExprLog(child.init)
    child.cond = makeAssignExprLog(child.cond)
    child.next = makeAssignExprLog(child.next)
        
    parent.block_items = parent.block_items[:index] + \
                         preFor + \
                         [parent.block_items[index]] + \
                         postFor + \
                         parent.block_items[index + 1:]
コード例 #2
0
def addWhileDebug(parent, child, index):
    if nodeType(parent) != 'Compound':
        return
    child.cond = makeAssignExprLog(child.cond)
    parent.block_items = parent.block_items[:index] + \
                         [ASTModifier.makeScopeInLog(child.coord)] + \
                         [parent.block_items[index]] + \
                         [ASTModifier.makeScopeOutLog(child.coord)] + \
                         parent.block_items[index + 1:]