def makeScopeOutLog(coord): (file, line) = getLocation(coord) return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', '"{0}:{1}:scope_out\\n"'.format( file, line)) ]))
def makeScopeOutLog(coord): (file, line) = getLocation(coord) return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', '"{0}:{1}:scope_out\\n"'.format(file, line)) ]))
def makeDeclLog(coord, declname): global vars type = getType(vars[-1][declname]) (file, line) = getLocation(coord) return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', '"{0}:{1}:decl({2},{3})\\n"'.format( file, line, getTypeString(type), getTypeName(type))) ]))
def makeDeclLog(coord, declname): global vars type = getType(vars[-1][declname]) (file, line) = getLocation(coord) return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant( 'string', '"{0}:{1}:decl({2},{3})\\n"'.format(file, line, getTypeString(type), getTypeName(type))) ]))
def makePostDecAssignLog(coord, declname, underlying = None): type = getType(vars[-1][declname]) name = declname (file, line) = getLocation(coord) if underlying != None: name = underlying return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', '"{0}:{1}:assign({2},{3},{4})\\n"'.format( file, line, getTypeString(type), getTypeName(type), getTypeFormatString(type))), c_ast.BinaryOp('-', c_ast.ID(name), c_ast.Constant('int', '1')) ]))
def makePostDecAssignLog(coord, declname, underlying=None): type = getType(vars[-1][declname]) name = declname (file, line) = getLocation(coord) if underlying != None: name = underlying return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant( 'string', '"{0}:{1}:assign({2},{3},{4})\\n"'.format( file, line, getTypeString(type), getTypeName(type), getTypeFormatString(type))), c_ast.BinaryOp('-', c_ast.ID(name), c_ast.Constant('int', '1')) ]))
def makeFuncReturnLog(coord, func, returnName=None): (file, line) = getLocation(coord) type = getType(func['type']) logString = '"{0}:{1}:return({2},{3},ret,'.format(file, line, func['name'], getTypeString(type)) if returnName == None: logString = logString + 'undef)\\n"' return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList( [c_ast.ID('stderr'), c_ast.Constant('string', logString)])) else: logString = logString + '{0})\\n"'.format(getTypeFormatString(type)) return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', logString), c_ast.ID(returnName) ]))
def makeFuncReturnLog(coord, func, returnName = None): (file, line) = getLocation(coord) type = getType(func['type']) logString = '"{0}:{1}:return({2},{3},ret,'.format( file, line, func['name'], getTypeString(type)) if returnName == None: logString = logString + 'undef)\\n"' return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', logString) ])) else: logString = logString + '{0})\\n"'.format(getTypeFormatString(type)) return c_ast.FuncCall( c_ast.ID('fprintf'), c_ast.ExprList([ c_ast.ID('stderr'), c_ast.Constant('string', logString), c_ast.ID(returnName) ]))
pm = PlaceMark(cli_code, site,street,city,state,country,equipment,long,lat) pm.setComment(comment) pop_pm = addPlaceMrk(pm) folder_layer0.append(pop_pm) cli_code = x[1][0:8] prev_cli = cli_code equipment = x[5] + ',' comment = x[1] + ',' site = cli_code street = x[2] country = x[4] city = '' state = '' long_lat = getLocation(cli_code) long= long_lat[1] lat = long_lat[0] if x[3] is not None : st_list = x[3].split() try: city = ' '.join(st_list[0:-2]) except Exception as err: print(st_list) print('Handling run-time error:', err) state = st_list[-2] # ef __init__(self, cli_code,site,street,city,state,country,equipment,long,lat) indent(kml)