本文整理汇总了Python中Constants.string方法的典型用法代码示例。如果您正苦于以下问题:Python Constants.string方法的具体用法?Python Constants.string怎么用?Python Constants.string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constants
的用法示例。
在下文中一共展示了Constants.string方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_function_expression
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import string [as 别名]
def gen_function_expression(ast):
assert ast[0] == 'FunctionExpression'
label = Labels.function()
func, temp = Registers.allocate(2)
builder.inst_newfunc(func, label)
context['function'].append(func)
if ast[2] != '(':
# The function has an identifier
identifier = gen_identifier(ast[2], True)
builder.inst_getvar(temp, identifier)
builder.inst_move(temp, func)
Registers.free([identifier])
args, t1, t2 = Registers.allocate(3)
builder.inst_la(t1, Constants.string('arguments'))
builder.inst_getfield(args, func, t1)
if ast[-3] != '(':
# The function has arguments
offset = -16
for node in ast[-3]:
if type(node) == list:
arg = gen_identifier(node, True)
builder.inst_getfield(t1, args, arg)
builder.inst_la(t2, Constants.integer(offset))
builder.inst_move(t1, t2)
Registers.free([arg])
offset -= 4
Registers.free([t1, t2])
# The function body starts.
builder.enter(label)
gen_function_body(ast[-1])
builder.exit(label)
context['function'].pop()
return func
示例2: gen_identifier
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import string [as 别名]
def gen_identifier(ast, as_literal=False):
assert ast[0] == 'Identifier'
ret = Registers.allocate(1)[0]
builder.inst_la(ret, Constants.string(ast[1]))
if not as_literal:
builder.inst_getvar(ret, ret) # TODO: getvar/findvar?
return ret
示例3: gen_allocation_expression
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import string [as 别名]
def gen_allocation_expression(ast):
assert ast[0] == 'AllocationExpression'
func = gen_member_expression(ast[2]) # it should be a function
args = []
if ast[3][-2] != '(': # there are some arguments
for node in ast[3][-2]:
if type(node) == list:
args.append(gen_assignment_expression_no_in(node))
this = Registers.allocate(1)[0]
builder.inst_newobj(this)
builder.call_func(func, this, args)
Registers.free([this] + args)
ret, temp = Registers.allocate(2)
builder.get_this(ret)
builder.get_ret(temp) # temp will be discarded immediately
builder.inst_la(temp, Constants.string('constructor'))
builder.inst_getfield(temp, ret, temp)
builder.inst_move(temp, func)
Registers.free([temp, func])
return ret
示例4: gen_string_literal
# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import string [as 别名]
def gen_string_literal(string):
label = Constants.string(string)
rd = Registers.allocate(1)[0]
builder.inst_la(rd, label)
return rd