コード例 #1
0
ファイル: code.py プロジェクト: cshintov/py_vm
    def acq_names(self):
        """ constructs co_names of the code object """
        global name_cnt
        cur = self.cur
        pyclist = self.pyclist
        n_names = utl.decimal(pyclist, cur)
        func_idx = 0
        cur += 5
        co_names = {}
        idx = 0
        for dummy in range(n_names):
            # first occurrence of a name
            if (pyclist[cur] == opc.TYPE_INTERN):
                names[name_cnt] = [0]
                co_names[idx] = names[name_cnt]
                name_cnt += 1
                idx += 1
                cur = utl.skip_element(pyclist, cur)
            elif (pyclist[cur] == opc.TYPE_SREF):
                func_idx = utl.decimal(pyclist, cur)
                co_names[idx] = names[func_idx]
                idx += 1
                cur += 5
            else:
                cur += 1

        self.cur = cur
        return co_names
コード例 #2
0
ファイル: code.py プロジェクト: cshintov/py_vm
    def acq_name(self):
        """ constructs name of the code object """
        global name_cnt
        cur = self.cur
        pyclist = self.pyclist
        n_field = 0
        # skip 2 (:28 s that is cellvars and freevars
        while True:
            if pyclist[cur] == opc.TYPE_TUPLE:
                n_field += 1
            if n_field == 2:
                break
            cur += 1

        cur += 5
        # skip filenmae
        cur = utl.skip_element(pyclist, cur)
        self.cur = cur
        # getting the index of the name  of the code
        if pyclist[cur] == opc.TYPE_INTERN:
            names[name_cnt] = [0]
            name_cnt += 1
            return name_cnt - 1

        else:
            return utl.decimal(pyclist, cur, 4)
コード例 #3
0
ファイル: code.py プロジェクト: cshintov/py_vm
    def acq_consts(self):
        """ constructs co_consts of the code object """
        cur = self.cur
        pyclist = self.pyclist
        num_co = utl.decimal(pyclist, cur, 4)
        cur += 5
        consts = []
        for dummy in range(num_co):
            if pyclist[cur] == opc.TYPE_INTEGER:
                consts.append(utl.decimal(pyclist, cur, 4))
                cur += 5
            elif pyclist[cur] == opc.TYPE_NONE:
                consts.append(0)
                cur += 1
            elif pyclist[cur] == opc.TYPE_CODE:
                code_obj = Code(pyclist, cur)
                f_idx = code_obj.get_name()
                consts.append(code_obj)
                names[f_idx][0] = code_obj
                cur = utl.end_of_code(pyclist, cur)

        self.cur = cur
        return consts
コード例 #4
0
ファイル: code.py プロジェクト: cshintov/py_vm
    def acq_code(self):
        """ constructs co_code field of the code object """
        pyclist = self.pyclist
        cur = utl.start_of_code(pyclist, self.cur)
        end = cur + utl.decimal(pyclist, cur - 5, 4)
        code = []
        while cur < end:
            if not utl.is_func_def(cur, pyclist):
                if utl.have_arg(pyclist[cur]):
                    code.extend(pyclist[cur:cur + 3])
                    cur += 3
                else:
                    code.append(pyclist[cur])
                    cur += 1
            else:
                code.append(opc.MAKE_FUNCTION)
                code.extend([0] * 8)
                cur += 9

        self.cur = cur
        return code
コード例 #5
0
ファイル: code.py プロジェクト: cshintov/py_vm
    def acq_varnames(self):
        """ constructs co_varnames of the code object """
        global name_cnt
        cur = self.cur
        pyclist = self.pyclist
        varnames = []
        n_varnames = utl.decimal(pyclist, cur, 4)
        cur += 5
        for dummy in range(n_varnames):
            varnames.append(0)
            if pyclist[cur] == opc.TYPE_INTERN:
                names[name_cnt] = [0]
                name_cnt += 1
                cur = utl.skip_element(pyclist, cur)
            elif pyclist[cur] == opc.TYPE_SREF:
                cur += 5
            else:
                cur += 1

        self.cur = cur
        return varnames
コード例 #6
0
ファイル: main.py プロジェクト: fortebit/Polaris_Zerynth
            else:
                # sleep as indicated by rate
                if now_time - last_time < gps_period - poll_time:
                    continue

        ts = modem.rtc()
        #print("MODEM RTC =", ts)

        if counter % (update_period / gps_period) == 0 or extra_send:
            telemetry['ignition'] = ignition
            telemetry['sos'] = sos

            if polaris.isBatteryBackup():
                telemetry['charger'] = -1
            else:
                telemetry['battery'] = utils.decimal(3, polaris.readMainVoltage())
                telemetry['charger'] = polaris.getChargerStatus()

            telemetry['backup'] = utils.decimal(3, polaris.readBattVoltage())
            telemetry['temperature'] = utils.decimal(2, accel.get_temperature())
            telemetry['sigma'] = utils.decimal(3, accel.get_sigma())

            pr = accel.get_pitchroll()
            telemetry['pitch'] = utils.decimal(1, pr[0])
            telemetry['roll'] = utils.decimal(1, pr[1])

        if gnss.has_fix():
            fix = gnss.fix()
            # only transmit position when it's accurate
            if fix[6] < 2.5:
                telemetry['latitude'] = utils.decimal(6, fix[0])
コード例 #7
0
ファイル: code.py プロジェクト: cshintov/py_vm
 def get_oparg(self, cur):
     """ returns the oparg of the opcode at cur """
     return utl.decimal(self.code, cur)