annotate modules/string.tp @ 259:32964a4e7a33

Add ltrim method to string
author Michael Pavone <pavone@retrodev.com>
date Thu, 29 May 2014 18:51:15 -0700
parents 5b830147c1cd
children d6a4c9e7716e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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)
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
5
88
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 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
13
88
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 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
21
88
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 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
29
243
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
30 llMessage: compareSub withVars: {
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
31 argb <- string ptr
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
32 myoff <- obj_int32 ptr
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
33 boff <- obj_int32 ptr
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
34 clen <- obj_int32 ptr
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
35 intret <- obj_int32 ptr
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
36 } andCode: :argb myoff boff clen {
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
37 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
38 intret num!: (memcmp: data + (myoff num) (argb data) + (boff num) (clen num))
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
39 intret
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
40 }
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
41
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 llMessage: NEQ_ withVars: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 argb <- (string ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 } andCode: :argb {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 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
46 true
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 }
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
49
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 llMessage: print withVars: {} andCode: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 fwrite: data 1 bytes stdout
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 self
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
54
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 llMessage: string withVars: {} andCode: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 self
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
58
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 llMessage: CAT_ withVars: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 argbo <- (object ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 argb <- (string ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62 out <- (string ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 } andCode: :argbo {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 argb <- mcall: string 1 argbo
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 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
66 out bytes!: bytes + (argb bytes)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 out len!: len + (argb len)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68 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
69 memcpy: (out data) data bytes
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 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
71 out
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
73
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74 llMessage: byte withVars: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75 index <- (obj_int32 ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76 intret <- (obj_int32 ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 } andCode: :index {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78 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
79 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
80 intret
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
82
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
83 llMessage: int32 withVars: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
84 intret <- (obj_int32 ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
85 } andCode: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
86 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
87 intret num!: (atoi: data)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88 intret
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
89 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
90
158
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
91 parseHex32 <- {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
92 num <- 0u32
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
93 cur <- 0
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
94 a <- uint32: ("a" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
95 A <- uint32: ("A" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
96 f <- uint32: ("f" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
97 F <- uint32: ("F" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
98 zero <- "0" byte: 0
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
99 nine <- "9" byte: 0
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
100 while: { cur < byte_length} do: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
101 b <- uint32: (byte: cur)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
102 cur <- cur + 1
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
103 if: b >= zero && b <= nine {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
104 num <- num * 16 + (b - zero)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
105 } else: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
106 if: b >= a && b <= f {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
107 num <- num * 16 + (b - a) + 10u32
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
108 } else: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
109 if: b >= A && b <= F {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
110 num <- num * 16 + (b - A) + 10u32
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
111 } else: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
112 cur <- byte_length
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
113 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
114 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
115 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
116 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
117 num
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
118 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
119
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
120 parseHex64 <- {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
121 num <- 0u64
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
122 cur <- 0
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
123 a <- uint64: ("a" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
124 A <- uint64: ("A" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
125 f <- uint64: ("f" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
126 F <- uint64: ("F" byte: 0)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
127 zero <- "0" byte: 0
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
128 nine <- "9" byte: 0
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
129 while: { cur < byte_length} do: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
130 b <- uint64: (byte: cur)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
131 cur <- cur + 1
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
132 if: b >= zero && b <= nine {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
133 num <- num * 16 + (b - zero)
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
134 } else: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
135 if: b >= a && b <= f {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
136 num <- num * 16 + (b - a) + 10u64
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
137 } else: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
138 if: b >= A && b <= F {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
139 num <- num * 16 + (b - A) + 10u64
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
140 } else: {
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
141 cur <- byte_length
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
142 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
143 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
144 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
145 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
146 num
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
147 }
38140b7dbe3d Add parseHex32 and parseHex64 to string objects
Mike Pavone <pavone@retrodev.com>
parents: 157
diff changeset
148
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
149 llMessage: hash withVars: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
150 intret <- (obj_int32 ptr)
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
151 i <- uint32_t
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
152 } andCode: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
153 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
154 intret num!: 0
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
155 if: bytes {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
156 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
157 i <- 0
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
158 while: { i < bytes } do: {
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
159 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
160 i <- i + 1
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
161 }
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
162 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
163 }
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
164 intret
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
165 }
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
166
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
167 llMessage: find:startingAt:else withVars: {
150
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
168 intret <- obj_int32 ptr
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
169 oneedle <- object ptr
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
170 startpos <- obj_int32 ptr
150
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
171 ifNotFound <- object ptr
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
172 sneedle <- string ptr
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
173 i <- uint32_t
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
174 notFound <- uint32_t
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
175 } andCode: :oneedle :startpos :ifNotFound {
150
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
176 sneedle <- mcall: string 1 oneedle
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
177 i <- startpos num
150
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
178 notFound <- 1
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
179 while: { notFound && i + (sneedle bytes) <= bytes} do: {
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
180 if: (memcmp: data + i (sneedle data) (sneedle bytes)) = 0 {
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
181 notFound <- 0
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
182 } else: {
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
183 i <- i + 1
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
184 }
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
185 }
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
186 if: notFound {
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
187 ccall: ifNotFound 0
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
188 } else: {
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
189 intret <- make_object: (addr_of: obj_int32_meta) NULL 0
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
190 intret num!: i
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
191 intret
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
192 }
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
193 }
7dfa4481deb0 Implement find:else on string objects
Mike Pavone <pavone@retrodev.com>
parents: 147
diff changeset
194
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
195 find:else <- :toFind :orElse {
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
196 find: toFind startingAt: 0 else: orElse
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
197 }
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
198
151
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
199 llMessage: from:withLength withVars: {
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
200 from <- obj_int32 ptr
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
201 tocopy <- obj_int32 ptr
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
202 ret <- string ptr
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
203 start <- int32_t
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
204 clampedLen <- int32_t
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
205 } andCode: :from :tocopy {
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
206 start <- from num
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
207 if: start < 0 {
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
208 start <- bytes + start
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
209 }
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
210 if: start > bytes {
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
211 start <- bytes
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
212 }
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
213 clampedLen <- tocopy num
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
214 if: start + clampedLen > bytes {
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
215 clampedLen <- bytes - start
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
216 }
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
217 ret <- make_object: (addr_of: string_meta) NULL 0
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
218 ret data!: (GC_MALLOC_ATOMIC: clampedLen + 1)
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
219 memcpy: (ret data) data + start clampedLen
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
220 ret len!: clampedLen
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
221 ret bytes!: clampedLen
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
222 ret
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
223 }
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
224
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
225 from <- :start {
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
226 from: start withLength: length
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
227 }
3e9cb69e516d Added from and from:withLength for doing substring operations
Mike Pavone <pavone@retrodev.com>
parents: 150
diff changeset
228
152
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
229 partitionOn <- :delim {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
230 pos <- find: delim else: { -1 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
231 if: pos >= 0 {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
232 _before <- from: 0 withLength: pos
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
233 _after <- from: (pos + (delim length))
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
234 #{
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
235 before <- _before
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
236 after <- _after
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
237 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
238 } else: {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
239 _before <- self
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
240 #{
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
241 before <- _before
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
242 after <- ""
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
243 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
244 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
245 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
246
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
247 splitOn <- :delim {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
248 pos <- 0
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
249 pieces <- #[]
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
250 while: {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
251 pos <- find: delim else: { -1 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
252 pos >= 0
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
253 } do: {
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
254 pieces append: (from: 0 withLength: pos)
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
255 self <- from: pos + (delim length)
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
256 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
257 pieces append: self
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
258 }
a6739206a9e3 Add splitOn and partitionOn to string objects
Mike Pavone <pavone@retrodev.com>
parents: 151
diff changeset
259
259
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
260 ltrim <- {
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
261 l <- length
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
262 start <- 0
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
263 space <- " " byte: 0
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
264 tab <- "\t" byte: 0
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
265 nl <- "\n" byte: 0
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
266 cr <- "\r" byte: 0
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
267
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
268 while: {
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
269 if: start < l {
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
270 b <- byte: start
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
271 b = space || b = tab || b = nl || b = cr
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
272 }
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
273 } do: {
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
274 start <- start + 1
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
275 }
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
276 from: start
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
277 }
32964a4e7a33 Add ltrim method to string
Michael Pavone <pavone@retrodev.com>
parents: 243
diff changeset
278
157
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
279 trim <- {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
280 l <- length
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
281 start <- 0
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
282 space <- " " byte: 0
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
283 tab <- "\t" byte: 0
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
284 nl <- "\n" byte: 0
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
285 cr <- "\r" byte: 0
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
286
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
287 while: {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
288 if: start < l {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
289 b <- byte: start
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
290 b = space || b = tab || b = nl || b = cr
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
291 }
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
292 } do: {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
293 start <- start + 1
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
294 }
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
295 end <- l
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
296 while: {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
297 if: end > 0 {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
298 b <- byte: end
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
299 b = space || b = tab || b = nl || b = cr
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
300 }
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
301 } do: {
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
302 end <- end + 1
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
303 }
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
304 from: start withLength: (end - start)
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
305 }
55e0dca7d3d7 Partial implementation of HTTP get requests
Mike Pavone <pavone@retrodev.com>
parents: 154
diff changeset
306
147
4c96a393103e Add support for receiving data from a socket
Mike Pavone <pavone@retrodev.com>
parents: 88
diff changeset
307 isInteger? <- { false }
154
6e579a75a0a9 Add JSON parser and sample
Mike Pavone <pavone@retrodev.com>
parents: 152
diff changeset
308 isString? <- { true }
243
5b830147c1cd Use a lightweight substring object in a few places in the parser to improve performance for large files.
Mike Pavone <pavone@retrodev.com>
parents: 158
diff changeset
309 isBasicString? <- { true }
88
474f17ebaaa0 Add string.tp which should have been in previous commit
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
310 }