Exemple #1
0
    def straightsort(self, r):
        DRIVER.simulate_function_call('straightsort', 5, sys._getframe())
        r.frame = sys._getframe()
        result = None

        n = Integer()
        n.declare()
        i = Indexpointer()
        i.declare()
        DRIVER.simulate_statement(9, sys._getframe())
        DRIVER.simulate_statement(10, sys._getframe())
        n.assign(pascal.high(r))
        DRIVER.simulate_statement(11, sys._getframe())
        i.assign(Pointer(r))
        i.assign(Integer(2) - Integer(1))
        _for_end = n
        while True:
            DRIVER.simulate_statement(12, sys._getframe())
            i.assign(i + Integer(1))
            if i > _for_end: break
            DRIVER.simulate_statement(13, sys._getframe())
            _straipass = self.straipass(r, i)
            DRIVER.simulate_function_return()
            DRIVER.simulate_statement(13, sys._getframe())
            _straipass
        DRIVER.simulate_statement(14, sys._getframe())

        r.frame = sys._getframe(1)

        n.destroy()
        i.destroy()

        return result
Exemple #2
0
    def move(self, x, n, y):
        Driver.simulate_function_call("move", 15, locals())

        i = Integer(3)

        Driver.simulate_statement(16)

        Driver.simulate_statement(17)

        i.assign(Integer(5))
        Driver.simulate_statement(18)
Exemple #3
0
    def mergesort(self, r, r1, s, t):
        DRIVER.simulate_function_call('mergesort', 8, sys._getframe())
        r.frame = sys._getframe()
        r1.frame = sys._getframe()
        s = s.clone()
        s.declare()
        t = t.clone()
        t.declare()
        result = None

        r2 = Queue()
        r2.declare()
        m = Integer()
        m.declare()
        DRIVER.simulate_statement(12, sys._getframe())
        DRIVER.simulate_statement(13, sys._getframe())
        pascal.setlength(r2, t + Integer(1))
        DRIVER.simulate_statement(14, sys._getframe())
        if s == t:
            DRIVER.simulate_statement(15, sys._getframe())
            r1[s].assign(r[s])
        else:
            DRIVER.simulate_statement(17, sys._getframe())
            m.assign(pascal.trunc((s + t) / Integer(2)))
            DRIVER.simulate_statement(18, sys._getframe())
            _mergesort = self.mergesort(r, r2, s, m)
            DRIVER.simulate_function_return()
            DRIVER.simulate_statement(18, sys._getframe())
            _mergesort
            DRIVER.simulate_statement(19, sys._getframe())
            _mergesort = self.mergesort(r, r2, m + Integer(1), t)
            DRIVER.simulate_function_return()
            DRIVER.simulate_statement(19, sys._getframe())
            _mergesort
            DRIVER.simulate_statement(20, sys._getframe())
            _merge = self.merge(r2, s, m, t, r1)
            DRIVER.simulate_function_return()
            DRIVER.simulate_statement(20, sys._getframe())
            _merge
        DRIVER.simulate_statement(22, sys._getframe())
        pascal.dispose(r2)
        DRIVER.simulate_statement(23, sys._getframe())

        r.frame = sys._getframe(1)
        r1.frame = sys._getframe(1)
        s.destroy()
        t.destroy()

        r2.destroy()
        m.destroy()

        return result
Exemple #4
0
    def move(self, x, n, y):
        Driver.simulate_function_call("move", 15, locals())

        i = Integer(3)
        Driver.simulate_declare_var(i.name, i)

        Driver.simulate_statement(16)

        Driver.simulate_statement(17)
        # print x, " ", n, " ", y
        _name = "plate_%s" % (Paras['n'] - n + Integer(1))
        Driver.simulateVisionMove(str(_name), str(x), str(y))

        i.assign(Integer(5))
        Driver.simulate_statement(18)
