Mercurial > repos > tabletprog
annotate modules/string.tp @ 108:5099c1a96e3f
Mostly fix clicking on the function name in a funcall expression
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 13 Apr 2013 15:54:53 -0700 |
parents | 474f17ebaaa0 |
children | 4c96a393103e |
rev | line source |
---|---|
88
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #{ |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 llProperty: len withType: uint32_t |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 llProperty: bytes withType: uint32_t |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 llProperty: data withType: (char ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 llMessage: length withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 intret <- (obj_int32 ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 } andCode: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 intret num!: len |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 intret |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 llMessage: byte_length withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 intret <- (obj_int32 ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 } andCode: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 intret num!: bytes |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 intret |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 llMessage: EQ_ withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 argb <- (string ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 } andCode: :argb { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 if: len = (argb len) && bytes = (argb bytes) && (not: (memcmp: data (argb data) bytes)) { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 true |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 llMessage: NEQ_ withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 argb <- (string ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 } andCode: :argb { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 if: len != (argb len) || bytes != (argb bytes) || (memcmp: data (argb data) bytes) { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 true |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 llMessage: print withVars: {} andCode: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 fwrite: data 1 bytes stdout |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 self |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 llMessage: string withVars: {} andCode: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 self |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 llMessage: CAT_ withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 argbo <- (object ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 argb <- (string ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 out <- (string ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 } andCode: :argbo { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 argb <- mcall: string 1 argbo |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 out <- make_object: (addr_of: string_meta) NULL 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 out bytes!: bytes + (argb bytes) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 out len!: len + (argb len) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 out data!: (GC_MALLOC_ATOMIC: (out bytes) + 1) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 memcpy: (out data) data bytes |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 memcpy: (out data) + bytes (argb data) (argb bytes) + 1 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 out |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 llMessage: byte withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 index <- (obj_int32 ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 intret <- (obj_int32 ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 } andCode: :index { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 intret num!: (if: (index num) < bytes { data get: (index num) } else: {0}) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 intret |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 llMessage: int32 withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 intret <- (obj_int32 ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 } andCode: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 intret num!: (atoi: data) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 intret |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 llMessage: hash withVars: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 intret <- (obj_int32 ptr) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 i <- uint32_t |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 } andCode: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 intret <- make_object: (addr_of: obj_int32_meta) NULL 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 intret num!: 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 if: bytes { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 intret num!: (data get: 0) * 128 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 i <- 0 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 while: { i < bytes } do: { |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 intret num!: (1000003 * (intret num)) xor (data get: i) |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 i <- i + 1 |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 intret num!: (intret num) xor bytes |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 intret |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 } |
474f17ebaaa0
Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 } |