History

Updated the use of Type objects. Added a simpler test.

David Boddie committed 9 years ago

Commit af6d52b1 parent 5b67b842 files · +71 −3Browse files

Unified · Split

2 files
  1. Tests/count.py +3 −3
  2. Tests/countmin.py +68 −0
Tests/count.py+3−3
@@ -61,14 +61,14 @@ if __name__ == "__main__": · 60 unmodified lines
6161 ]
6262
6363 d.types = [
64− dis.Type(0, 16, 1, "\xf0"),
65− dis.Type(1, 40, 2, "\x00\x80"),
64+ dis.Type(0, 16, "\xf0"),
65+ dis.Type(1, 40, "\x00\x80"),
6666 # Type 2 is the stack frame type for the init functon (see below) and
6767 # the entry type for the program (see above),
6868 # 56 bytes (14 words) in size:
6969 # pointer bitmap: 0 0 0 0 0 0 0 0 | 1 1 0 1 0 0 [0 0]
7070 # pointers at offsets 32, 36 and 44
71− dis.Type(2, 56, 2, "\x00\xd0")
71+ dis.Type(2, 56, "\x00\xd0")
7272 ]
7373
7474 d.data = {
Tests/countmin.py+68−0
@@ -0,0 +1,68 @@
1+#!/usr/bin/env python
2+
3+import sys
4+
5+import dis
6+import opcodes
7+from opcodes import Imm, LOfp, LOmp, NoOp, SOfp, SOmp, SOSOfp, SOSOmp
8+from utils import hash_signature
9+
10+if __name__ == "__main__":
11+
12+ if len(sys.argv) != 2:
13+ sys.stderr.write("Usage: %s <output file>\n" % sys.argv[0])
14+ sys.exit(1)
15+
16+ d = dis.Dis()
17+ d.runtime_flag = dis.RuntimeFlag(dis.RuntimeFlag.HASLDT)
18+ d.stack_extent = 560
19+ d.data_size = 8
20+ d.entry_pc = 0
21+ d.entry_type = 1
22+
23+ """
24+ implement count;
25+
26+ include "sys.m";
27+ include "draw.m";
28+
29+ count: module
30+ {
31+ init: fn(ctxt: ref Draw->Context, args: list of string);
32+ };
33+
34+ init(ctxt: ref Draw->Context, args: list of string)
35+ {
36+ sys := load Sys Sys->PATH;
37+ for (i := 0; i < 123; i++)
38+ ;
39+ }
40+ """
41+
42+ d.code = [
43+ opcodes.load(LOmp(0), Imm(0), LOfp(48)),
44+ opcodes.movw(Imm(0), LOfp(40)),
45+ opcodes.blew(Imm(123), SOfp(40), Imm(5)),
46+ opcodes.addw(Imm(1), NoOp(), LOfp(40)),
47+ opcodes.jmp(Imm(2)),
48+ opcodes.ret()
49+ ]
50+
51+ d.types = [
52+ dis.Type(0, 8, "\xc0"),
53+ dis.Type(1, 56, "\x00\xc8")
54+ ]
55+
56+ d.data = {
57+ 0: dis.Data(0, 0, 0x03, array = "$Sys"),
58+ }
59+
60+ d.module_name = "count"
61+ d.link = [dis.Link(0, 1, 0x4244b354, "init")]
62+ d.initialised_globals = 1
63+ d.ldt = []
64+ d.path = sys.argv[0]
65+
66+ d.write(open(sys.argv[1], "w"))
67+
68+ sys.exit()