示例#1
0
    def execute(self, vm):
        stack = vm.stack
        m = vm.current_method()
        if stack.get_frame_count() < 1:
            raise StackStateException('Not enough values on the stack')

        # handle referencetype case
        value = stack.pop()
        if self.targetName is None:
            variable = m.locals[self.index]
            if isinstance(value, ReferenceType):
                value.name = variable.name
                # fixme - set other properties?
                m.locals[self.index] = value
            else:
                m.locals[self.index].value = value.value
        else:
            for x in range(len(m.locals)):
                if m.locals[x].name == self.targetName:
                    if isinstance(value, ReferenceType):
                        value.name = variable.name
                        # fixme - set other properties?
                        m.locals[x] = value
                    else:
                        m.locals[x].value = value.value
示例#2
0
    def execute(self, vm):
        stack = vm.stack
        if stack.get_frame_count() < 2:
            raise StackStateException('Not enough values on the stack')

        rhs = stack.pop()
        lhs = stack.pop()
        stack.push(Variable(lhs.value * rhs.value))
示例#3
0
文件: ldlen.py 项目: memsom/PyCIL
    def execute(self, vm):
        stack = vm.stack
        m = vm.current_method()
        if stack.get_frame_count() < 1:
            raise StackStateException('Not enough values on the stack')

        array = vm.stack.pop()
        result = Variable(array.length)
        result.type = Types.UInt32
        vm.stack.push(result)
示例#4
0
文件: ldelem.py 项目: memsom/PyCIL
 def execute(self, vm):
     stack = vm.stack
     m = vm.current_method()
     if stack.get_frame_count() < 2:
         raise StackStateException('Not enough values on the stack')
     
     index = vm.stack.pop()
     array = vm.stack.pop()
     
     vm.stack.push(array.values[index.value])
示例#5
0
    def execute(self, vm):
        stack = vm.stack
        if stack.get_frame_count() < 2:
            raise StackStateException('Not enough values on the stack')

        v2 = stack.pop()
        v1 = stack.pop()
        if v1.value == v2.value:
            stack.push(Variable(1))
        else:
            stack.push(Variable(0))
示例#6
0
文件: conv.py 项目: memsom/PyCIL
    def execute(self, vm):
        stack = vm.stack
        if stack.get_frame_count() < 1:
            raise StackStateException('Not enough values on the stack')

        input = stack.pop()
        result = None
        if self.suffix == 'i4':
            result = self.convert_to_i4(input)
        else:
            raise Exception('Unimplemented conversion ' + self.suffix)
        
        stack.push(result)
示例#7
0
文件: ldfld.py 项目: memsom/PyCIL
 def execute(self, vm):
     stack = vm.stack
     m = vm.current_method()
     if stack.get_frame_count() < 1:
         raise StackStateException('Not enough values on the stack')
     
     object = vm.stack.pop()
     for fieldIndex in range(len(object.fieldNames)):
         fieldName = object.fieldNames[fieldIndex]
         if fieldName == self.fieldName:
             vm.stack.push(object.fields[fieldIndex])
             return
         
     raise Exception("Field " + self.fieldName + " not found!")
示例#8
0
    def execute(self, vm):
        stack = vm.stack
        if stack.get_frame_count() < 1:
            raise StackStateException('Not enough values on the stack')

        stack.pop()