Ejemplo n.º 1
0
 def __init__(self, desc):
     self.contents = util.cdict(Attribute)
     self.desc = desc
Ejemplo n.º 2
0
                    bs.code += end
                    pos += 8
                else:
                    assert False, type
            assert bs.flow.stack.pop() is self
            bs.code += isa.mov(registers.rbx, ctypes.cast(self.func, ctypes.c_void_p).value)
            bs.code += isa.mov(registers.r12, registers.rsp)
            bs.code += isa.and_(registers.rsp, -16)
            bs.code += isa.mov(registers.rax, floats)
            bs.code += isa.call(registers.rbx)
            bs.code += isa.mov(registers.rsp, registers.r12)
            bs.code += isa.add(registers.rsp, pos)
            bs.code += isa.push(registers.rax)
            bs.flow.stack.append(type_impl.Int)
        return _
FuncPtrs = util.cdict(_FuncPtr)

class _CDLLInst(type_impl._Type):
    size = 0
    def __init__(self, name):
        type_impl._Type.__init__(self)
        self.cdll = ctypes.CDLL(name)
    def const_getattr(self, s):
        def _(bs):
            assert bs.flow.stack.pop() is self
            bs.flow.stack.append(FuncPtrs[self.cdll, s])
        return _
CDLLInsts = util.cdict(_CDLLInst)

@apply
class CDLL(type_impl._Type):
Ejemplo n.º 3
0
            bs.code += isa.and_(registers.rsp, -16)
            bs.code += isa.call(registers.rax)
            bs.code += isa.mov(registers.rsp, registers.r12)
            bs.code += skip
            
            #if type is not content.value.value: content.value.set(type)
            # i'm pretty sure we can do this - this code will immediately be executed after and this fits in with code generation
            # BUT things that use it before it have to be altered properly
            # right now they will just raise an error - render_code hasn't been defined
            # it should ignore this and wait for the asm code above to modify it.
            
            #print "storing", attr, self.desc, type, a, repr(content.container.raw)
            if type.size:
                bs.code += isa.mov(registers.rax, ctypes.cast(content.container, ctypes.c_void_p).value)
                for i in reversed(xrange(type.size)):
                    bs.code += isa.pop(MemRef(registers.rax, 8 * i))
        return _
    
    def del_name(self, attr):
        bs.flow.stack.append(Unset)
        bs.flow.this.append(self.set_name(attr))

class UpperDictType(_Type):
    size = 0
    def __init__(self, dict):
        _Type.__init__(self)
        assert isinstance(dict, UpperDict)
        self.dict = dict

upperdicttypes = util.cdict(UpperDictType)
Ejemplo n.º 4
0
            assert bs.flow.stack.pop() is self
            bs.code += isa.mov(registers.rbx,
                               ctypes.cast(self.func, ctypes.c_void_p).value)
            bs.code += isa.mov(registers.r12, registers.rsp)
            bs.code += isa.and_(registers.rsp, -16)
            bs.code += isa.mov(registers.rax, floats)
            bs.code += isa.call(registers.rbx)
            bs.code += isa.mov(registers.rsp, registers.r12)
            bs.code += isa.add(registers.rsp, pos)
            bs.code += isa.push(registers.rax)
            bs.flow.stack.append(type_impl.Int)

        return _


FuncPtrs = util.cdict(_FuncPtr)


class _CDLLInst(type_impl._Type):
    size = 0

    def __init__(self, name):
        type_impl._Type.__init__(self)
        self.cdll = ctypes.CDLL(name)

    def const_getattr(self, s):
        def _(bs):
            assert bs.flow.stack.pop() is self
            bs.flow.stack.append(FuncPtrs[self.cdll, s])

        return _