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


Python Ophis.Frontend类代码示例

本文整理汇总了Python中Ophis.Frontend的典型用法代码示例。如果您正苦于以下问题:Python Frontend类的具体用法?Python Frontend怎么用?Python Frontend使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: pragmaIncbin

def pragmaIncbin(ppt, line, result):
    "Includes a binary file"
    filename = line.expect("STRING").value
    offset = IR.ConstantExpr(0)
    size = None
    if str(line.lookahead(0)) == ",":
        line.pop()
        offset = FE.parse_expr(line)
        if str(line.lookahead(0)) == ",":
            line.pop()
            size = FE.parse_expr(line)
    line.expect("EOL")
    if type(filename) == str:
        try:
            f = file(os.path.join(FE.context_directory, filename), "rb")
            if offset.hardcoded and (size is None or size.hardcoded):
                # We know how big it will be, we can just use the values.
                # First check to make sure they're sane
                if offset.value() < 0:
                    Err.log("Offset may not be negative")
                    f.close()
                    return
                f.seek(0, 2)  # Seek to end of file
                if offset.value() > f.tell():
                    Err.log("Offset runs past end of file")
                    f.close()
                    return
                if size is not None:
                    if size.value() < 0:
                        Err.log("Length may not be negative")
                        f.close()
                        return
                    if offset.value() + size.value() > f.tell():
                        Err.log(".incbin length too long")
                        f.close()
                        return
                if size is None:
                    size = IR.ConstantExpr(-1)
                f.seek(offset.value())
                bytes = f.read(size.value())
                bytes = [IR.ConstantExpr(ord(x)) for x in bytes]
                result.append(IR.Node(ppt, "Byte", *bytes))
            else:
                # offset or length could change based on label placement.
                # This seems like an unbelievably bad idea, but since we
                # don't have constant prop it will happen for any symbolic
                # alias. Don't use symbolic aliases when extracting tiny
                # pieces out of humongous files, I guess.
                bytes = f.read()
                bytes = [IR.ConstantExpr(ord(x)) for x in bytes]
                if size is None:
                    size = IR.SequenceExpr([IR.ConstantExpr(len(bytes)),
                                            "-",
                                            offset])
                result.append(IR.Node(ppt, "ByteRange", offset, size, *bytes))
            f.close()
        except IOError:
            Err.log("Could not read " + filename)
            return
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:59,代码来源:CorePragmas.py

示例2: pragmaAdvance

def pragmaAdvance(ppt, line, result):
    "Outputs filler until reaching the target PC"
    newPC = FE.parse_expr(line)
    if str(line.lookahead(0)) == ",":
        line.pop()
        fillexpr = FE.parse_expr(line)
    else:
        fillexpr = IR.ConstantExpr(0)
    line.expect("EOL")
    result.append(IR.Node(ppt, "Advance", newPC, fillexpr))
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:10,代码来源:CorePragmas.py

示例3: readData

def readData(line):
	"Read raw data from a comma-separated list"
	if line.lookahead(0).type == "STRING":
		data = [IR.ConstantExpr(ord(x)) for x in line.expect("STRING").value.translate(currentcharmap)]
	else:
		data = [FE.parse_expr(line)]
	next = line.expect(',', 'EOL').type
	while next == ',':
		if line.lookahead(0).type == "STRING":
			data.extend([IR.ConstantExpr(ord(x)) for x in line.expect("STRING").value])
		else:
			data.append(FE.parse_expr(line))
		next = line.expect(',', 'EOL').type
	return data
开发者ID:PlayBoyMan,项目名称:happiNES-dev,代码行数:14,代码来源:CorePragmas.py

示例4: pragmaRequire

def pragmaRequire(ppt, line, result):
	"Includes a source file at most one time"
	filename = str(os.path.dirname(sys.argv[1])) + os.sep + line.expect("STRING").value
	line.expect("EOL")
	if type(filename)==str:
		global loadedfiles
		if filename not in loadedfiles:
			loadedfiles[filename]=1
			result.append(FE.parse_file(ppt,filename))
开发者ID:PlayBoyMan,项目名称:happiNES-dev,代码行数:9,代码来源:CorePragmas.py

示例5: pragmaRequire

def pragmaRequire(ppt, line, result):
    "Includes a source file at most one time"
    filename = line.expect("STRING").value
    line.expect("EOL")
    if type(filename) == str:
        result.append(FE.parse_file(ppt, filename, True))
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:6,代码来源:CorePragmas.py

示例6: pragmaInclude

def pragmaInclude(ppt, line, result):
    "Includes a source file"
    filename = line.expect("STRING").value
    line.expect("EOL")
    if type(filename) == str:
        result.append(FE.parse_file(ppt, filename))
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:6,代码来源:CorePragmas.py

示例7: pragmaAlias

def pragmaAlias(ppt, line, result):
    "Assigns an arbitrary label"
    lbl = line.expect("LABEL").value
    target = FE.parse_expr(line)
    result.append(IR.Node(ppt, "Label", lbl, target))
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:5,代码来源:CorePragmas.py

示例8: pragmaCheckpc

def pragmaCheckpc(ppt, line, result):
    "Enforces that the PC has not exceeded a certain point"
    target = FE.parse_expr(line)
    line.expect("EOL")
    result.append(IR.Node(ppt, "CheckPC", target))
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:5,代码来源:CorePragmas.py

示例9: pragmaOrg

def pragmaOrg(ppt, line, result):
    "Relocates the PC with no output"
    newPC = FE.parse_expr(line)
    line.expect("EOL")
    result.append(IR.Node(ppt, "SetPC", newPC))
开发者ID:ZaneDubya,项目名称:MetroidMMC3,代码行数:5,代码来源:CorePragmas.py

示例10: pragmaAdvance

def pragmaAdvance(ppt, line, result):
	"Outputs filler until reaching the target PC"
	newPC = FE.parse_expr(line)
	line.expect("EOL")
	result.append(IR.Node(ppt, "Advance", newPC))
开发者ID:PlayBoyMan,项目名称:happiNES-dev,代码行数:5,代码来源:CorePragmas.py

示例11: pragmaInclude

def pragmaInclude(ppt, line, result):
	"Includes a source file"
	filename = str(os.path.dirname(sys.argv[1])) + os.sep + line.expect("STRING").value
	line.expect("EOL")
	if type(filename)==str:	result.append(FE.parse_file(ppt,filename))
开发者ID:PlayBoyMan,项目名称:happiNES-dev,代码行数:5,代码来源:CorePragmas.py


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