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


Python Constants.integer方法代码示例

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


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

示例1: gen_literal

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import integer [as 别名]
def gen_literal(ast):
    assert ast[0] == 'Literal'
    if type(ast[1]) == int:
        label = Constants.integer(ast[1])
        rd = Registers.allocate(1)[0]
        builder.inst_la(rd, label)
        return rd
    elif type(ast[1]) == str:
        return gen_string_literal(ast[1])
    elif type(ast[1]) == bool:
        label = Constants.integer(1 if ast[1] else 0)
        rd = Registers.allocate(1)[0]
        builder.inst_la(rd, label)
        return rd
开发者ID:SundongCandy,项目名称:lift-js,代码行数:16,代码来源:Generator.py

示例2: gen_function_expression

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import integer [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
开发者ID:SundongCandy,项目名称:lift-js,代码行数:35,代码来源:Generator.py

示例3: call_func

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import integer [as 别名]
 def call_func(self, func, this, args):
     fp = Registers.fp()
     sp = Registers.sp()
     temp, zero = Registers.allocate(2)
     self.inst_newobj(temp)
     self.inst_la(zero, Constants.integer(0))
     self.inst_add(temp, fp, zero)
     self.push(temp)  # push fp
     Registers.free([temp, zero])
     self.inst_move(fp, sp)
     self.push(0)  # dummy push for return address
     self.push(func)
     self.push(this)
     self.push(0)  # dummy push for return value
     for arg in args:
         self.push(arg)
     self.inst_jalr(func)
开发者ID:SundongCandy,项目名称:lift-js,代码行数:19,代码来源:Builder.py

示例4: pop

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import integer [as 别名]
 def pop(self, rd):
     sp = Registers.sp()
     self.inst_la(rd, Constants.integer(4))  # reuse rd so as not to introduce new register
     self.inst_add(sp, sp, rd)
     self.inst_ld(rd, sp, 0)
开发者ID:SundongCandy,项目名称:lift-js,代码行数:7,代码来源:Builder.py

示例5: gen_assignment_expression_no_in

# 需要导入模块: import Constants [as 别名]
# 或者: from Constants import integer [as 别名]
def gen_assignment_expression_no_in(ast):
    assert ast[0] == 'AssignmentExpressionNoIn'
    if len(ast) == 2:
        if ast[1][0] == 'LeftHandSideExpression':
            return gen_left_hand_side_expression(ast[1])
        elif ast[1][0] == 'CallExpression':
            return gen_call_expression(ast[1])
        elif ast[1][0] == 'MemberExpression':
            return gen_member_expression(ast[1])
    elif len(ast) == 3:
        if ast[1][0] == 'AssignmentExpressionNoIn':
            raise Exception('Postfix operator is not supported yet.')
            rs = gen_assignment_expression_no_in(ast[1])
            rt = Registers.allocate(1)[0]
            builder.inst_la(rt, Constants.integer(1))
            if ast[2] == '++':
                builder.inst_add(rs, rs, rt)
            elif ast[2] == '--':
                builder.inst_sub(rs, rs, rt)
            Registers.free([rt])
            return rs
        elif ast[1] == '++':
            rs = gen_assignment_expression_no_in(ast[2])
            rt = Registers.allocate(1)[0]
            builder.inst_la(rt, Constants.integer(1))
            builder.inst_add(rs, rs, rt)
            Registers.free([rt])
            return rs
        elif ast[1] == '--':
            rs = gen_assignment_expression_no_in(ast[2])
            rt = Registers.allocate(1)[0]
            builder.inst_la(rt, Constants.integer(1))
            builder.inst_sub(rs, rs, rt)
            Registers.free([rt])
            return rs
        elif ast[1] == 'typeof':
            rd = Registers.allocate(1)[0]
            rs = gen_assignment_expression_no_in(ast[2])
            builder.inst_newobj(rd)
            builder.inst_typeof(rd, rs)
            Registers.free([rs])
            return rd
        elif ast[1] == '+':
            return gen_assignment_expression_no_in(ast[2])
        elif ast[1] == '-':
            rs = gen_assignment_expression_no_in(ast[2])
            rd, rt = Registers.allocate(2)
            builder.inst_la(rt, Constants.integer(-1))
            builder.inst_mul(rd, rs, rt)
            Registers.free([rs, rt])
            return rd
        elif ast[1] == '~':
            rs = gen_assignment_expression_no_in(ast[2])
            builder.inst_not(rs, rs)
            return rs
        elif ast[1] == '!':
            rs = gen_assignment_expression_no_in(ast[2])
            t1 = Registers.allocate(1)[0]
            exit_label = Labels.temp()
            true_label = Labels.temp()
            builder.inst_newobj(t1)
            builder.inst_bnz(rs, true_label)
            builder.inst_la(t1, Constants.integer(1))
            builder.inst_j(exit_label)
            builder.insert_label(true_label)
            builder.insert_la(t1, Constants.integer(0))
            builder.insert_label(exit_label)
            return t1
    elif len(ast) == 4:
        if ast[2] in ['=', '*=', '/=', '%=', '+=', '-=', '<<=', '>>=', '>>>=', '&=',
                      '^=', '|=']:
            r1 = gen_left_hand_side_expression(ast[1])
        elif ast[2] in ['||', '&&', '|', '&', '^', '==', '!=', '===', '!==',
                        '<', '>', '<=', '>=', '<<', '>>', '>>>', '+', '-', '*',
                        '/']:
            r1 = gen_assignment_expression_no_in(ast[1])
        r2 = gen_assignment_expression_no_in(ast[3])
        if ast[2] == '+':
            rd = Registers.allocate(1)[0]
            builder.inst_newobj(rd)
            builder.inst_add(rd, r1, r2)
            Registers.free([r1, r2])
            return rd
        elif ast[2] == '-':
            rd = Registers.allocate(1)[0]
            builder.inst_newobj(rd)
            builder.inst_sub(rd, r1, r2)
            Registers.free([r1, r2])
            return rd
        elif ast[2] == '*':
            rd = Registers.allocate(1)[0]
            builder.inst_newobj(rd)
            builder.inst_mul(rd, r1, r2)
            Registers.free([r1, r2])
            return rd
        elif ast[2] == '/':
            rd = Registers.allocate(1)[0]
            builder.inst_newobj(rd)
            builder.inst_div(rd, r1, r2)
            Registers.free([r1, r2])
#.........这里部分代码省略.........
开发者ID:SundongCandy,项目名称:lift-js,代码行数:103,代码来源:Generator.py


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