Exemple #5
0
    def qkpass(self, r, s, t, i):
        DRIVER.simulate_function_call('qkpass', 21, sys._getframe())
        r.frame = sys._getframe()
        s = s.clone()
        s.declare()
        t = t.clone()
        t.declare()
        i.frame = sys._getframe()
        result = None

        j = Integer()
        j.declare()
        x = Integer()
        x.declare()
        rp = Integer()
        rp.declare()
        DRIVER.simulate_statement(26, sys._getframe())
        DRIVER.simulate_statement(27, sys._getframe())
        i.assign(s)
        DRIVER.simulate_statement(28, sys._getframe())
        j.assign(t)
        DRIVER.simulate_statement(29, sys._getframe())
        rp.assign(r[s])
        DRIVER.simulate_statement(30, sys._getframe())
        x.assign(r[s])
        DRIVER.simulate_statement(31, sys._getframe())
        while i < j:
            DRIVER.simulate_statement(33, sys._getframe())
            while i < j and r[j] >= x:
                DRIVER.simulate_statement(34, sys._getframe())
                j.assign(j - Integer(1))
            DRIVER.simulate_statement(35, sys._getframe())
            r[i].assign(r[j])
            DRIVER.simulate_statement(36, sys._getframe())
            while i < j and r[i] <= x:
                DRIVER.simulate_statement(37, sys._getframe())
                i.assign(i + Integer(1))
            DRIVER.simulate_statement(38, sys._getframe())
            r[j].assign(r[i])
        DRIVER.simulate_statement(40, sys._getframe())
        r[i].assign(rp)
        DRIVER.simulate_statement(41, sys._getframe())

        r.frame = sys._getframe(1)
        s.destroy()
        t.destroy()
        i.frame = sys._getframe(1)

        j.destroy()
        x.destroy()
        rp.destroy()

        return result
Exemple #6
0
    def move(self, x1, x2):
        x1 = x1.clone()
        x2 = x2.clone()
        Driver.simulate_function_call('move', 17, locals())
        Result = None

        v0 = Integer()
        Driver.simulate_declare_var(v0)
        v1 = Char()
        Driver.simulate_declare_var(v1)
        v1 = Char()
        Driver.simulate_declare_var(v1)
        v1 = Char()
        Driver.simulate_declare_var(v1)
        v4 = Integer()
        Driver.simulate_declare_var(v4)
        Driver.simulate_statement(22)
        Driver.simulate_statement(23)
        v0.assign(Integer(1))
        v0.assign(Integer(1) - Integer(1))
        _for_end = Integer(100)
        while True:
            Driver.simulate_statement(24)
            v0.assign(v0 + Integer(1))
            if v0 > _for_end: break
            Driver.simulate_statement(26)
            v1.assign(xxx)
        Driver.simulate_statement(30)
        v2.assign(yyy)
        Driver.simulate_statement(29)
        while True:
            Driver.simulate_statement(31)
            if v2 == Integer(0): break
Exemple #7
0
    def straipass(self, r, i):
        DRIVER.simulate_function_call('straipass', 16, sys._getframe())
        r.frame = sys._getframe()
        i = i.clone()
        i.declare()
        result = None

        x = Integer()
        x.declare()
        j = Indexpointer()
        j.declare()
        DRIVER.simulate_statement(20, sys._getframe())
        DRIVER.simulate_statement(21, sys._getframe())
        j.assign(Pointer(r))
        DRIVER.simulate_statement(22, sys._getframe())
        r[Integer(0)].assign(r[i])
        DRIVER.simulate_statement(23, sys._getframe())
        j.assign(i - Integer(1))
        DRIVER.simulate_statement(24, sys._getframe())
        x.assign(r[i])
        DRIVER.simulate_statement(25, sys._getframe())
        while x < r[j]:
            DRIVER.simulate_statement(27, sys._getframe())
            r[j + Integer(1)].assign(r[j])
            DRIVER.simulate_statement(28, sys._getframe())
            j.assign(j - Integer(1))
        DRIVER.simulate_statement(30, sys._getframe())
        r[j + Integer(1)].assign(r[Integer(0)])
        DRIVER.simulate_statement(31, sys._getframe())

        r.frame = sys._getframe(1)
        i.destroy()

        x.destroy()
        j.destroy()

        return result
