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


Python Errors.report方法代码示例

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


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

示例1: run_all

# 需要导入模块: import Errors [as 别名]
# 或者: from Errors import report [as 别名]
def run_all():
    """Transforms the source infiles to a binary outfile.

    Returns a shell-style exit code: 1 if there were errors, 0 if there
    were no errors.

    """
    Err.count = 0
    Tamagotchi.process(CmdLine.infiles)
    z = Frontend.parse(CmdLine.infiles)
    env = Environment.Environment()

    m = Passes.ExpandMacros()
    i = Passes.InitLabels()
    l_basic = Passes.UpdateLabels()
    l = Passes.FixPoint("label update", [l_basic],
                              lambda: not l_basic.changed)

    # The instruction selector is a bunch of fixpoints, and which
    # passes run depends on the command line options a bit.
    c_basic = Passes.Collapse()
    c = Passes.FixPoint("instruction selection 1", [l, c_basic],
                              lambda: not c_basic.changed)

    if CmdLine.enable_branch_extend:
        b = Passes.ExtendBranches()
        instruction_select = Passes.FixPoint("instruction selection 2",
                                                   [c, b],
                                                   lambda: not b.changed)
    else:
        instruction_select = c
    a = Passes.Assembler()

    passes = []
    passes.append(Passes.DefineMacros())
    passes.append(Passes.FixPoint("macro expansion", [m],
                                        lambda: not m.changed))
    passes.append(Passes.FixPoint("label initialization", [i],
                                        lambda: not i.changed))
    passes.extend([Passes.CircularityCheck(),
                   Passes.CheckExprs(),
                   Passes.EasyModes()])
    passes.append(instruction_select)
    passes.extend([Passes.NormalizeModes(),
                   Passes.UpdateLabels(),
                   a])

    for p in passes:
        p.go(z, env)

    if Err.count == 0:
        try:
            outfile = CmdLine.outfile
            if outfile == '-':
                output = sys.stdout
                if sys.platform == "win32":
                    # We can't dump our binary in text mode; that would be
                    # disastrous. So, we'll do some platform-specific
                    # things here to force our stdout to binary mode.
                    import msvcrt
                    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
            elif outfile is None:
                output = file('bin', 'wb')
            else:
                output = file(outfile, 'wb')
            f = open("template.txt", "rb")
            t = f.read()
            head = t[:0x40000]
            if (len("".join(map(chr, a.output))) > 0x400):
                print "too large"
                return 1
            tail = t[(0x40000 + len("".join(map(chr, a.output)))):]
            output.write(head + "".join(map(chr, a.output)) + tail)
            output.flush()
            if outfile != '-':
                output.close()
            return 0
        except IOError:
                print>>sys.stderr, "Could not write to " + outfile
                return 1
    else:
        Err.report()
        return 1
开发者ID:0day1day,项目名称:Egg-Shell,代码行数:85,代码来源:tASMgotchi.py


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