当前位置: 首页>>代码示例>>Python>>正文


Python Context.saveCurrentBank方法代码示例

本文整理汇总了Python中context.Context.saveCurrentBank方法的典型用法代码示例。如果您正苦于以下问题:Python Context.saveCurrentBank方法的具体用法?Python Context.saveCurrentBank怎么用?Python Context.saveCurrentBank使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在context.Context的用法示例。


在下文中一共展示了Context.saveCurrentBank方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from context import Context [as 别名]
# 或者: from context.Context import saveCurrentBank [as 别名]
def main():
    totalTime = 0.0
    startTime = time.time()

    parser = OptionParser("usage: %prog [options] src_file [src_file...]")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Verbose output.")
    parser.add_option("-l", "--log", dest="logLevel", default=0, help="Print detailed log information.")
    parser.add_option("-t", "--test", action="store_true", dest="test", default=False, help="Run assembler test code.")
    parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Turn on assembler debugging code.")
    parser.add_option("-s", "--syntax-only", action="store_true", dest="syntaxOnly", default=False, help="Exit after checking syntax.")
    (options, args) = parser.parse_args()

    if len(args) < 1:
        parser.error("At least one source file must be supplied!")
        sys.exit(1)

    sources = []
    for arg in args:
        sources.append(arg)
        if not os.path.isfile(arg):
            parser.error("File \"%s\" does not exist" % arg)
            sys.exit(1)

    buildname = os.path.basename(os.getcwd())
    
    firstfile = args[0]
    firstfilename = args[0].split('.')[0]
    
    listfile = open(firstfile + ".lst", 'w')
    symtabfile = open(firstfile + ".symtab", 'w')
    binfile = open(firstfile + ".bin", 'wb')
    logfile = None
    if options.logLevel > 0:
        logfile = open(firstfilename + ".log", 'w')

    context = Context(Architecture.AGC4_B2, listfile, binfile, options, int(options.logLevel), logfile)
    assembler = Assembler(context)
    context.assembler = assembler

    if options.debug:
        print "Build:", buildname 
        endTime = time.time()
        delta = endTime - startTime
        totalTime += delta
        print "Initialisation: %3.2f seconds" % delta

    assembler.info("Simple AGC Assembler, v0.1", source=False)
    assembler.info("", source=False)

    startTime = time.time()
    for arg in args:
        try:
            assembler.assemble(arg)
        except:
            print >>sys.stderr
            print >>sys.stderr, "EXCEPTION:"
            traceback.print_exc(file=sys.stderr)
            print >>sys.stderr, "Context:"
            print >>sys.stderr, context
            raise
    if options.debug:
        endTime = time.time()
        delta = endTime - startTime
        totalTime += delta
        print "Pass 1: %3.2f seconds" % delta

    context.saveCurrentBank()

    if options.syntaxOnly == False and context.errors == 0:
        assembler.info("Resolving symbols...", source=False)
        startTime = time.time()
        try:
            assembler.resolve()
        except:
            assembler.log(1, "EXCEPTION:\n%s" % context)
            raise
        if options.debug:
            endTime = time.time()
            delta = endTime - startTime
            totalTime += delta

    for record in assembler.context.records:
        record.printMessages()

    assembler.info("Writing listing...", source=False)
    startTime = time.time()
    print >>listfile
    print >>listfile, "Listing"
    print >>listfile, "-------"
    for record in assembler.context.records:
        print >>listfile, record
    if options.debug:
        endTime = time.time()
        delta = endTime - startTime
        totalTime += delta
        print "Write listing: %3.2f seconds" % delta

    if not options.syntaxOnly:
        assembler.info("Writing symbol table listing...", source=False)
        startTime = time.time()
#.........这里部分代码省略.........
开发者ID:jimlawton,项目名称:pyagc,代码行数:103,代码来源:agcasm.py


注:本文中的context.Context.saveCurrentBank方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。