Exemple #8
0
    def merge(self, rs, s, m, n, rn):
        DRIVER.simulate_function_call('merge', 25, sys._getframe())
        rs = rs.clone()
        rs.declare()
        s = s.clone()
        s.declare()
        m = m.clone()
        m.declare()
        n = n.clone()
        n.declare()
        rn.frame = sys._getframe()
        result = None

        i = Indexpointer()
        i.declare()
        j = Indexpointer()
        j.declare()
        k = Indexpointer()
        k.declare()
        ki = Integer()
        ki.declare()
        DRIVER.simulate_statement(29, sys._getframe())
        DRIVER.simulate_statement(30, sys._getframe())
        i.assign(Pointer(rs))
        DRIVER.simulate_statement(30, sys._getframe())
        j.assign(Pointer(rs))
        DRIVER.simulate_statement(30, sys._getframe())
        k.assign(Pointer(rs))
        DRIVER.simulate_statement(31, sys._getframe())
        i.assign(s)
        DRIVER.simulate_statement(31, sys._getframe())
        j.assign(m + Integer(1))
        DRIVER.simulate_statement(31, sys._getframe())
        k.assign(s - Integer(1))
        DRIVER.simulate_statement(32, sys._getframe())
        while (i <= m) and (j <= n):
            DRIVER.simulate_statement(34, sys._getframe())
            k.assign(k + Integer(1))
            DRIVER.simulate_statement(35, sys._getframe())
            if rs[i] <= rs[j]:
                DRIVER.simulate_statement(37, sys._getframe())
                rn[k].assign(rs[i])
                DRIVER.simulate_statement(38, sys._getframe())
                i.assign(i + Integer(1))
            else:
                DRIVER.simulate_statement(42, sys._getframe())
                rn[k].assign(rs[j])
                DRIVER.simulate_statement(43, sys._getframe())
                j.assign(j + Integer(1))
        DRIVER.simulate_statement(46, sys._getframe())
        if i <= m:
            ki.assign(k + Integer(1) - Integer(1))
            _for_end = n
            while True:
                DRIVER.simulate_statement(47, sys._getframe())
                ki.assign(ki + Integer(1))
                if ki > _for_end: break
                DRIVER.simulate_statement(48, sys._getframe())
                rn[ki].assign(rs[i + ki - k - Integer(1)])
        DRIVER.simulate_statement(49, sys._getframe())
        if j <= n:
            ki.assign(k + Integer(1) - Integer(1))
            _for_end = n
            while True:
                DRIVER.simulate_statement(50, sys._getframe())
                ki.assign(ki + Integer(1))
                if ki > _for_end: break
                DRIVER.simulate_statement(51, sys._getframe())
                rn[ki].assign(rs[j + ki - k - Integer(1)])
        DRIVER.simulate_statement(52, sys._getframe())

        rs.destroy()
        s.destroy()
        m.destroy()
        n.destroy()
        rn.frame = sys._getframe(1)

        i.destroy()
        j.destroy()
        k.destroy()
        ki.destroy()

        return result
Exemple #9
0
    def merge(self, rs, s, m, n, rn):
        rs.clone()
        s.clone()
        m.clone()
        n.clone()
        Driver.simulate_function_call('merge', 17, locals())
        Result = None

        i = Integer()
        Driver.simulate_declare_var(i)
        j = Integer()
        Driver.simulate_declare_var(j)
        k = Integer()
        Driver.simulate_declare_var(k)
        ki = Integer()
        Driver.simulate_declare_var(ki)
        Driver.simulate_statement(23)
        i.show()
        j.show()
        k.show()
        Driver.simulate_statement(25)
        i.assign(s)
        Driver.simulate_statement(25)
        j.assign(m + Integer(1))
        Driver.simulate_statement(25)
        k.assign(s - Integer(1))
        Driver.simulate_statement(1)
        while (i <= m) and (j <= n):
            Driver.simulate_statement(28)
            k.assign(k + Integer(1))
            Driver.simulate_statement(29)
            if rs[i] <= rs[j]:
                Driver.simulate_statement(31)
                rn[k].assign(rs[i])
                Driver.simulate_statement(32)
                i.assign(i + Integer(1))
            else:
                Driver.simulate_statement(36)
                rn[k].assign(rs[j])
                Driver.simulate_statement(37)
                j.assign(j + Integer(1))
            Driver.simulate_statement(39)
            if i <= m:
                ki = k + Integer(1) - Integer(1)
                _for_end = n
                while True:
                    Driver.simulate_statement(40)
                    ki = ki + Integer(1)
                    if ki > _for_end: break
                    Driver.simulate_statement(41)
                    rn[ki].assign(rs[i + ki - k - Integer(1)])
            Driver.simulate_statement(43)
            if j <= n:
                ki = k + Integer(1) - Integer(1)
                _for_end = n
                while True:
                    Driver.simulate_statement(44)
                    ki = ki + Integer(1)
                    if ki > _for_end: break
                    Driver.simulate_statement(45)
                    rn[ki].assign(rs[j + ki - k - Integer(2)])
        i.hide()
        j.hide()
        k.hide()
        Driver.simulate_statement(48)

        return Result