buildscripts/squish

Thu, 04 Feb 2016 17:22:28 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 04 Feb 2016 17:22:28 +0000
changeset 76
fecc1af937be
parent 74
b3f2711684a7
child 86
3c64919a50f9
permissions
-rwxr-xr-x

main.lua: Add --skip-server-startup-log to discard server log output at startup

74
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env lua
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 package.preload['optlex']=(function(...)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local s=_G
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 local u=require"string"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 module"optlex"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local i=u.match
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 local e=u.sub
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 local r=u.find
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 local d=u.rep
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 local c
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 error=s.error
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 warn={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 local n,o,l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 local p={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 TK_KEYWORD=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 TK_NAME=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 TK_NUMBER=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 TK_STRING=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19 TK_LSTRING=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 TK_OP=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 TK_EOS=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 local y={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 TK_COMMENT=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 TK_LCOMMENT=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 TK_EOL=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 TK_SPACE=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 local h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 local function w(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 local t=n[e-1]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 if e<=1 or t=="TK_EOL"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 return true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 elseif t==""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 return w(e-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 return false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39 local function g(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 local t=n[e+1]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 if e>=#n or t=="TK_EOL"or t=="TK_EOS"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 return true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 elseif t==""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 return g(e+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 return false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 local function _(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 local t=#i(a,"^%-%-%[=*%[")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 local a=e(a,t+1,-(t-1))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 local e,t=1,0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 local o,n,i,a=r(a,"([\r\n])([\r\n]?)",e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 if not o then break end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 e=o+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 if#a>0 and i~=a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 e=e+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 return t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 local function v(s,h)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 local a=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 local t,e=n[s],n[h]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 if t=="TK_STRING"or t=="TK_LSTRING"or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 e=="TK_STRING"or e=="TK_LSTRING"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 return""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 elseif t=="TK_OP"or e=="TK_OP"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 if(t=="TK_OP"and(e=="TK_KEYWORD"or e=="TK_NAME"))or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 (e=="TK_OP"and(t=="TK_KEYWORD"or t=="TK_NAME"))then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 return""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 if t=="TK_OP"and e=="TK_OP"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 local t,e=o[s],o[h]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 if(a(t,"^%.%.?$")and a(e,"^%."))or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 (a(t,"^[~=<>]$")and e=="=")or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 (t=="["and(e=="["or e=="="))then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 return" "
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 return""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 local t=o[s]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 if e=="TK_OP"then t=o[h]end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
85 if a(t,"^%.%.?%.?$")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
86 return" "
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
87 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
88 return""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
89 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
90 return" "
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
91 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
92 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
93 local function b()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
94 local s,i,a={},{},{}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
95 local e=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
96 for t=1,#n do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
97 local n=n[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
98 if n~=""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
99 s[e],i[e],a[e]=n,o[t],l[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
100 e=e+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
101 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
102 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
103 n,o,l=s,i,a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
104 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
105 local function A(r)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
106 local t=o[r]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
107 local t=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
108 local n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
109 if i(t,"^0[xX]")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
110 local e=s.tostring(s.tonumber(t))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
111 if#e<=#t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
112 t=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
113 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
114 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
115 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
116 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
117 if i(t,"^%d+%.?0*$")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
118 t=i(t,"^(%d+)%.?0*$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
119 if t+0>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
120 t=i(t,"^0*([1-9]%d*)$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
121 local a=#i(t,"0*$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
122 local o=s.tostring(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
123 if a>#o+1 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
124 t=e(t,1,#t-a).."e"..o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
125 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
126 n=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
127 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
128 n="0"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
129 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
130 elseif not i(t,"[eE]")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
131 local a,t=i(t,"^(%d*)%.(%d+)$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
132 if a==""then a=0 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
133 if t+0==0 and a==0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
134 n="0"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
135 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
136 local o=#i(t,"0*$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
137 if o>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
138 t=e(t,1,#t-o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
139 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
140 if a+0>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
141 n=a.."."..t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
142 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
143 n="."..t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
144 local a=#i(t,"^0*")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
145 local a=#t-a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
146 local o=s.tostring(#t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
147 if a+2+#o<1+#t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
148 n=e(t,-a).."e-"..o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
149 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
150 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
151 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
152 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
153 local t,a=i(t,"^([^eE]+)[eE]([%+%-]?%d+)$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
154 a=s.tonumber(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
155 local h,o=i(t,"^(%d*)%.(%d*)$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
156 if h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
157 a=a-#o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
158 t=h..o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
159 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
160 if t+0==0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
161 n="0"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
162 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
163 local o=#i(t,"^0*")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
164 t=e(t,o+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
165 o=#i(t,"0*$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
166 if o>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
167 t=e(t,1,#t-o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
168 a=a+o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
169 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
170 local i=s.tostring(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
171 if a==0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
172 n=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
173 elseif a>0 and(a<=1+#i)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
174 n=t..d("0",a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
175 elseif a<0 and(a>=-#t)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
176 o=#t+a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
177 n=e(t,1,o).."."..e(t,o+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
178 elseif a<0 and(#i>=-a-#t)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
179 o=-a-#t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
180 n="."..d("0",o)..t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
181 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
182 n=t.."e"..a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
183 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
184 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
185 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
186 if n and n~=o[r]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
187 if h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
188 c("<number> (line "..l[r]..") "..o[r].." -> "..n)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
189 h=h+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
190 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
191 o[r]=n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
192 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
193 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
194 local function O(m)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
195 local t=o[m]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
196 local s=e(t,1,1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
197 local f=(s=="'")and'"'or"'"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
198 local t=e(t,2,-2)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
199 local a=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
200 local d,n=0,0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
201 while a<=#t do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
202 local c=e(t,a,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
203 if c=="\\"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
204 local o=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
205 local l=e(t,o,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
206 local h=r("abfnrtv\\\n\r\"\'0123456789",l,1,true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
207 if not h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
208 t=e(t,1,a-1)..e(t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
209 a=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
210 elseif h<=8 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
211 a=a+2
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
212 elseif h<=10 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
213 local i=e(t,o,o+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
214 if i=="\r\n"or i=="\n\r"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
215 t=e(t,1,a).."\n"..e(t,o+2)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
216 elseif h==10 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
217 t=e(t,1,a).."\n"..e(t,o+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
218 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
219 a=a+2
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
220 elseif h<=12 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
221 if l==s then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
222 d=d+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
223 a=a+2
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
224 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
225 n=n+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
226 t=e(t,1,a-1)..e(t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
227 a=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
228 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
229 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
230 local i=i(t,"^(%d%d?%d?)",o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
231 o=a+1+#i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
232 local l=i+0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
233 local h=u.char(l)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
234 local r=r("\a\b\f\n\r\t\v",h,1,true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
235 if r then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
236 i="\\"..e("abfnrtv",r,r)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
237 elseif l<32 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
238 i="\\"..l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
239 elseif h==s then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
240 i="\\"..h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
241 d=d+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
242 elseif h=="\\"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
243 i="\\\\"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
244 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
245 i=h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
246 if h==f then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
247 n=n+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
248 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
249 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
250 t=e(t,1,a-1)..i..e(t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
251 a=a+#i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
252 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
253 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
254 a=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
255 if c==f then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
256 n=n+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
257 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
258 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
259 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
260 if d>n then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
261 a=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
262 while a<=#t do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
263 local o,n,i=r(t,"([\'\"])",a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
264 if not o then break end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
265 if i==s then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
266 t=e(t,1,o-2)..e(t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
267 a=o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
268 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
269 t=e(t,1,o-1).."\\"..e(t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
270 a=o+2
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
271 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
272 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
273 s=f
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
274 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
275 t=s..t..s
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
276 if t~=o[m]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
277 if h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
278 c("<string> (line "..l[m]..") "..o[m].." -> "..t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
279 h=h+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
280 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
281 o[m]=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
282 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
283 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
284 local function I(u)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
285 local t=o[u]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
286 local s=i(t,"^%[=*%[")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
287 local a=#s
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
288 local c=e(t,-a,-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
289 local h=e(t,a+1,-(a+1))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
290 local n=""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
291 local t=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
292 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
293 local a,o,r,s=r(h,"([\r\n])([\r\n]?)",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
294 local o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
295 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
296 o=e(h,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
297 elseif a>=t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
298 o=e(h,t,a-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
299 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
300 if o~=""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
301 if i(o,"%s+$")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
302 warn.lstring="trailing whitespace in long string near line "..l[u]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
303 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
304 n=n..o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
305 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
306 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
307 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
308 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
309 t=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
310 if a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
311 if#s>0 and r~=s then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
312 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
313 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
314 if not(t==1 and t==a)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
315 n=n.."\n"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
316 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
317 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
318 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
319 if a>=3 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
320 local e,t=a-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
321 while e>=2 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
322 local a="%]"..d("=",e-2).."%]"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
323 if not i(n,a)then t=e end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
324 e=e-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
325 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
326 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
327 a=d("=",t-2)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
328 s,c="["..a.."[","]"..a.."]"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
329 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
330 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
331 o[u]=s..n..c
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
332 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
333 local function j(l)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
334 local a=o[l]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
335 local h=i(a,"^%-%-%[=*%[")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
336 local t=#h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
337 local u=e(a,-t,-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
338 local s=e(a,t+1,-(t-1))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
339 local n=""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
340 local a=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
341 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
342 local o,t,r,h=r(s,"([\r\n])([\r\n]?)",a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
343 local t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
344 if not o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
345 t=e(s,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
346 elseif o>=a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
347 t=e(s,a,o-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
348 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
349 if t~=""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
350 local a=i(t,"%s*$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
351 if#a>0 then t=e(t,1,-(a+1))end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
352 n=n..t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
353 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
354 if not o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
355 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
356 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
357 a=o+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
358 if o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
359 if#h>0 and r~=h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
360 a=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
361 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
362 n=n.."\n"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
363 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
364 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
365 t=t-2
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
366 if t>=3 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
367 local e,a=t-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
368 while e>=2 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
369 local t="%]"..d("=",e-2).."%]"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
370 if not i(n,t)then a=e end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
371 e=e-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
372 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
373 if a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
374 t=d("=",a-2)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
375 h,u="--["..t.."[","]"..t.."]"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
376 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
377 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
378 o[l]=h..n..u
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
379 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
380 local function q(n)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
381 local t=o[n]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
382 local a=i(t,"%s*$")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
383 if#a>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
384 t=e(t,1,-(a+1))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
385 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
386 o[n]=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
387 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
388 local function x(o,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
389 if not o then return false end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
390 local t=i(a,"^%-%-%[=*%[")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
391 local t=#t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
392 local i=e(a,-t,-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
393 local e=e(a,t+1,-(t-1))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
394 if r(e,o,1,true)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
395 return true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
396 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
397 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
398 function optimize(t,a,i,r)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
399 local f=t["opt-comments"]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
400 local u=t["opt-whitespace"]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
401 local m=t["opt-emptylines"]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
402 local k=t["opt-eols"]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
403 local E=t["opt-strings"]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
404 local T=t["opt-numbers"]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
405 local z=t.KEEP
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
406 h=t.DETAILS and 0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
407 c=c or s.print
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
408 if k then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
409 f=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
410 u=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
411 m=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
412 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
413 n,o,l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
414 =a,i,r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
415 local t=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
416 local a,r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
417 local s
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
418 local function i(a,i,e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
419 e=e or t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
420 n[e]=a or""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
421 o[e]=i or""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
422 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
423 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
424 a,r=n[t],o[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
425 local h=w(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
426 if h then s=nil end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
427 if a=="TK_EOS"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
428 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
429 elseif a=="TK_KEYWORD"or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
430 a=="TK_NAME"or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
431 a=="TK_OP"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
432 s=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
433 elseif a=="TK_NUMBER"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
434 if T then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
435 A(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
436 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
437 s=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
438 elseif a=="TK_STRING"or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
439 a=="TK_LSTRING"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
440 if E then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
441 if a=="TK_STRING"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
442 O(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
443 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
444 I(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
445 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
446 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
447 s=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
448 elseif a=="TK_COMMENT"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
449 if f then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
450 if t==1 and e(r,1,1)=="#"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
451 q(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
452 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
453 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
454 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
455 elseif u then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
456 q(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
457 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
458 elseif a=="TK_LCOMMENT"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
459 if x(z,r)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
460 if u then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
461 j(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
462 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
463 s=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
464 elseif f then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
465 local e=_(r)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
466 if y[n[t+1]]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
467 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
468 a=""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
469 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
470 i("TK_SPACE"," ")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
471 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
472 if not m and e>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
473 i("TK_EOL",d("\n",e))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
474 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
475 if u and a~=""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
476 t=t-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
477 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
478 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
479 if u then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
480 j(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
481 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
482 s=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
483 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
484 elseif a=="TK_EOL"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
485 if h and m then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
486 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
487 elseif r=="\r\n"or r=="\n\r"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
488 i("TK_EOL","\n")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
489 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
490 elseif a=="TK_SPACE"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
491 if u then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
492 if h or g(t)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
493 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
494 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
495 local a=n[s]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
496 if a=="TK_LCOMMENT"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
497 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
498 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
499 local e=n[t+1]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
500 if y[e]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
501 if(e=="TK_COMMENT"or e=="TK_LCOMMENT")and
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
502 a=="TK_OP"and o[s]=="-"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
503 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
504 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
505 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
506 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
507 local e=v(s,t+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
508 if e==""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
509 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
510 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
511 i("TK_SPACE"," ")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
512 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
513 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
514 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
515 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
516 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
517 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
518 error("unidentified token encountered")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
519 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
520 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
521 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
522 b()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
523 if k then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
524 t=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
525 if n[1]=="TK_COMMENT"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
526 t=3
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
527 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
528 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
529 a,r=n[t],o[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
530 if a=="TK_EOS"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
531 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
532 elseif a=="TK_EOL"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
533 local a,e=n[t-1],n[t+1]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
534 if p[a]and p[e]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
535 local e=v(t-1,t+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
536 if e==""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
537 i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
538 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
539 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
540 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
541 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
542 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
543 b()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
544 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
545 if h and h>0 then c()end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
546 return n,o,l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
547 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
548 end)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
549 package.preload['optparser']=(function(...)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
550 local e=_G
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
551 local a=require"string"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
552 local f=require"table"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
553 module"optparser"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
554 local s="etaoinshrdlucmfwypvbgkqjxz_ETAOINSHRDLUCMFWYPVBGKQJXZ"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
555 local r="etaoinshrdlucmfwypvbgkqjxz_0123456789ETAOINSHRDLUCMFWYPVBGKQJXZ"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
556 local w={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
557 for e in a.gmatch([[
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
558 and break do else elseif end false for function if in
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
559 local nil not or repeat return then true until while
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
560 self]],"%S+")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
561 w[e]=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
562 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
563 local h,m,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
564 u,o,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
565 l,y,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
566 d,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
567 n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
568 local function c(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
569 local o={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
570 for n=1,#e do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
571 local e=e[n]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
572 local i=e.name
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
573 if not o[i]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
574 o[i]={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
575 decl=0,token=0,size=0,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
576 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
577 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
578 local t=o[i]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
579 t.decl=t.decl+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
580 local o=e.xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
581 local a=#o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
582 t.token=t.token+a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
583 t.size=t.size+a*#i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
584 if e.decl then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
585 e.id=n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
586 e.xcount=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
587 if a>1 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
588 e.first=o[2]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
589 e.last=o[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
590 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
591 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
592 t.id=n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
593 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
594 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
595 return o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
596 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
597 local function v(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
598 local n=a.byte
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
599 local d=a.char
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
600 local a={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
601 TK_KEYWORD=true,TK_NAME=true,TK_NUMBER=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
602 TK_STRING=true,TK_LSTRING=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
603 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
604 if not e["opt-comments"]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
605 a.TK_COMMENT=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
606 a.TK_LCOMMENT=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
607 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
608 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
609 for e=1,#h do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
610 t[e]=m[e]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
611 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
612 for e=1,#o do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
613 local e=o[e]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
614 local a=e.xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
615 for e=1,e.xcount do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
616 local e=a[e]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
617 t[e]=""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
618 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
619 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
620 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
621 for t=0,255 do e[t]=0 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
622 for o=1,#h do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
623 local o,t=h[o],t[o]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
624 if a[o]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
625 for a=1,#t do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
626 local t=n(t,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
627 e[t]=e[t]+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
628 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
629 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
630 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
631 local function i(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
632 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
633 for o=1,#a do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
634 local a=n(a,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
635 t[o]={c=a,freq=e[a],}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
636 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
637 f.sort(t,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
638 function(t,e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
639 return t.freq>e.freq
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
640 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
641 )
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
642 local a={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
643 for e=1,#t do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
644 a[e]=d(t[e].c)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
645 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
646 return f.concat(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
647 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
648 s=i(s)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
649 r=i(r)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
650 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
651 local function p()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
652 local t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
653 local n,h=#s,#r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
654 local e=d
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
655 if e<n then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
656 e=e+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
657 t=a.sub(s,e,e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
658 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
659 local o,i=n,1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
660 repeat
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
661 e=e-o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
662 o=o*h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
663 i=i+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
664 until o>e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
665 local o=e%n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
666 e=(e-o)/n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
667 o=o+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
668 t=a.sub(s,o,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
669 while i>1 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
670 local o=e%h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
671 e=(e-o)/h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
672 o=o+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
673 t=t..a.sub(r,o,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
674 i=i-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
675 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
676 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
677 d=d+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
678 return t,l[t]~=nil
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
679 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
680 function optimize(e,a,s,i,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
681 h,m,u,o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
682 =a,s,i,t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
683 d=0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
684 n={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
685 l=c(u)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
686 y=c(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
687 if e["opt-entropy"]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
688 v(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
689 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
690 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
691 for t=1,#o do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
692 e[t]=o[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
693 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
694 f.sort(e,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
695 function(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
696 return e.xcount>t.xcount
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
697 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
698 )
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
699 local a,t,r={},1,false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
700 for o=1,#e do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
701 local e=e[o]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
702 if not e.isself then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
703 a[t]=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
704 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
705 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
706 r=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
707 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
708 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
709 e=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
710 local s=#e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
711 while s>0 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
712 local h,t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
713 repeat
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
714 h,t=p()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
715 until not w[h]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
716 n[#n+1]=h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
717 local a=s
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
718 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
719 local i=u[l[h].id].xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
720 local h=#i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
721 for t=1,s do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
722 local t=e[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
723 local n,e=t.act,t.rem
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
724 while e<0 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
725 e=o[-e].rem
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
726 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
727 local o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
728 for t=1,h do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
729 local t=i[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
730 if t>=n and t<=e then o=true end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
731 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
732 if o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
733 t.skip=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
734 a=a-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
735 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
736 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
737 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
738 while a>0 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
739 local t=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
740 while e[t].skip do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
741 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
742 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
743 a=a-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
744 local i=e[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
745 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
746 i.newname=h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
747 i.skip=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
748 i.done=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
749 local s,r=i.first,i.last
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
750 local h=i.xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
751 if s and a>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
752 local n=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
753 while n>0 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
754 while e[t].skip do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
755 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
756 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
757 n=n-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
758 local e=e[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
759 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
760 local n,t=e.act,e.rem
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
761 while t<0 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
762 t=o[-t].rem
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
763 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
764 if not(r<n or s>t)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
765 if n>=i.act then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
766 for o=1,i.xcount do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
767 local o=h[o]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
768 if o>=n and o<=t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
769 a=a-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
770 e.skip=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
771 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
772 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
773 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
774 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
775 if e.last and e.last>=i.act then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
776 a=a-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
777 e.skip=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
778 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
779 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
780 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
781 if a==0 then break end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
782 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
783 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
784 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
785 local a,t={},1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
786 for o=1,s do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
787 local e=e[o]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
788 if not e.done then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
789 e.skip=false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
790 a[t]=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
791 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
792 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
793 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
794 e=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
795 s=#e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
796 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
797 for e=1,#o do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
798 local e=o[e]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
799 local t=e.xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
800 if e.newname then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
801 for a=1,e.xcount do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
802 local t=t[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
803 m[t]=e.newname
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
804 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
805 e.name,e.oldname
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
806 =e.newname,e.name
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
807 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
808 e.oldname=e.name
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
809 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
810 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
811 if r then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
812 n[#n+1]="self"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
813 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
814 local e=c(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
815 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
816 end)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
817 package.preload['llex']=(function(...)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
818 local f=_G
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
819 local r=require"string"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
820 module"llex"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
821 local l=r.find
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
822 local c=r.match
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
823 local i=r.sub
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
824 local m={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
825 for e in r.gmatch([[
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
826 and break do else elseif end false for function if in
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
827 local nil not or repeat return then true until while]],"%S+")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
828 m[e]=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
829 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
830 local e,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
831 d,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
832 a,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
833 n,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
834 h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
835 local function o(t,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
836 local e=#tok+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
837 tok[e]=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
838 seminfo[e]=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
839 tokln[e]=h
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
840 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
841 local function s(t,s)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
842 local n=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
843 local i=n(e,t,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
844 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
845 local e=n(e,t,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
846 if(e=="\n"or e=="\r")and(e~=i)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
847 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
848 i=i..e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
849 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
850 if s then o("TK_EOL",i)end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
851 h=h+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
852 a=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
853 return t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
854 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
855 function init(t,i)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
856 e=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
857 d=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
858 a=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
859 h=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
860 tok={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
861 seminfo={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
862 tokln={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
863 local i,n,e,t=l(e,"^(#[^\r\n]*)(\r?\n?)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
864 if i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
865 a=a+#e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
866 o("TK_COMMENT",e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
867 if#t>0 then s(a,true)end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
868 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
869 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
870 function chunkid()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
871 if d and c(d,"^[=@]")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
872 return i(d,2)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
873 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
874 return"[string]"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
875 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
876 function errorline(a,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
877 local e=error or f.error
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
878 e(r.format("%s:%d: %s",chunkid(),t or h,a))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
879 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
880 local r=errorline
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
881 local function u(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
882 local i=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
883 local n=i(e,t,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
884 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
885 local o=#c(e,"=*",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
886 t=t+o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
887 a=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
888 return(i(e,t,t)==n)and o or(-o)-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
889 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
890 local function w(h,d)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
891 local t=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
892 local i=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
893 local o=i(e,t,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
894 if o=="\r"or o=="\n"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
895 t=s(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
896 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
897 local o=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
898 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
899 local o,c,l=l(e,"([\r\n%]])",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
900 if not o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
901 r(h and"unfinished long string"or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
902 "unfinished long comment")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
903 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
904 t=o
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
905 if l=="]"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
906 if u(t)==d then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
907 n=i(e,n,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
908 a=a+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
909 return n
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
910 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
911 t=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
912 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
913 n=n.."\n"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
914 t=s(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
915 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
916 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
917 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
918 local function y(u)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
919 local t=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
920 local h=l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
921 local d=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
922 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
923 local i,l,o=h(e,"([\n\r\\\"\'])",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
924 if i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
925 if o=="\n"or o=="\r"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
926 r("unfinished string")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
927 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
928 t=i
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
929 if o=="\\"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
930 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
931 o=d(e,t,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
932 if o==""then break end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
933 i=h("abfnrtv\n\r",o,1,true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
934 if i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
935 if i>7 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
936 t=s(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
937 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
938 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
939 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
940 elseif h(o,"%D")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
941 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
942 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
943 local o,e,a=h(e,"^(%d%d?%d?)",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
944 t=e+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
945 if a+1>256 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
946 r("escape sequence too large")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
947 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
948 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
949 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
950 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
951 if o==u then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
952 a=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
953 return d(e,n,t-1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
954 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
955 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
956 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
957 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
958 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
959 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
960 r("unfinished string")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
961 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
962 function llex()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
963 local h=l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
964 local l=c
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
965 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
966 local t=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
967 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
968 local c,p,d=h(e,"^([_%a][_%w]*)",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
969 if c then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
970 a=t+#d
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
971 if m[d]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
972 o("TK_KEYWORD",d)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
973 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
974 o("TK_NAME",d)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
975 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
976 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
977 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
978 local d,m,c=h(e,"^(%.?)%d",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
979 if d then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
980 if c=="."then t=t+1 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
981 local u,s,n=h(e,"^%d*[%.%d]*([eE]?)",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
982 t=s+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
983 if#n==1 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
984 if l(e,"^[%+%-]",t)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
985 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
986 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
987 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
988 local n,t=h(e,"^[_%w]*",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
989 a=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
990 local e=i(e,d,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
991 if not f.tonumber(e)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
992 r("malformed number")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
993 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
994 o("TK_NUMBER",e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
995 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
996 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
997 local c,m,f,d=h(e,"^((%s)[ \t\v\f]*)",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
998 if c then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
999 if d=="\n"or d=="\r"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1000 s(t,true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1001 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1002 a=m+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1003 o("TK_SPACE",f)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1004 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1005 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1006 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1007 local s=l(e,"^%p",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1008 if s then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1009 n=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1010 local d=h("-[\"\'.=<>~",s,1,true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1011 if d then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1012 if d<=2 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1013 if d==1 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1014 local r=l(e,"^%-%-(%[?)",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1015 if r then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1016 t=t+2
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1017 local s=-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1018 if r=="["then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1019 s=u(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1020 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1021 if s>=0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1022 o("TK_LCOMMENT",w(false,s))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1023 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1024 a=h(e,"[\n\r]",t)or(#e+1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1025 o("TK_COMMENT",i(e,n,a-1))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1026 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1027 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1028 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1029 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1030 local e=u(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1031 if e>=0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1032 o("TK_LSTRING",w(true,e))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1033 elseif e==-1 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1034 o("TK_OP","[")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1035 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1036 r("invalid long string delimiter")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1037 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1038 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1039 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1040 elseif d<=5 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1041 if d<5 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1042 a=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1043 o("TK_STRING",y(s))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1044 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1045 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1046 s=l(e,"^%.%.?%.?",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1047 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1048 s=l(e,"^%p=?",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1049 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1050 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1051 a=t+#s
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1052 o("TK_OP",s)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1053 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1054 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1055 local e=i(e,t,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1056 if e~=""then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1057 a=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1058 o("TK_OP",e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1059 break
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1060 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1061 o("TK_EOS","")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1062 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1063 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1064 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1065 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1066 return _M
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1067 end)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1068 package.preload['lparser']=(function(...)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1069 local R=_G
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1070 local p=require"string"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1071 module"lparser"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1072 local _,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1073 q,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1074 z,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1075 S,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1076 u,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1077 r,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1078 V,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1079 t,k,l,f,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1080 w,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1081 a,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1082 K,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1083 j,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1084 I,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1085 d,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1086 b,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1087 A
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1088 local v,h,y,E,T,x
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1089 local e=p.gmatch
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1090 local D={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1091 for e in e("else elseif end until <eof>","%S+")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1092 D[e]=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1093 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1094 local B={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1095 for e in e("if while do for repeat function local return break","%S+")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1096 B[e]=e.."_stat"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1097 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1098 local L={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1099 local G={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1100 for e,t,a in e([[
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1101 {+ 6 6}{- 6 6}{* 7 7}{/ 7 7}{% 7 7}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1102 {^ 10 9}{.. 5 4}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1103 {~= 3 3}{== 3 3}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1104 {< 3 3}{<= 3 3}{> 3 3}{>= 3 3}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1105 {and 2 2}{or 1 1}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1106 ]],"{(%S+)%s(%d+)%s(%d+)}")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1107 L[e]=t+0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1108 G[e]=a+0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1109 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1110 local Z={["not"]=true,["-"]=true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1111 ["#"]=true,}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1112 local X=8
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1113 local function o(a,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1114 local e=error or R.error
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1115 e(p.format("(source):%d: %s",t or l,a))
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1116 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1117 local function e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1118 V=z[u]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1119 t,k,l,f
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1120 =_[u],q[u],z[u],S[u]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1121 u=u+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1122 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1123 local function J()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1124 return _[u]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1125 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1126 local function n(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1127 local e=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1128 if e~="<number>"and e~="<string>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1129 if e=="<name>"then e=k end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1130 e="'"..e.."'"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1131 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1132 o(a.." near "..e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1133 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1134 local function c(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1135 n("'"..e.."' expected")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1136 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1137 local function o(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1138 if t==a then e();return true end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1139 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1140 local function O(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1141 if t~=e then c(e)end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1142 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1143 local function i(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1144 O(t);e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1145 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1146 local function Q(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1147 if not e then n(t)end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1148 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1149 local function s(e,a,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1150 if not o(e)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1151 if t==l then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1152 c(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1153 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1154 n("'"..e.."' expected (to close '"..a.."' at line "..t..")")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1155 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1156 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1157 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1158 local function m()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1159 O("<name>")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1160 local t=k
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1161 w=f
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1162 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1163 return t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1164 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1165 local function N(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1166 e.k="VK"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1167 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1168 local function U(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1169 N(e,m())
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1170 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1171 local function c(o,i)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1172 local t=a.bl
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1173 local e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1174 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1175 e=t.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1176 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1177 e=a.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1178 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1179 local t=#d+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1180 d[t]={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1181 name=o,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1182 xref={w},
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1183 decl=w,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1184 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1185 if i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1186 d[t].isself=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1187 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1188 local a=#b+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1189 b[a]=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1190 A[a]=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1191 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1192 local function g(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1193 local t=#b
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1194 while e>0 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1195 e=e-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1196 local t=t-e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1197 local a=b[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1198 local e=d[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1199 local o=e.name
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1200 e.act=f
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1201 b[t]=nil
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1202 local i=A[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1203 A[t]=nil
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1204 local t=i[o]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1205 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1206 e=d[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1207 e.rem=-a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1208 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1209 i[o]=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1210 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1211 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1212 local function H()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1213 local t=a.bl
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1214 local e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1215 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1216 e=t.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1217 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1218 e=a.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1219 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1220 for t,e in R.pairs(e)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1221 local e=d[e]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1222 e.rem=f
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1223 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1224 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1225 local function f(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1226 if p.sub(e,1,1)=="("then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1227 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1228 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1229 c(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1230 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1231 local function R(o,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1232 local t=o.bl
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1233 local e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1234 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1235 e=t.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1236 while e do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1237 if e[a]then return e[a]end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1238 t=t.prev
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1239 e=t and t.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1240 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1241 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1242 e=o.locallist
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1243 return e[a]or-1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1244 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1245 local function p(t,o,e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1246 if t==nil then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1247 e.k="VGLOBAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1248 return"VGLOBAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1249 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1250 local a=R(t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1251 if a>=0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1252 e.k="VLOCAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1253 e.id=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1254 return"VLOCAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1255 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1256 if p(t.prev,o,e)=="VGLOBAL"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1257 return"VGLOBAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1258 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1259 e.k="VUPVAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1260 return"VUPVAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1261 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1262 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1263 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1264 local function W(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1265 local t=m()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1266 p(a,t,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1267 if o.k=="VGLOBAL"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1268 local e=I[t]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1269 if not e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1270 e=#j+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1271 j[e]={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1272 name=t,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1273 xref={w},
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1274 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1275 I[t]=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1276 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1277 local e=j[e].xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1278 e[#e+1]=w
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1279 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1280 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1281 local e=o.id
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1282 local e=d[e].xref
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1283 e[#e+1]=w
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1284 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1285 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1286 local function p(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1287 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1288 e.isbreakable=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1289 e.prev=a.bl
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1290 e.locallist={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1291 a.bl=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1292 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1293 local function w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1294 local e=a.bl
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1295 H()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1296 a.bl=e.prev
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1297 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1298 local function C()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1299 local e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1300 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1301 e=K
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1302 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1303 e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1304 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1305 e.prev=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1306 e.bl=nil
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1307 e.locallist={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1308 a=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1309 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1310 local function M()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1311 H()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1312 a=a.prev
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1313 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1314 local function H(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1315 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1316 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1317 U(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1318 a.k="VINDEXED"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1319 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1320 local function F(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1321 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1322 h(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1323 i("]")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1324 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1325 local function R(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1326 local e,a={},{}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1327 if t=="<name>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1328 U(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1329 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1330 F(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1331 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1332 i("=")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1333 h(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1334 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1335 local function Y(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1336 if e.v.k=="VVOID"then return end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1337 e.v.k="VVOID"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1338 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1339 local function Y(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1340 h(e.v)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1341 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1342 local function P(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1343 local n=l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1344 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1345 e.v={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1346 e.t=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1347 a.k="VRELOCABLE"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1348 e.v.k="VVOID"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1349 i("{")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1350 repeat
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1351 if t=="}"then break end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1352 local t=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1353 if t=="<name>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1354 if J()~="="then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1355 Y(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1356 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1357 R(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1358 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1359 elseif t=="["then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1360 R(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1361 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1362 Y(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1363 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1364 until not o(",")and not o(";")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1365 s("}","{",n)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1366 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1367 local function J()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1368 local i=0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1369 if t~=")"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1370 repeat
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1371 local t=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1372 if t=="<name>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1373 c(m())
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1374 i=i+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1375 elseif t=="..."then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1376 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1377 a.is_vararg=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1378 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1379 n("<name> or '...' expected")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1380 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1381 until a.is_vararg or not o(",")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1382 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1383 g(i)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1384 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1385 local function Y(h)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1386 local a={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1387 local i=l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1388 local o=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1389 if o=="("then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1390 if i~=V then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1391 n("ambiguous syntax (function call x new statement)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1392 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1393 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1394 if t==")"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1395 a.k="VVOID"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1396 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1397 v(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1398 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1399 s(")","(",i)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1400 elseif o=="{"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1401 P(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1402 elseif o=="<string>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1403 N(a,k)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1404 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1405 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1406 n("function arguments expected")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1407 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1408 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1409 h.k="VCALL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1410 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1411 local function V(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1412 local t=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1413 if t=="("then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1414 local t=l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1415 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1416 h(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1417 s(")","(",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1418 elseif t=="<name>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1419 W(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1420 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1421 n("unexpected symbol")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1422 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1423 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1424 local function R(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1425 V(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1426 while true do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1427 local t=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1428 if t=="."then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1429 H(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1430 elseif t=="["then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1431 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1432 F(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1433 elseif t==":"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1434 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1435 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1436 U(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1437 Y(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1438 elseif t=="("or t=="<string>"or t=="{"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1439 Y(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1440 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1441 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1442 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1443 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1444 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1445 local function U(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1446 local t=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1447 if t=="<number>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1448 o.k="VKNUM"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1449 elseif t=="<string>"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1450 N(o,k)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1451 elseif t=="nil"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1452 o.k="VNIL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1453 elseif t=="true"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1454 o.k="VTRUE"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1455 elseif t=="false"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1456 o.k="VFALSE"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1457 elseif t=="..."then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1458 Q(a.is_vararg==true,
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1459 "cannot use '...' outside a vararg function");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1460 o.k="VVARARG"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1461 elseif t=="{"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1462 P(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1463 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1464 elseif t=="function"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1465 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1466 T(o,false,l)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1467 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1468 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1469 R(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1470 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1471 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1472 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1473 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1474 local function k(o,n)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1475 local a=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1476 local i=Z[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1477 if i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1478 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1479 k(o,X)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1480 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1481 U(o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1482 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1483 a=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1484 local t=L[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1485 while t and t>n do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1486 local o={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1487 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1488 local e=k(o,G[a])
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1489 a=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1490 t=L[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1491 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1492 return a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1493 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1494 function h(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1495 k(e,0)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1496 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1497 local function N(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1498 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1499 local e=e.v.k
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1500 Q(e=="VLOCAL"or e=="VUPVAL"or e=="VGLOBAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1501 or e=="VINDEXED","syntax error")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1502 if o(",")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1503 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1504 e.v={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1505 R(e.v)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1506 N(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1507 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1508 i("=")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1509 v(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1510 return
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1511 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1512 t.k="VNONRELOC"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1513 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1514 local function k(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1515 i("do")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1516 p(false)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1517 g(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1518 y()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1519 w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1520 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1521 local function L(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1522 local t=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1523 f("(for index)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1524 f("(for limit)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1525 f("(for step)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1526 c(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1527 i("=")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1528 E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1529 i(",")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1530 E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1531 if o(",")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1532 E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1533 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1534 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1535 k(1,true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1536 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1537 local function F(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1538 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1539 f("(for generator)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1540 f("(for state)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1541 f("(for control)")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1542 c(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1543 local e=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1544 while o(",")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1545 c(m())
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1546 e=e+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1547 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1548 i("in")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1549 local a=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1550 v(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1551 k(e,false)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1552 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1553 local function U(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1554 local a=false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1555 W(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1556 while t=="."do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1557 H(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1558 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1559 if t==":"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1560 a=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1561 H(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1562 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1563 return a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1564 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1565 function E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1566 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1567 h(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1568 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1569 local function k()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1570 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1571 h(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1572 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1573 local function E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1574 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1575 k()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1576 i("then")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1577 y()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1578 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1579 local function H()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1580 local e,t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1581 c(m())
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1582 e.k="VLOCAL"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1583 g(1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1584 T(t,false,l)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1585 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1586 local function W()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1587 local e=0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1588 local t={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1589 repeat
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1590 c(m())
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1591 e=e+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1592 until not o(",")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1593 if o("=")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1594 v(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1595 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1596 t.k="VVOID"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1597 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1598 g(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1599 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1600 function v(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1601 h(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1602 while o(",")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1603 h(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1604 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1605 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1606 function T(a,t,e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1607 C()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1608 i("(")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1609 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1610 f("self",true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1611 g(1)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1612 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1613 J()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1614 i(")")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1615 x()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1616 s("end","function",e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1617 M()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1618 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1619 function y()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1620 p(false)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1621 x()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1622 w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1623 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1624 function for_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1625 local o=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1626 p(true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1627 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1628 local a=m()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1629 local e=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1630 if e=="="then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1631 L(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1632 elseif e==","or e=="in"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1633 F(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1634 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1635 n("'=' or 'in' expected")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1636 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1637 s("end","for",o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1638 w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1639 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1640 function while_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1641 local t=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1642 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1643 k()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1644 p(true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1645 i("do")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1646 y()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1647 s("end","while",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1648 w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1649 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1650 function repeat_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1651 local t=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1652 p(true)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1653 p(false)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1654 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1655 x()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1656 s("until","repeat",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1657 k()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1658 w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1659 w()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1660 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1661 function if_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1662 local a=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1663 local o={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1664 E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1665 while t=="elseif"do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1666 E()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1667 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1668 if t=="else"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1669 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1670 y()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1671 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1672 s("end","if",a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1673 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1674 function return_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1675 local a={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1676 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1677 local e=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1678 if D[e]or e==";"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1679 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1680 v(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1681 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1682 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1683 function break_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1684 local t=a.bl
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1685 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1686 while t and not t.isbreakable do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1687 t=t.prev
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1688 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1689 if not t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1690 n("no loop to break")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1691 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1692 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1693 function expr_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1694 local e={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1695 e.v={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1696 R(e.v)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1697 if e.v.k=="VCALL"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1698 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1699 e.prev=nil
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1700 N(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1701 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1702 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1703 function function_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1704 local o=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1705 local a,t={},{}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1706 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1707 local e=U(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1708 T(t,e,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1709 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1710 function do_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1711 local t=r
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1712 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1713 y()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1714 s("end","do",t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1715 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1716 function local_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1717 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1718 if o("function")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1719 H()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1720 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1721 W()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1722 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1723 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1724 local function i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1725 r=l
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1726 local e=t
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1727 local t=B[e]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1728 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1729 _M[t]()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1730 if e=="return"or e=="break"then return true end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1731 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1732 expr_stat()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1733 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1734 return false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1735 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1736 function x()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1737 local e=false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1738 while not e and not D[t]do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1739 e=i()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1740 o(";")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1741 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1742 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1743 function parser()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1744 C()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1745 a.is_vararg=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1746 e()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1747 x()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1748 O("<eof>")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1749 M()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1750 return j,d
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1751 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1752 function init(e,o,n)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1753 u=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1754 K={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1755 local t=1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1756 _,q,z,S={},{},{},{}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1757 for a=1,#e do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1758 local e=e[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1759 local i=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1760 if e=="TK_KEYWORD"or e=="TK_OP"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1761 e=o[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1762 elseif e=="TK_NAME"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1763 e="<name>"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1764 q[t]=o[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1765 elseif e=="TK_NUMBER"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1766 e="<number>"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1767 q[t]=0
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1768 elseif e=="TK_STRING"or e=="TK_LSTRING"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1769 e="<string>"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1770 q[t]=""
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1771 elseif e=="TK_EOS"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1772 e="<eof>"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1773 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1774 i=false
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1775 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1776 if i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1777 _[t]=e
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1778 z[t]=n[a]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1779 S[t]=a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1780 t=t+1
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1781 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1782 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1783 j,I,d={},{},{}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1784 b,A={},{}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1785 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1786 return _M
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1787 end)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1788 do local e={};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1789 e["vio"]="local vio = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1790 vio.__index = vio; \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1791 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1792 function vio.open(string)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1793 return setmetatable({ pos = 1, data = string }, vio);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1794 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1795 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1796 function vio:read(format, ...)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1797 if self.pos >= #self.data then return; end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1798 if format == \"*a\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1799 local oldpos = self.pos;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1800 self.pos = #self.data;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1801 return self.data:sub(oldpos, self.pos);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1802 elseif format == \"*l\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1803 local data;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1804 data, self.pos = self.data:match(\"([^\\r\\n]*)\\r?\\n?()\", self.pos)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1805 return data;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1806 elseif format == \"*n\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1807 local data;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1808 data, self.pos = self.data:match(\"(%d+)()\", self.pos)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1809 return tonumber(data); \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1810 elseif type(format) == \"number\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1811 local oldpos = self.pos;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1812 self.pos = self.pos + format;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1813 return self.data:sub(oldpos, self.pos-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1814 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1815 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1816 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1817 function vio:seek(whence, offset)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1818 if type(whence) == \"number\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1819 whence, offset = \"cur\", whence;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1820 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1821 offset = offset or 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1822 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1823 if whence == \"cur\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1824 self.pos = self.pos + offset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1825 elseif whence == \"set\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1826 self.pos = offset + 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1827 elseif whence == \"end\" then\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1828 self.pos = #self.data - offset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1829 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1830 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1831 return self.pos;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1832 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1833 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1834 local function _readline(f) return f:read(\"*l\"); end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1835 function vio:lines()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1836 return _readline, self;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1837 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1838 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1839 function vio:write(...)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1840 for i=1,select('#', ...) do\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1841 local dat = tostring(select(i, ...));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1842 self.data = self.data:sub(1, self.pos-1)..dat..self.data:sub(self.pos+#dat, -1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1843 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1844 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1845 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1846 function vio:close()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1847 self.pos, self.data = nil, nil;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1848 end\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1849 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1850 "e["gunzip.lua"]="local base_char,keywords=128,{\"and\",\"break\",\"do\",\"else\",\"elseif\",\"end\",\"false\",\"for\",\"function\",\"if\",\"in\",\"local\",\"nil\",\"not\",\"or\",\"repeat\",\"return\",\"then\",\"true\",\"until\",\"while\",\"read\",\"nbits\",\"nbits_left_in_byte\",\"wnd_pos\",\"output\",\"val\",\"input\",}; function prettify(code) return code:gsub(\"[\"..string.char(base_char)..\"-\"..string.char(base_char+#keywords)..\"]\", \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1851 function (c) return keywords[c:byte()-base_char]; end) end return assert(loadstring(prettify[===[Œ i,h,b,m,l,d,e,y,r,w,u,v,l,l=assert,error,ipairs,pairs,tostring,type,setmetatable,io,math,table.sort,math.max,string.char,io.open,_G;Œ ‰ p(n)Œ l={};Œ e=e({},l)‰ l:__index(l)Œ n=n(l);e[l]=n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1852 ‘ n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1853 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1854 ‘ e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1855 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1856 Œ ‰ l(n,l)l=l 1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1857 h({n},l+1)†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1858 Œ ‰ _(n)Œ l={}l.outbs=n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1859 l.wnd={}l.™=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1860 ‘ l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1861 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1862 Œ ‰ t(l,e)Œ n=l.™\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1863 l.outbs(e)l.wnd[n]=e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1864 l.™=n%32768+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1865 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1866 Œ ‰ n(l)‘ i(l,'unexpected end of file')†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1867 Œ ‰ o(n,l)‘ n%(l+l)>=l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1868 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1869 Œ a=p(‰(l)‘ 2^l †)Œ c=e({},{__mode='k'})Œ ‰ g(o)Œ l=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1870 Œ e={}‰ e:–()Œ n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1871 Š l<=#o ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1872 n=o:byte(l)l=l+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1873 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1874 ‘ n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1875 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1876 ‘ e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1877 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1878 Πl\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1879 Œ ‰ s(d)Œ n,l,o=0,0,{};‰ o:˜()‘ l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1880 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1881 ‰ o:–(e)e=e 1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1882 • l<e ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1883 Œ e=d:–()Š Ž e ’ ‘ †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1884 n=n+a[l]*e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1885 l=l+8\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1886 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1887 Πo=a[e]Πa=n%o\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1888 n=(n-a)/o\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1889 l=l-e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1890 ‘ a\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1891 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1892 c[o]=“\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1893 ‘ o\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1894 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1895 Œ ‰ f(l)‘ c[l] l s(g(l))†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1896 Œ ‰ s(l)Œ n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1897 Š y.type(l)=='file'’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1898 n=‰(n)l:write(v(n))†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1899 … d(l)=='function'’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1900 n=l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1901 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1902 ‘ n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1903 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1904 Œ ‰ d(e,o)Œ l={}Š o ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1905 ˆ e,n ‹ m(e)ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1906 Š n~=0 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1907 l[#l+1]={›=e,—=n}†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1908 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1909 „\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1910 ˆ n=1,#e-2,2 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1911 Œ o,n,e=e[n],e[n+1],e[n+2]Š n~=0 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1912 ˆ e=o,e-1 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1913 l[#l+1]={›=e,—=n}†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1914 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1915 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1916 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1917 w(l,‰(n,l)‘ n.—==l.— n.›<l.› n.—<l.—\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1918 †)Œ e=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1919 Πo=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1920 ˆ n,l ‹ b(l)ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1921 Š l.—~=o ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1922 e=e*a[l.—-o]o=l.—\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1923 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1924 l.code=e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1925 e=e+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1926 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1927 Πe=r.huge\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1928 Œ c={}ˆ n,l ‹ b(l)ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1929 e=r.min(e,l.—)c[l.code]=l.›\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1930 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1931 Œ ‰ o(n,e)Œ l=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1932 ˆ e=1,e ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1933 Πe=n%2\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1934 n=(n-e)/2\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1935 l=l*2+e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1936 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1937 ‘ l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1938 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1939 Œ d=p(‰(l)‘ a[e]+o(l,e)†)‰ l:–(a)Œ o,l=1,0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1940 • 1 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1941 Š l==0 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1942 o=d[n(a:–(e))]l=l+e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1943 „\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1944 Œ n=n(a:–())l=l+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1945 o=o*2+n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1946 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1947 Œ l=c[o]Š l ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1948 ‘ l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1949 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1950 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1951 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1952 ‘ l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1953 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1954 Œ ‰ b(l)Œ a=2^1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1955 Πe=2^2\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1956 Πc=2^3\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1957 Πd=2^4\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1958 Œ n=l:–(8)Œ n=l:–(8)Œ n=l:–(8)Œ n=l:–(8)Œ t=l:–(32)Œ t=l:–(8)Œ t=l:–(8)Š o(n,e)’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1959 Œ n=l:–(16)Œ e=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1960 ˆ n=1,n ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1961 e=l:–(8)†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1962 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1963 Š o(n,c)’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1964 • l:–(8)~=0 ƒ †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1965 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1966 Š o(n,d)’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1967 • l:–(8)~=0 ƒ †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1968 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1969 Š o(n,a)’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1970 l:–(16)†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1971 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1972 Œ ‰ p(l)Œ f=l:–(5)Œ i=l:–(5)Œ e=n(l:–(4))Œ a=e+4\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1973 Œ e={}Œ o={16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}ˆ n=1,a ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1974 Œ l=l:–(3)Œ n=o[n]e[n]=l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1975 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1976 Œ e=d(e,“)Œ ‰ r(o)Œ t={}Œ a\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1977 Πc=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1978 • c<o ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1979 Œ o=e:–(l)Œ e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1980 Š o<=15 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1981 e=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1982 a=o\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1983 … o==16 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1984 e=3+n(l:–(2))… o==17 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1985 e=3+n(l:–(3))a=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1986 … o==18 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1987 e=11+n(l:–(7))a=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1988 „\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1989 h'ASSERT'†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1990 ˆ l=1,e ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1991 t[c]=a\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1992 c=c+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1993 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1994 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1995 Œ l=d(t,“)‘ l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1996 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1997 Πn=f+257\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1998 Πl=i+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1999 Œ n=r(n)Œ l=r(l)‘ n,l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2000 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2001 Πa\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2002 Πo\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2003 Πc\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2004 Πr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2005 Œ ‰ h(e,n,l,d)Œ l=l:–(e)Š l<256 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2006 t(n,l)… l==256 ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2007 ‘ “\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2008 „\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2009 Š Ž a ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2010 Πl={[257]=3}Πe=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2011 ˆ n=258,285,4 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2012 ˆ n=n,n+3 ƒ l[n]=l[n-1]+e †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2013 Š n~=258 ’ e=e*2 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2014 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2015 l[285]=258\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2016 a=l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2017 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2018 Š Ž o ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2019 Œ l={}ˆ e=257,285 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2020 Πn=u(e-261,0)l[e]=(n-(n%4))/4\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2021 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2022 l[285]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2023 o=l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2024 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2025 Œ a=a[l]Œ l=o[l]Œ l=e:–(l)Œ o=a+l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2026 Š Ž c ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2027 Πe={[0]=1}Πl=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2028 ˆ n=1,29,2 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2029 ˆ n=n,n+1 ƒ e[n]=e[n-1]+l †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2030 Š n~=1 ’ l=l*2 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2031 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2032 c=e\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2033 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2034 Š Ž r ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2035 Œ n={}ˆ e=0,29 ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2036 Πl=u(e-2,0)n[e]=(l-(l%2))/2\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2037 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2038 r=n\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2039 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2040 Œ l=d:–(e)Œ a=c[l]Œ l=r[l]Œ l=e:–(l)Œ l=a+l\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2041 ˆ e=1,o ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2042 Œ l=(n.™-1-l)%32768+1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2043 t(n,i(n.wnd[l],'invalid distance'))†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2044 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2045 ‘ ‡\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2046 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2047 Œ ‰ u(l,a)Œ i=l:–(1)Œ e=l:–(2)Œ r=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2048 Πo=1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2049 Πc=2\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2050 Πf=3\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2051 Š e==r ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2052 l:–(l:˜())Œ e=l:–(16)Œ o=n(l:–(16))ˆ e=1,e ƒ\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2053 Œ l=n(l:–(8))t(a,l)†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2054 … e==o e==c ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2055 Πn,o\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2056 Š e==c ’\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2057 n,o=p(l)„\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2058 n=d{0,8,144,9,256,7,280,8,288,}o=d{0,5,32,}†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2059 ” h(l,a,n,o);†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2060 ‘ i~=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2061 †\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2062 Œ ‰ e(l)Œ n,l=f(l.œ),_(s(l.š)) ” u(n,l)†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2063 ‘ ‰(n)Œ l=f(n.œ)Œ n=s(n.š)b(l)e{œ=l,š=n}l:–(l:˜())l:–()†\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2064 ]===], '@gunzip.lua'))()"e["lua5.1.min.js"]="////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2065 // lua5.1.5.js: Lua 5.1.5 in JavaScript\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2066 // This file is a part of lua5.1.js project:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2067 // https://github.com/logiceditor-com/lua5.1.js/\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2068 // Copyright (c) LogicEditor <info@logiceditor.com>\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2069 // Copyright (c) lua5.1.js authors\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2070 // Distributed under the terms of the MIT license:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2071 // https://github.com/logiceditor-com/lua5.1.js/tree/master/COPYRIGHT\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2072 // Based on original Lua 5.1.5 header files:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2073 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2074 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2075 // WARNING: Emscriptenized code does not like minification.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2076 // Keep this file as is and enable compression in your HTTP server.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2077 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2078 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2079 var Lua5_1 = Lua5_1 || { };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2080 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2081 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2082 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2083 (function(Lua5_1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2084 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2085 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2086 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2087 // Note: For maximum-speed code, see \"Optimizing Code\" on the Emscripten wiki, https://github.com/kripken/emscripten/wiki/Optimizing-Code\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2088 // Note: Some Emscripten settings may limit the speed of the generated code.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2089 // The Module object: Our interface to the outside world. We import\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2090 // and export values on it, and do the work to get that through\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2091 // closure compiler if necessary. There are various ways Module can be used:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2092 // 1. Not defined. We create it here\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2093 // 2. A function parameter, function(Module) { ..generated code.. }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2094 // 3. pre-run appended it, var Module = {}; ..generated code..\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2095 // 4. External script tag defines var Module.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2096 // We need to do an eval in order to handle the closure compiler\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2097 // case, where this code here is minified but Module was defined\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2098 // elsewhere (e.g. case 4 above). We also need to check if Module\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2099 // already exists (e.g. case 3 above).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2100 // Note that if you want to run closure, and also to use Module\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2101 // after the generated code, you will need to define var Module = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2102 // before the code. Then that object will be used in the code, and you\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2103 // can continue to use Module afterwards as well.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2104 var Module;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2105 if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2106 // Sometimes an existing Module object exists with properties\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2107 // meant to overwrite the default module functionality. Here\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2108 // we collect those properties and reapply _after_ we configure\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2109 // the current environment's defaults to avoid having to be so\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2110 // defensive during initialization.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2111 var moduleOverrides = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2112 for (var key in Module) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2113 if (Module.hasOwnProperty(key)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2114 moduleOverrides[key] = Module[key];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2115 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2116 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2117 // The environment setup code below is customized to use Module.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2118 // *** Environment setup code ***\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2119 var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2120 var ENVIRONMENT_IS_WEB = typeof window === 'object';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2121 var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2122 var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2123 if (ENVIRONMENT_IS_NODE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2124 // Expose functionality in the same simple way that the shells work\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2125 // Note that we pollute the global namespace here, otherwise we break in node\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2126 Module['print'] = function(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2127 process['stdout'].write(x + '\\n');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2128 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2129 Module['printErr'] = function(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2130 process['stderr'].write(x + '\\n');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2131 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2132 var nodeFS = require('fs');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2133 var nodePath = require('path');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2134 Module['read'] = function(filename, binary) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2135 filename = nodePath['normalize'](filename);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2136 var ret = nodeFS['readFileSync'](filename);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2137 // The path is absolute if the normalized version is the same as the resolved.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2138 if (!ret && filename != nodePath['resolve'](filename)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2139 filename = path.join(__dirname, '..', 'src', filename);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2140 ret = nodeFS['readFileSync'](filename);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2141 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2142 if (ret && !binary) ret = ret.toString();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2143 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2144 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2145 Module['readBinary'] = function(filename) { return Module['read'](filename, true) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2146 Module['load'] = function(f) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2147 globalEval(read(f));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2148 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2149 Module['arguments'] = process['argv'].slice(2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2150 module.exports = Module;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2151 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2152 else if (ENVIRONMENT_IS_SHELL) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2153 Module['print'] = print;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2154 if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2155 if (typeof read != 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2156 Module['read'] = read;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2157 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2158 Module['read'] = function() { throw 'no read() available (jsc?)' };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2159 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2160 Module['readBinary'] = function(f) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2161 return read(f, 'binary');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2162 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2163 if (typeof scriptArgs != 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2164 Module['arguments'] = scriptArgs;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2165 } else if (typeof arguments != 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2166 Module['arguments'] = arguments;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2167 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2168 this['Module'] = Module;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2169 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2170 else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2171 Module['read'] = function(url) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2172 var xhr = new XMLHttpRequest();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2173 xhr.open('GET', url, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2174 xhr.send(null);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2175 return xhr.responseText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2176 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2177 if (typeof arguments != 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2178 Module['arguments'] = arguments;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2179 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2180 if (ENVIRONMENT_IS_WEB) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2181 Module['print'] = function(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2182 console.log(x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2183 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2184 Module['printErr'] = function(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2185 console.log(x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2186 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2187 this['Module'] = Module;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2188 } else if (ENVIRONMENT_IS_WORKER) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2189 // We can do very little here...\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2190 var TRY_USE_DUMP = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2191 Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== \"undefined\") ? (function(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2192 dump(x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2193 }) : (function(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2194 // self.postMessage(x); // enable this if you want stdout to be sent as messages\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2195 }));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2196 Module['load'] = importScripts;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2197 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2198 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2199 else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2200 // Unreachable because SHELL is dependant on the others\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2201 throw 'Unknown runtime environment. Where are we?';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2202 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2203 function globalEval(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2204 eval.call(null, x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2205 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2206 if (!Module['load'] == 'undefined' && Module['read']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2207 Module['load'] = function(f) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2208 globalEval(Module['read'](f));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2209 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2210 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2211 if (!Module['print']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2212 Module['print'] = function(){};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2213 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2214 if (!Module['printErr']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2215 Module['printErr'] = Module['print'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2216 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2217 if (!Module['arguments']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2218 Module['arguments'] = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2219 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2220 // *** Environment setup code ***\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2221 // Closure helpers\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2222 Module.print = Module['print'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2223 Module.printErr = Module['printErr'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2224 // Callbacks\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2225 Module['preRun'] = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2226 Module['postRun'] = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2227 // Merge back in the overrides\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2228 for (var key in moduleOverrides) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2229 if (moduleOverrides.hasOwnProperty(key)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2230 Module[key] = moduleOverrides[key];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2231 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2232 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2233 // === Auto-generated preamble library stuff ===\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2234 //========================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2235 // Runtime code shared with compiler\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2236 //========================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2237 var Runtime = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2238 stackSave: function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2239 return STACKTOP;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2240 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2241 stackRestore: function (stackTop) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2242 STACKTOP = stackTop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2243 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2244 forceAlign: function (target, quantum) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2245 quantum = quantum || 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2246 if (quantum == 1) return target;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2247 if (isNumber(target) && isNumber(quantum)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2248 return Math.ceil(target/quantum)*quantum;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2249 } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2250 var logg = log2(quantum);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2251 return '((((' +target + ')+' + (quantum-1) + ')>>' + logg + ')<<' + logg + ')';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2252 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2253 return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2254 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2255 isNumberType: function (type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2256 return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2257 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2258 isPointerType: function isPointerType(type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2259 return type[type.length-1] == '*';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2260 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2261 isStructType: function isStructType(type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2262 if (isPointerType(type)) return false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2263 if (isArrayType(type)) return true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2264 if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2265 // See comment in isStructPointerType()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2266 return type[0] == '%';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2267 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2268 INT_TYPES: {\"i1\":0,\"i8\":0,\"i16\":0,\"i32\":0,\"i64\":0},\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2269 FLOAT_TYPES: {\"float\":0,\"double\":0},\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2270 or64: function (x, y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2271 var l = (x | 0) | (y | 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2272 var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2273 return l + h;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2274 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2275 and64: function (x, y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2276 var l = (x | 0) & (y | 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2277 var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2278 return l + h;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2279 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2280 xor64: function (x, y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2281 var l = (x | 0) ^ (y | 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2282 var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2283 return l + h;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2284 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2285 getNativeTypeSize: function (type, quantumSize) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2286 if (Runtime.QUANTUM_SIZE == 1) return 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2287 var size = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2288 '%i1': 1,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2289 '%i8': 1,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2290 '%i16': 2,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2291 '%i32': 4,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2292 '%i64': 8,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2293 \"%float\": 4,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2294 \"%double\": 8\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2295 }['%'+type]; // add '%' since float and double confuse Closure compiler as keys, and also spidermonkey as a compiler will remove 's from '_i8' etc\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2296 if (!size) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2297 if (type.charAt(type.length-1) == '*') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2298 size = Runtime.QUANTUM_SIZE; // A pointer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2299 } else if (type[0] == 'i') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2300 var bits = parseInt(type.substr(1));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2301 assert(bits % 8 == 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2302 size = bits/8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2303 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2304 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2305 return size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2306 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2307 getNativeFieldSize: function (type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2308 return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2309 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2310 dedup: function dedup(items, ident) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2311 var seen = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2312 if (ident) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2313 return items.filter(function(item) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2314 if (seen[item[ident]]) return false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2315 seen[item[ident]] = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2316 return true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2317 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2318 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2319 return items.filter(function(item) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2320 if (seen[item]) return false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2321 seen[item] = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2322 return true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2323 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2324 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2325 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2326 set: function set() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2327 var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2328 var ret = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2329 for (var i = 0; i < args.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2330 ret[args[i]] = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2331 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2332 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2333 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2334 STACK_ALIGN: 8,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2335 getAlignSize: function (type, size, vararg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2336 // we align i64s and doubles on 64-bit boundaries, unlike x86\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2337 if (type == 'i64' || type == 'double' || vararg) return 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2338 if (!type) return Math.min(size, 8); // align structures internally to 64 bits\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2339 return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2340 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2341 calculateStructAlignment: function calculateStructAlignment(type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2342 type.flatSize = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2343 type.alignSize = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2344 var diffs = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2345 var prev = -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2346 var index = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2347 type.flatIndexes = type.fields.map(function(field) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2348 index++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2349 var size, alignSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2350 if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2351 size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2352 alignSize = Runtime.getAlignSize(field, size);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2353 } else if (Runtime.isStructType(field)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2354 if (field[1] === '0') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2355 // this is [0 x something]. When inside another structure like here, it must be at the end,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2356 // and it adds no size\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2357 // XXX this happens in java-nbody for example... assert(index === type.fields.length, 'zero-length in the middle!');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2358 size = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2359 if (Types.types[field]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2360 alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2361 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2362 alignSize = type.alignSize || QUANTUM_SIZE;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2363 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2364 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2365 size = Types.types[field].flatSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2366 alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2367 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2368 } else if (field[0] == 'b') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2369 // bN, large number field, like a [N x i8]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2370 size = field.substr(1)|0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2371 alignSize = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2372 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2373 throw 'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Types.types[type.name_]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2374 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2375 if (type.packed) alignSize = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2376 type.alignSize = Math.max(type.alignSize, alignSize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2377 var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2378 type.flatSize = curr + size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2379 if (prev >= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2380 diffs.push(curr-prev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2381 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2382 prev = curr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2383 return curr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2384 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2385 type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2386 if (diffs.length == 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2387 type.flatFactor = type.flatSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2388 } else if (Runtime.dedup(diffs).length == 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2389 type.flatFactor = diffs[0];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2390 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2391 type.needsFlattening = (type.flatFactor != 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2392 return type.flatIndexes;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2393 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2394 generateStructInfo: function (struct, typeName, offset) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2395 var type, alignment;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2396 if (typeName) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2397 offset = offset || 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2398 type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2399 if (!type) return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2400 if (type.fields.length != struct.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2401 printErr('Number of named fields must match the type for ' + typeName + ': possibly duplicate struct names. Cannot return structInfo');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2402 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2403 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2404 alignment = type.flatIndexes;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2405 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2406 var type = { fields: struct.map(function(item) { return item[0] }) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2407 alignment = Runtime.calculateStructAlignment(type);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2408 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2409 var ret = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2410 __size__: type.flatSize\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2411 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2412 if (typeName) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2413 struct.forEach(function(item, i) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2414 if (typeof item === 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2415 ret[item] = alignment[i] + offset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2416 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2417 // embedded struct\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2418 var key;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2419 for (var k in item) key = k;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2420 ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2421 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2422 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2423 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2424 struct.forEach(function(item, i) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2425 ret[item[1]] = alignment[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2426 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2427 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2428 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2429 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2430 dynCall: function (sig, ptr, args) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2431 if (args && args.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2432 if (!args.splice) args = Array.prototype.slice.call(args);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2433 args.splice(0, 0, ptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2434 return Module['dynCall_' + sig].apply(null, args);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2435 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2436 return Module['dynCall_' + sig].call(null, ptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2437 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2438 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2439 functionPointers: [null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2440 addFunction: function (func) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2441 for (var i = 0; i < Runtime.functionPointers.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2442 if (!Runtime.functionPointers[i]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2443 Runtime.functionPointers[i] = func;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2444 return 2 + 2*i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2445 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2446 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2447 throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2448 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2449 removeFunction: function (index) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2450 Runtime.functionPointers[(index-2)/2] = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2451 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2452 warnOnce: function (text) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2453 if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2454 if (!Runtime.warnOnce.shown[text]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2455 Runtime.warnOnce.shown[text] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2456 Module.printErr(text);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2457 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2458 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2459 funcWrappers: {},\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2460 getFuncWrapper: function (func, sig) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2461 assert(sig);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2462 if (!Runtime.funcWrappers[func]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2463 Runtime.funcWrappers[func] = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2464 return Runtime.dynCall(sig, func, arguments);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2465 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2466 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2467 return Runtime.funcWrappers[func];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2468 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2469 UTF8Processor: function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2470 var buffer = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2471 var needed = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2472 this.processCChar = function (code) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2473 code = code & 0xFF;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2474 if (buffer.length == 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2475 if ((code & 0x80) == 0x00) { // 0xxxxxxx\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2476 return String.fromCharCode(code);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2477 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2478 buffer.push(code);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2479 if ((code & 0xE0) == 0xC0) { // 110xxxxx\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2480 needed = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2481 } else if ((code & 0xF0) == 0xE0) { // 1110xxxx\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2482 needed = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2483 } else { // 11110xxx\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2484 needed = 3;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2485 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2486 return '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2487 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2488 if (needed) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2489 buffer.push(code);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2490 needed--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2491 if (needed > 0) return '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2492 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2493 var c1 = buffer[0];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2494 var c2 = buffer[1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2495 var c3 = buffer[2];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2496 var c4 = buffer[3];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2497 var ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2498 if (buffer.length == 2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2499 ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2500 } else if (buffer.length == 3) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2501 ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2502 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2503 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2504 var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2505 ((c3 & 0x3F) << 6) | (c4 & 0x3F);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2506 ret = String.fromCharCode(\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2507 Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2508 (codePoint - 0x10000) % 0x400 + 0xDC00);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2509 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2510 buffer.length = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2511 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2512 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2513 this.processJSString = function(string) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2514 string = unescape(encodeURIComponent(string));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2515 var ret = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2516 for (var i = 0; i < string.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2517 ret.push(string.charCodeAt(i));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2518 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2519 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2520 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2521 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2522 stackAlloc: function (size) { var ret = STACKTOP;STACKTOP = (STACKTOP + size)|0;STACKTOP = ((((STACKTOP)+7)>>3)<<3); return ret; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2523 staticAlloc: function (size) { var ret = STATICTOP;STATICTOP = (STATICTOP + size)|0;STATICTOP = ((((STATICTOP)+7)>>3)<<3); return ret; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2524 dynamicAlloc: function (size) { var ret = DYNAMICTOP;DYNAMICTOP = (DYNAMICTOP + size)|0;DYNAMICTOP = ((((DYNAMICTOP)+7)>>3)<<3); if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2525 alignMemory: function (size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 8))*(quantum ? quantum : 8); return ret; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2526 makeBigInt: function (low,high,unsigned) { var ret = (unsigned ? ((+(((low)>>>(0))))+((+(((high)>>>(0))))*(+(4294967296)))) : ((+(((low)>>>(0))))+((+(((high)|(0))))*(+(4294967296))))); return ret; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2527 GLOBAL_BASE: 8,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2528 QUANTUM_SIZE: 4,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2529 __dummy__: 0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2530 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2531 function jsCall() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2532 var args = Array.prototype.slice.call(arguments);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2533 return Runtime.functionPointers[args[0]].apply(null, args.slice(1));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2534 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2535 //========================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2536 // Runtime essentials\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2537 //========================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2538 var __THREW__ = 0; // Used in checking for thrown exceptions.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2539 var ABORT = false; // whether we are quitting the application. no code should run after this. set in exit() and abort()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2540 var EXITSTATUS = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2541 var undef = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2542 // tempInt is used for 32-bit signed values or smaller. tempBigInt is used\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2543 // for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2544 var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2545 var tempI64, tempI64b;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2546 var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2547 function assert(condition, text) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2548 if (!condition) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2549 abort('Assertion failed: ' + text);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2550 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2551 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2552 var globalScope = this;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2553 // C calling interface. A convenient way to call C functions (in C files, or\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2554 // defined with extern \"C\").\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2555 //\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2556 // Note: LLVM optimizations can inline and remove functions, after which you will not be\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2557 // able to call them. Closure can also do so. To avoid that, add your function to\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2558 // the exports using something like\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2559 //\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2560 // -s EXPORTED_FUNCTIONS='[\"_main\", \"_myfunc\"]'\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2561 //\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2562 // @param ident The name of the C function (note that C++ functions will be name-mangled - use extern \"C\")\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2563 // @param returnType The return type of the function, one of the JS types 'number', 'string' or 'array' (use 'number' for any C pointer, and\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2564 // 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2565 // @param argTypes An array of the types of arguments for the function (if there are no arguments, this can be ommitted). Types are as in returnType,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2566 // except that 'array' is not possible (there is no way for us to know the length of the array)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2567 // @param args An array of the arguments to the function, as native JS values (as in returnType)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2568 // Note that string arguments will be stored on the stack (the JS string will become a C string on the stack).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2569 // @return The return value, as a native JS value (as in returnType)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2570 function ccall(ident, returnType, argTypes, args) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2571 return ccallFunc(getCFunc(ident), returnType, argTypes, args);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2572 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2573 Module[\"ccall\"] = ccall;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2574 // Returns the C function with a specified identifier (for C++, you need to do manual name mangling)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2575 function getCFunc(ident) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2576 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2577 var func = Module['_' + ident]; // closure exported function\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2578 if (!func) func = eval('_' + ident); // explicit lookup\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2579 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2580 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2581 assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2582 return func;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2583 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2584 // Internal function that does a C call using a function, not an identifier\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2585 function ccallFunc(func, returnType, argTypes, args) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2586 var stack = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2587 function toC(value, type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2588 if (type == 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2589 if (value === null || value === undefined || value === 0) return 0; // null string\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2590 if (!stack) stack = Runtime.stackSave();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2591 var ret = Runtime.stackAlloc(value.length+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2592 writeStringToMemory(value, ret);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2593 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2594 } else if (type == 'array') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2595 if (!stack) stack = Runtime.stackSave();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2596 var ret = Runtime.stackAlloc(value.length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2597 writeArrayToMemory(value, ret);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2598 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2599 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2600 return value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2601 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2602 function fromC(value, type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2603 if (type == 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2604 return Pointer_stringify(value);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2605 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2606 assert(type != 'array');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2607 return value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2608 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2609 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2610 var cArgs = args ? args.map(function(arg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2611 return toC(arg, argTypes[i++]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2612 }) : [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2613 var ret = fromC(func.apply(null, cArgs), returnType);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2614 if (stack) Runtime.stackRestore(stack);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2615 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2616 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2617 // Returns a native JS wrapper for a C function. This is similar to ccall, but\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2618 // returns a function you can call repeatedly in a normal way. For example:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2619 //\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2620 // var my_function = cwrap('my_c_function', 'number', ['number', 'number']);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2621 // alert(my_function(5, 22));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2622 // alert(my_function(99, 12));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2623 //\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2624 function cwrap(ident, returnType, argTypes) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2625 var func = getCFunc(ident);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2626 return function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2627 return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2628 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2629 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2630 Module[\"cwrap\"] = cwrap;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2631 // Sets a value in memory in a dynamic way at run-time. Uses the\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2632 // type data. This is the same as makeSetValue, except that\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2633 // makeSetValue is done at compile-time and generates the needed\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2634 // code then, whereas this function picks the right code at\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2635 // run-time.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2636 // Note that setValue and getValue only do *aligned* writes and reads!\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2637 // Note that ccall uses JS types as for defining types, while setValue and\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2638 // getValue need LLVM types ('i8', 'i32') - this is a lower-level operation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2639 function setValue(ptr, value, type, noSafe) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2640 type = type || 'i8';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2641 if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2642 switch(type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2643 case 'i1': HEAP8[(ptr)]=value; break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2644 case 'i8': HEAP8[(ptr)]=value; break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2645 case 'i16': HEAP16[((ptr)>>1)]=value; break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2646 case 'i32': HEAP32[((ptr)>>2)]=value; break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2647 case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math.abs(tempDouble))) >= (+(1)) ? (tempDouble > (+(0)) ? ((Math.min((+(Math.floor((tempDouble)/(+(4294967296))))), (+(4294967295))))|0)>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+(4294967296)))))))>>>0) : 0)],HEAP32[((ptr)>>2)]=tempI64[0],HEAP32[(((ptr)+(4))>>2)]=tempI64[1]); break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2648 case 'float': HEAPF32[((ptr)>>2)]=value; break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2649 case 'double': HEAPF64[((ptr)>>3)]=value; break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2650 default: abort('invalid type for setValue: ' + type);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2651 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2652 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2653 Module['setValue'] = setValue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2654 // Parallel to setValue.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2655 function getValue(ptr, type, noSafe) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2656 type = type || 'i8';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2657 if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2658 switch(type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2659 case 'i1': return HEAP8[(ptr)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2660 case 'i8': return HEAP8[(ptr)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2661 case 'i16': return HEAP16[((ptr)>>1)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2662 case 'i32': return HEAP32[((ptr)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2663 case 'i64': return HEAP32[((ptr)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2664 case 'float': return HEAPF32[((ptr)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2665 case 'double': return HEAPF64[((ptr)>>3)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2666 default: abort('invalid type for setValue: ' + type);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2667 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2668 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2669 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2670 Module['getValue'] = getValue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2671 var ALLOC_NORMAL = 0; // Tries to use _malloc()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2672 var ALLOC_STACK = 1; // Lives for the duration of the current function call\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2673 var ALLOC_STATIC = 2; // Cannot be freed\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2674 var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2675 var ALLOC_NONE = 4; // Do not allocate\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2676 Module['ALLOC_NORMAL'] = ALLOC_NORMAL;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2677 Module['ALLOC_STACK'] = ALLOC_STACK;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2678 Module['ALLOC_STATIC'] = ALLOC_STATIC;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2679 Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2680 Module['ALLOC_NONE'] = ALLOC_NONE;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2681 // allocate(): This is for internal use. You can use it yourself as well, but the interface\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2682 // is a little tricky (see docs right below). The reason is that it is optimized\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2683 // for multiple syntaxes to save space in generated code. So you should\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2684 // normally not use allocate(), and instead allocate memory using _malloc(),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2685 // initialize it with setValue(), and so forth.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2686 // @slab: An array of data, or a number. If a number, then the size of the block to allocate,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2687 // in *bytes* (note that this is sometimes confusing: the next parameter does not\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2688 // affect this!)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2689 // @types: Either an array of types, one for each byte (or 0 if no type at that position),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2690 // or a single type which is used for the entire block. This only matters if there\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2691 // is initial data - if @slab is a number, then this does not matter at all and is\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2692 // ignored.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2693 // @allocator: How to allocate memory, see ALLOC_*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2694 function allocate(slab, types, allocator, ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2695 var zeroinit, size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2696 if (typeof slab === 'number') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2697 zeroinit = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2698 size = slab;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2699 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2700 zeroinit = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2701 size = slab.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2702 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2703 var singleType = typeof types === 'string' ? types : null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2704 var ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2705 if (allocator == ALLOC_NONE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2706 ret = ptr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2707 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2708 ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc, Runtime.dynamicAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2709 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2710 if (zeroinit) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2711 var ptr = ret, stop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2712 assert((ret & 3) == 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2713 stop = ret + (size & ~3);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2714 for (; ptr < stop; ptr += 4) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2715 HEAP32[((ptr)>>2)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2716 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2717 stop = ret + size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2718 while (ptr < stop) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2719 HEAP8[((ptr++)|0)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2720 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2721 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2722 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2723 if (singleType === 'i8') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2724 if (slab.subarray || slab.slice) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2725 HEAPU8.set(slab, ret);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2726 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2727 HEAPU8.set(new Uint8Array(slab), ret);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2728 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2729 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2730 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2731 var i = 0, type, typeSize, previousType;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2732 while (i < size) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2733 var curr = slab[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2734 if (typeof curr === 'function') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2735 curr = Runtime.getFunctionIndex(curr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2736 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2737 type = singleType || types[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2738 if (type === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2739 i++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2740 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2741 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2742 if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2743 setValue(ret+i, curr, type);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2744 // no need to look up size unless type changes, so cache it\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2745 if (previousType !== type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2746 typeSize = Runtime.getNativeTypeSize(type);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2747 previousType = type;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2748 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2749 i += typeSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2750 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2751 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2752 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2753 Module['allocate'] = allocate;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2754 function Pointer_stringify(ptr, /* optional */ length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2755 // TODO: use TextDecoder\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2756 // Find the length, and check for UTF while doing so\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2757 var hasUtf = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2758 var t;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2759 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2760 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2761 t = HEAPU8[(((ptr)+(i))|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2762 if (t >= 128) hasUtf = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2763 else if (t == 0 && !length) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2764 i++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2765 if (length && i == length) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2766 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2767 if (!length) length = i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2768 var ret = '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2769 if (!hasUtf) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2770 var MAX_CHUNK = 1024; // split up into chunks, because .apply on a huge string can overflow the stack\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2771 var curr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2772 while (length > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2773 curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2774 ret = ret ? ret + curr : curr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2775 ptr += MAX_CHUNK;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2776 length -= MAX_CHUNK;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2777 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2778 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2779 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2780 var utf8 = new Runtime.UTF8Processor();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2781 for (i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2782 t = HEAPU8[(((ptr)+(i))|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2783 ret += utf8.processCChar(t);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2784 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2785 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2786 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2787 Module['Pointer_stringify'] = Pointer_stringify;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2788 // Given a pointer 'ptr' to a null-terminated UTF16LE-encoded string in the emscripten HEAP, returns\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2789 // a copy of that string as a Javascript String object.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2790 function UTF16ToString(ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2791 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2792 var str = '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2793 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2794 var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2795 if (codeUnit == 0)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2796 return str;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2797 ++i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2798 // fromCharCode constructs a character from a UTF-16 code unit, so we can pass the UTF16 string right through.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2799 str += String.fromCharCode(codeUnit);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2800 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2801 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2802 Module['UTF16ToString'] = UTF16ToString;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2803 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2804 // null-terminated and encoded in UTF16LE form. The copy will require at most (str.length*2+1)*2 bytes of space in the HEAP.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2805 function stringToUTF16(str, outPtr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2806 for(var i = 0; i < str.length; ++i) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2807 // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2808 var codeUnit = str.charCodeAt(i); // possibly a lead surrogate\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2809 HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2810 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2811 // Null-terminate the pointer to the HEAP.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2812 HEAP16[(((outPtr)+(str.length*2))>>1)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2813 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2814 Module['stringToUTF16'] = stringToUTF16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2815 // Given a pointer 'ptr' to a null-terminated UTF32LE-encoded string in the emscripten HEAP, returns\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2816 // a copy of that string as a Javascript String object.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2817 function UTF32ToString(ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2818 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2819 var str = '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2820 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2821 var utf32 = HEAP32[(((ptr)+(i*4))>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2822 if (utf32 == 0)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2823 return str;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2824 ++i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2825 // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2826 if (utf32 >= 0x10000) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2827 var ch = utf32 - 0x10000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2828 str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2829 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2830 str += String.fromCharCode(utf32);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2831 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2832 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2833 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2834 Module['UTF32ToString'] = UTF32ToString;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2835 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2836 // null-terminated and encoded in UTF32LE form. The copy will require at most (str.length+1)*4 bytes of space in the HEAP,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2837 // but can use less, since str.length does not return the number of characters in the string, but the number of UTF-16 code units in the string.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2838 function stringToUTF32(str, outPtr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2839 var iChar = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2840 for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2841 // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2842 var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2843 if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2844 var trailSurrogate = str.charCodeAt(++iCodeUnit);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2845 codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2846 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2847 HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2848 ++iChar;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2849 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2850 // Null-terminate the pointer to the HEAP.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2851 HEAP32[(((outPtr)+(iChar*4))>>2)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2852 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2853 Module['stringToUTF32'] = stringToUTF32;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2854 // Memory management\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2855 var PAGE_SIZE = 4096;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2856 function alignMemoryPage(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2857 return ((x+4095)>>12)<<12;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2858 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2859 var HEAP;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2860 var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2861 var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2862 var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2863 var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2864 function enlargeMemory() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2865 abort('Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value ' + TOTAL_MEMORY + ', or (2) set Module.TOTAL_MEMORY before the program runs.');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2866 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2867 var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2868 var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 16777216;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2869 var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2870 // Initialize the runtime's memory\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2871 // check for full engine support (use string 'subarray' to avoid closure compiler confusion)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2872 assert(!!Int32Array && !!Float64Array && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2873 'Cannot fallback to non-typed array case: Code is too specialized');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2874 var buffer = new ArrayBuffer(TOTAL_MEMORY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2875 HEAP8 = new Int8Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2876 HEAP16 = new Int16Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2877 HEAP32 = new Int32Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2878 HEAPU8 = new Uint8Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2879 HEAPU16 = new Uint16Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2880 HEAPU32 = new Uint32Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2881 HEAPF32 = new Float32Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2882 HEAPF64 = new Float64Array(buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2883 // Endianness check (note: assumes compiler arch was little-endian)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2884 HEAP32[0] = 255;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2885 assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2886 Module['HEAP'] = HEAP;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2887 Module['HEAP8'] = HEAP8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2888 Module['HEAP16'] = HEAP16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2889 Module['HEAP32'] = HEAP32;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2890 Module['HEAPU8'] = HEAPU8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2891 Module['HEAPU16'] = HEAPU16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2892 Module['HEAPU32'] = HEAPU32;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2893 Module['HEAPF32'] = HEAPF32;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2894 Module['HEAPF64'] = HEAPF64;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2895 function callRuntimeCallbacks(callbacks) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2896 while(callbacks.length > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2897 var callback = callbacks.shift();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2898 if (typeof callback == 'function') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2899 callback();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2900 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2901 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2902 var func = callback.func;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2903 if (typeof func === 'number') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2904 if (callback.arg === undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2905 Runtime.dynCall('v', func);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2906 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2907 Runtime.dynCall('vi', func, [callback.arg]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2908 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2909 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2910 func(callback.arg === undefined ? null : callback.arg);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2911 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2912 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2913 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2914 var __ATPRERUN__ = []; // functions called before the runtime is initialized\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2915 var __ATINIT__ = []; // functions called during startup\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2916 var __ATMAIN__ = []; // functions called when main() is to be run\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2917 var __ATEXIT__ = []; // functions called during shutdown\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2918 var __ATPOSTRUN__ = []; // functions called after the runtime has exited\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2919 var runtimeInitialized = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2920 function preRun() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2921 // compatibility - merge in anything from Module['preRun'] at this time\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2922 if (Module['preRun']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2923 if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2924 while (Module['preRun'].length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2925 addOnPreRun(Module['preRun'].shift());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2926 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2927 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2928 callRuntimeCallbacks(__ATPRERUN__);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2929 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2930 function ensureInitRuntime() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2931 if (runtimeInitialized) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2932 runtimeInitialized = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2933 callRuntimeCallbacks(__ATINIT__);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2934 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2935 function preMain() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2936 callRuntimeCallbacks(__ATMAIN__);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2937 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2938 function exitRuntime() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2939 callRuntimeCallbacks(__ATEXIT__);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2940 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2941 function postRun() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2942 // compatibility - merge in anything from Module['postRun'] at this time\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2943 if (Module['postRun']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2944 if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2945 while (Module['postRun'].length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2946 addOnPostRun(Module['postRun'].shift());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2947 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2948 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2949 callRuntimeCallbacks(__ATPOSTRUN__);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2950 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2951 function addOnPreRun(cb) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2952 __ATPRERUN__.unshift(cb);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2953 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2954 Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2955 function addOnInit(cb) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2956 __ATINIT__.unshift(cb);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2957 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2958 Module['addOnInit'] = Module.addOnInit = addOnInit;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2959 function addOnPreMain(cb) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2960 __ATMAIN__.unshift(cb);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2961 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2962 Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2963 function addOnExit(cb) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2964 __ATEXIT__.unshift(cb);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2965 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2966 Module['addOnExit'] = Module.addOnExit = addOnExit;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2967 function addOnPostRun(cb) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2968 __ATPOSTRUN__.unshift(cb);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2969 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2970 Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2971 // Tools\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2972 // This processes a JS string into a C-line array of numbers, 0-terminated.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2973 // For LLVM-originating strings, see parser.js:parseLLVMString function\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2974 function intArrayFromString(stringy, dontAddNull, length /* optional */) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2975 var ret = (new Runtime.UTF8Processor()).processJSString(stringy);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2976 if (length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2977 ret.length = length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2978 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2979 if (!dontAddNull) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2980 ret.push(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2981 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2982 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2983 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2984 Module['intArrayFromString'] = intArrayFromString;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2985 function intArrayToString(array) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2986 var ret = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2987 for (var i = 0; i < array.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2988 var chr = array[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2989 if (chr > 0xFF) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2990 chr &= 0xFF;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2991 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2992 ret.push(String.fromCharCode(chr));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2993 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2994 return ret.join('');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2995 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2996 Module['intArrayToString'] = intArrayToString;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2997 // Write a Javascript array to somewhere in the heap\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2998 function writeStringToMemory(string, buffer, dontAddNull) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2999 var array = intArrayFromString(string, dontAddNull);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3000 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3001 while (i < array.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3002 var chr = array[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3003 HEAP8[(((buffer)+(i))|0)]=chr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3004 i = i + 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3005 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3006 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3007 Module['writeStringToMemory'] = writeStringToMemory;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3008 function writeArrayToMemory(array, buffer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3009 for (var i = 0; i < array.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3010 HEAP8[(((buffer)+(i))|0)]=array[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3011 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3012 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3013 Module['writeArrayToMemory'] = writeArrayToMemory;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3014 function unSign(value, bits, ignore, sig) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3015 if (value >= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3016 return value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3017 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3018 return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3019 : Math.pow(2, bits) + value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3020 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3021 function reSign(value, bits, ignore, sig) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3022 if (value <= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3023 return value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3024 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3025 var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3026 : Math.pow(2, bits-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3027 if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3028 // but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3029 // TODO: In i64 mode 1, resign the two parts separately and safely\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3030 value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3031 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3032 return value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3033 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3034 if (!Math['imul']) Math['imul'] = function(a, b) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3035 var ah = a >>> 16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3036 var al = a & 0xffff;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3037 var bh = b >>> 16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3038 var bl = b & 0xffff;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3039 return (al*bl + ((ah*bl + al*bh) << 16))|0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3040 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3041 Math.imul = Math['imul'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3042 // A counter of dependencies for calling run(). If we need to\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3043 // do asynchronous work before running, increment this and\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3044 // decrement it. Incrementing must happen in a place like\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3045 // PRE_RUN_ADDITIONS (used by emcc to add file preloading).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3046 // Note that you can add dependencies in preRun, even though\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3047 // it happens right before run - run will be postponed until\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3048 // the dependencies are met.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3049 var runDependencies = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3050 var runDependencyTracking = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3051 var calledInit = false, calledRun = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3052 var runDependencyWatcher = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3053 function addRunDependency(id) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3054 runDependencies++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3055 if (Module['monitorRunDependencies']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3056 Module['monitorRunDependencies'](runDependencies);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3057 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3058 if (id) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3059 assert(!runDependencyTracking[id]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3060 runDependencyTracking[id] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3061 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3062 Module.printErr('warning: run dependency added without ID');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3063 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3064 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3065 Module['addRunDependency'] = addRunDependency;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3066 function removeRunDependency(id) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3067 runDependencies--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3068 if (Module['monitorRunDependencies']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3069 Module['monitorRunDependencies'](runDependencies);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3070 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3071 if (id) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3072 assert(runDependencyTracking[id]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3073 delete runDependencyTracking[id];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3074 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3075 Module.printErr('warning: run dependency removed without ID');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3076 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3077 if (runDependencies == 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3078 if (runDependencyWatcher !== null) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3079 clearInterval(runDependencyWatcher);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3080 runDependencyWatcher = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3081 } \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3082 // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3083 if (!calledRun && shouldRunNow) run();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3084 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3085 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3086 Module['removeRunDependency'] = removeRunDependency;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3087 Module[\"preloadedImages\"] = {}; // maps url to image data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3088 Module[\"preloadedAudios\"] = {}; // maps url to audio data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3089 function loadMemoryInitializer(filename) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3090 function applyData(data) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3091 HEAPU8.set(data, STATIC_BASE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3092 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3093 // always do this asynchronously, to keep shell and web as similar as possible\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3094 addOnPreRun(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3095 if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3096 applyData(Module['readBinary'](filename));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3097 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3098 Browser.asyncLoad(filename, function(data) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3099 applyData(data);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3100 }, function(data) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3101 throw 'could not load memory initializer ' + filename;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3102 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3103 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3104 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3105 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3106 // === Body ===\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3107 STATIC_BASE = 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3108 STATICTOP = STATIC_BASE + 11056;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3109 /* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3110 var _stdout;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3111 var _stdin;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3112 var _stderr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3113 var _stdout = _stdout=allocate([0,0,0,0,0,0,0,0], \"i8\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3114 var _stdin = _stdin=allocate([0,0,0,0,0,0,0,0], \"i8\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3115 var _stderr = _stderr=allocate([0,0,0,0,0,0,0,0], \"i8\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3116 /* memory initializer */ allocate([16,36,0,0,244,1,0,0,64,28,0,0,2,2,0,0,0,22,0,0,0,2,0,0,88,17,0,0,28,2,0,0,208,14,0,0,210,1,0,0,128,12,0,0,80,1,0,0,152,10,0,0,172,1,0,0,64,9,0,0,102,1,0,0,104,8,0,0,40,2,0,0,0,0,0,0,0,0,0,0,80,36,0,0,34,1,0,0,200,28,0,0,4,2,0,0,32,22,0,0,180,1,0,0,112,17,0,0,36,2,0,0,224,14,0,0,6,2,0,0,136,12,0,0,214,1,0,0,160,10,0,0,52,1,0,0,72,9,0,0,242,1,0,0,112,8,0,0,194,1,0,0,56,40,0,0,46,1,0,0,144,39,0,0,108,1,0,0,0,0,0,0,0,0,0,0,200,14,0,0,192,1,0,0,120,12,0,0,44,1,0,0,144,10,0,0,86,1,0,0,56,9,0,0,56,1,0,0,96,8,0,0,116,1,0,0,24,28,0,0,168,1,0,0,224,35,0,0,98,1,0,0,48,40,0,0,122,1,0,0,72,39,0,0,234,1,0,0,40,38,0,0,184,1,0,0,96,37,0,0,62,1,0,0,136,36,0,0,106,1,0,0,216,35,0,0,42,1,0,0,88,35,0,0,226,1,0,0,224,34,0,0,82,1,0,0,0,0,0,0,0,0,0,0,32,23,0,0,96,40,0,0,184,39,0,0,160,38,0,0,6,6,6,6,7,7,7,7,7,7,10,9,5,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,1,1,0,0,0,0,0,0,0,0,36,64,0,0,0,0,0,0,89,64,0,0,0,0,0,136,195,64,0,0,0,0,132,215,151,65,0,128,224,55,121,195,65,67,23,110,5,181,181,184,147,70,245,249,63,233,3,79,56,77,50,29,48,249,72,119,130,90,60,191,115,127,221,79,21,117,128,16,0,0,16,2,0,0,80,16,0,0,20,2,0,0,0,0,0,0,0,0,0,0,240,31,0,0,216,30,0,0,200,29,0,0,40,29,0,0,32,28,0,0,56,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,0,15,0,0,16,1,0,0,144,12,0,0,22,1,0,0,184,10,0,0,104,1,0,0,80,9,0,0,138,1,0,0,128,8,0,0,6,1,0,0,64,40,0,0,160,1,0,0,152,39,0,0,32,2,0,0,128,38,0,0,164,1,0,0,152,37,0,0,58,1,0,0,208,36,0,0,78,1,0,0,0,36,0,0,74,1,0,0,80,22,0,0,204,1,0,0,104,35,0,0,158,1,0,0,240,34,0,0,208,1,0,0,88,34,0,0,10,1,0,0,120,33,0,0,222,1,0,0,216,32,0,0,190,1,0,0,248,31,0,0,186,1,0,0,224,30,0,0,92,1,0,0,208,29,0,0,144,1,0,0,56,29,0,0,66,1,0,0,40,28,0,0,126,1,0,0,128,27,0,0,196,1,0,0,208,26,0,0,14,1,0,0,104,26,0,0,254,1,0,0,0,26,0,0,30,2,0,0,96,25,0,0,166,1,0,0,192,24,0,0,150,1,0,0,0,0,0,0,0,0,0,0,24,13,0,0,128,35,0,0,120,27,0,0,128,21,0,0,168,16,0,0,152,14,0,0,216,11,0,0,96,10,0,0,24,9,0,0,16,8,0,0,24,40,0,0,56,39,0,0,16,38,0,0,72,37,0,0,112,36,0,0,200,35,0,0,72,35,0,0,168,34,0,0,248,33,0,0,56,33,0,0,112,32,0,0,120,31,0,0,96,31,0,0,128,30,0,0,136,29,0,0,208,28,0,0,56,27,0,0,40,27,0,0,152,26,0,0,32,26,0,0,184,25,0,0,0,0,0,0,128,31,0,0,216,38,0,0,64,31,0,0,56,24,0,0,232,18,0,0,168,15,0,0,104,13,0,0,64,31,0,0,72,11,0,0,240,9,0,0,200,8,0,0,0,0,0,0,136,40,0,0,216,39,0,0,184,38,0,0,224,37,0,0,32,37,0,0,48,36,0,0,176,35,0,0,32,35,0,0,128,34,0,0,176,33,0,0,0,33,0,0,40,32,0,0,56,31,0,0,96,30,0,0,112,29,0,0,136,28,0,0,192,27,0,0,0,0,0,0,96,113,84,96,80,113,108,49,16,60,84,108,124,124,124,124,124,124,96,96,96,104,34,188,188,188,228,228,84,84,16,98,98,132,20,0,81,80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,5,0,0,0,6,0,0,0,7,0,0,0,0,0,0,0,120,11,0,0,112,11,0,0,80,11,0,0,8,11,0,0,200,10,0,0,168,10,0,0,128,10,0,0,0,0,0,0,208,35,0,0,46,2,0,0,80,35,0,0,118,1,0,0,0,0,0,0,0,0,0,0,136,8,0,0,120,1,0,0,72,40,0,0,42,2,0,0,160,39,0,0,10,2,0,0,136,38,0,0,84,1,0,0,160,37,0,0,220,1,0,0,216,36,0,0,170,1,0,0,200,17,0,0,154,1,0,0,8,36,0,0,206,1,0,0,112,35,0,0,50,1,0,0,248,34,0,0,252,1,0,0,96,34,0,0,2,1,0,0,0,0,0,0,0,0,0,0,136,26,0,0,16,26,0,0,136,25,0,0,224,24,0,0,248,23,0,0,0,0,0,0,136,8,0,0,120,1,0,0,72,40,0,0,200,1,0,0,136,38,0,0,28,1,0,0,8,36,0,0,130,1,0,0,104,22,0,0,252,0,0,0,248,21,0,0,44,2,0,0,96,34,0,0,38,1,0,0,168,21,0,0,32,1,0,0,32,21,0,0,250,1,0,0,0,0,0,0,0,0,0,0,200,19,0,0,48,19,0,0,200,18,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,18,0,0,168,17,0,0,80,17,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,21,0,0,238,1,0,0,80,37,0,0,54,1,0,0,144,29,0,0,18,1,0,0,152,22,0,0,88,1,0,0,232,17,0,0,36,1,0,0,48,15,0,0,198,1,0,0,208,12,0,0,4,1,0,0,208,10,0,0,110,1,0,0,120,9,0,0,176,1,0,0,144,8,0,0,178,1,0,0,80,40,0,0,230,1,0,0,168,39,0,0,90,1,0,0,144,38,0,0,48,1,0,0,168,37,0,0,236,1,0,0,0,0,0,0,0,0,0,0,216,37,0,0,114,1,0,0,88,30,0,0,232,1,0,0,32,23,0,0,136,1,0,0,40,18,0,0,224,1,0,0,64,15,0,0,134,1,0,0,248,12,0,0,174,1,0,0,0,0,0,0,0,0,0,0,88,29,0,0,70,1,0,0,96,28,0,0,18,2,0,0,184,27,0,0,188,1,0,0,248,26,0,0,182,1,0,0,144,26,0,0,152,1,0,0,24,26,0,0,22,2,0,0,144,25,0,0,202,1,0,0,232,24,0,0,212,1,0,0,48,24,0,0,24,2,0,0,16,23,0,0,218,1,0,0,120,22,0,0,8,1,0,0,24,22,0,0,162,1,0,0,216,21,0,0,216,1,0,0,72,21,0,0,12,1,0,0,208,20,0,0,34,2,0,0,104,20,0,0,14,2,0,0,224,19,0,0,8,2,0,0,72,19,0,0,24,1,0,0,216,18,0,0,240,1,0,0,24,18,0,0,112,1,0,0,184,17,0,0,72,1,0,0,104,17,0,0,0,1,0,0,240,16,0,0,228,1,0,0,160,16,0,0,128,1,0,0,0,0,0,0,0,0,0,0,105,102,0,0,0,0,0,0,46,47,63,46,115,111,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,49,47,63,46,115,111,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,49,47,108,111,97,100,97,108,108,46,115,111,0,0,0,0,102,111,114,109,97,116,0,0,115,111,114,116,0,0,0,0,115,101,116,108,111,99,97,108,101,0,0,0,0,0,0,0,97,116,97,110,0,0,0,0,99,108,111,115,101,0,0,0,115,101,116,104,111,111,107,0,116,111,111,32,109,97,110,121,32,114,101,115,117,108,116,115,32,116,111,32,114,101,115,117,109,101,0,0,0,0,0,0,98,97,100,32,104,101,97,100,101,114,0,0,0,0,0,0,117,112,118,97,108,0,0,0,105,116,101,109,115,32,105,110,32,97,32,99,111,110,115,116,114,117,99,116,111,114,0,0,102,105,101,108,100,0,0,0,109,101,109,111,114,121,32,97,108,108,111,99,97,116,105,111,110,32,101,114,114,111,114,58,32,98,108,111,99,107,32,116,111,111,32,98,105,103,0,0,102,117,110,99,116,105,111,110,0,0,0,0,0,0,0,0,76,85,65,95,67,80,65,84,72,0,0,0,0,0,0,0,102,105,110,100,0,0,0,0,115,101,116,110,0,0,0,0,114,101,110,97,109,101,0,0,97,116,97,110,50,0,0,0,99,97,110,110,111,116,32,99,108,111,115,101,32,115,116,97,110,100,97,114,100,32,102,105,108,101,0,0,0,0,0,0,115,101,116,102,101,110,118,0,99,97,110,110,111,116,32,114,101,115,117,109,101,32,37,115,32,99,111,114,111,117,116,105,110,101,0,0,0,0,0,0,37,115,58,37,100,58,32,0,99,97,108,108,0,0,0,0,39,102,111,114,39,32,115,116,101,112,32,109,117,115,116,32,98,101,32,97,32,110,117,109,98,101,114,0,0,0,0,0,37,115,58,32,37,115,32,105,110,32,112,114,101,99,111,109,112,105,108,101,100,32,99,104,117,110,107,0,0,0,0,0,112,114,111,116,111,0,0,0,116,111,111,32,109,97,110,121,32,108,111,99,97,108,32,118,97,114,105,97,98,108,101,115,0,0,0,0,0,0,0,0,103,108,111,98,97,108,0,0,97,116,116,101,109,112,116,32,116,111,32,37,115,32,37,115,32,39,37,115,39,32,40,97,32,37,115,32,118,97,108,117,101,41,0,0,0,0,0,0,97,115,115,101,114,116,105,111,110,32,102,97,105,108,101,100,33,0,0,0,0,0,0,0,102,111,114,0,0,0,0,0,37,115,0,0,0,0,0,0,100,101,98,117,103,0,0,0,99,112,97,116,104,0,0,0,115,101,116,115,116,101,112,109,117,108,0,0,0,0,0,0,100,117,109,112,0,0,0,0,114,101,109,111,118,101,0,0,114,101,109,111,118,101,0,0,115,101,116,112,97,117,115,101,0,0,0,0,0,0,0,0,97,115,105,110,0,0,0,0,37,115,0,0,0,0,0,0,115,116,101,112,0,0,0,0,103,101,116,117,112,118,97,108,117,101,0,0,0,0,0,0,116,111,111,32,109,97,110,121,32,97,114,103,117,109,101,110,116,115,32,116,111,32,114,101,115,117,109,101,0,0,0,0,83,108,0,0,0,0,0,0,99,111,117,110,116,0,0,0,39,102,111,114,39,32,108,105,109,105,116,32,109,117,115,116,32,98,101,32,97,32,110,117,109,98,101,114,0,0,0,0,110,0,0,0,0,0,0,0,98,97,100,32,105,110,116,101,103,101,114,0,0,0,0,0,116,104,114,101,97,100,0,0,99,111,108,108,101,99,116,0,108,111,99,97,108,32,118,97,114,105,97,98,108,101,115,0,34,93,0,0,0,0,0,0,114,101,115,116,97,114,116,0,115,116,111,112,0,0,0,0,108,111,99,97,108,0,0,0,114,101,97,100,101,114,32,102,117,110,99,116,105,111,110,32,109,117,115,116,32,114,101,116,117,114,110,32,97,32,115,116,114,105,110,103,0,0,0,0,116,111,111,32,109,97,110,121,32,110,101,115,116,101,100,32,102,117,110,99,116,105,111,110,115,0,0,0,0,0,0,0,61,40,108,111,97,100,41,0,102,97,108,115,101,0,0,0,109,97,116,104,0,0,0,0,46,47,63,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,115,104,97,114,101,47,108,117,97,47,53,46,49,47,63,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,115,104,97,114,101,47,108,117,97,47,53,46,49,47,63,47,105,110,105,116,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,49,47,63,46,108,117,97,59,47,117,115,114,47,108,111,99,97,108,47,108,105,98,47,108,117,97,47,53,46,49,47,63,47,105,110,105,116,46,108,117,97,0,0,0,0,0,0,0,99,104,97,114,0,0,0,0,105,110,115,101,114,116,0,0,103,101,116,101,110,118,0,0,97,99,111,115,0,0,0,0,37,115,58,32,37,115,0,0,39,116,111,115,116,114,105,110,103,39,32,109,117,115,116,32,114,101,116,117,114,110,32,97,32,115,116,114,105,110,103,32,116,111,32,39,112,114,105,110,116,39,0,0,0,0,0,0,103,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,105,110,100,101,120,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,121,105,101,108,100,0,0,0,37,115,32,101,120,112,101,99,116,101,100,44,32,103,111,116,32,37,115,0,0,0,0,0,97,110,100,0,0,0,0,0,39,102,111,114,39,32,105,110,105,116,105,97,108,32,118,97,108,117,101,32,109,117,115,116,32,98,101,32,97,32,110,117,109,98,101,114,0,0,0,0,115,116,97,99,107,32,111,118,101,114,102,108,111,119,0,0,98,97,100,32,99,111,110,115,116,97,110,116,0,0,0,0,102,117,110,99,116,105,111,110,0,0,0,0,0,0,0,0,110,111,32,102,117,110,99,116,105,111,110,32,101,110,118,105,114,111,110,109,101,110,116,32,102,111,114,32,116,97,105,108,32,99,97,108,108,32,97,116,32,108,101,118,101,108,32,37,100,0,0,0,0,0,0,0,60,110,97,109,101,62,32,111,114,32,39,46,46,46,39,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,0,0,91,115,116,114,105,110,103,32,34,0,0,0,0,0,0,0,102,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,108,101,118,101,108,0,0,0,37,115,58,37,100,58,32,37,115,0,0,0,0,0,0,0,95,76,79,65,68,76,73,66,0,0,0,0,0,0,0,0,108,101,118,101,108,32,109,117,115,116,32,98,101,32,110,111,110,45,110,101,103,97,116,105,118,101,0,0,0,0,0,0,39,115,101,116,102,101,110,118,39,32,99,97,110,110,111,116,32,99,104,97,110,103,101,32,101,110,118,105,114,111,110,109,101,110,116,32,111,102,32,103,105,118,101,110,32,111,98,106,101,99,116,0,0,0,0,0,99,97,110,110,111,116,32,99,104,97,110,103,101,32,97,32,112,114,111,116,101,99,116,101,100,32,109,101,116,97,116,97,98,108,101,0,0,0,0,0,101,110,100,0,0,0,0,0,115,116,114,105,110,103,0,0,95,95,109,101,116,97,116,97,98,108,101,0,0,0,0,0,76,85,65,95,80,65,84,72,0,0,0,0,0,0,0,0,98,121,116,101,0,0,0,0,109,97,120,110,0,0,0,0,115,116,114,105,110,103,0,0,101,120,105,116,0,0,0,0,110,105,108,32,111,114,32,116,97,98,108,101,32,101,120,112,101,99,116,101,100,0,0,0,97,98,115,0,0,0,0,0,70,73,76,69,42,0,0,0,98,97,115,101,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,0,116,97,98,108,101,0,0,0,103,101,116,114,101,103,105,115,116,114,121,0,0,0,0,0,119,114,97,112,0,0,0,0,98,97,100,32,97,114,103,117,109,101,110,116,32,35,37,100,32,116,111,32,39,37,115,39,32,40,37,115,41,0,0,0,37,115,58,32,37,112,0,0,103,101,116,32,108,101,110,103,116,104,32,111,102,0,0,0,117,110,101,120,112,101,99,116,101,100,32,101,110,100,0,0,61,40,100,101,98,117,103,32,99,111,109,109,97,110,100,41,0,0,0,0,0,0,0,0,116,97,98,108,101,0,0,0,110,105,108,0,0,0,0,0,105,110,105,116,0,0,0,0,97,114,103,0,0,0,0,0,99,111,110,116,10,0,0,0,10,13,0,0,0,0,0,0,102,97,108,115,101,0,0,0,111,115,0,0,0,0,0,0,97,98,115,101,110,116,0,0,108,117,97,95,100,101,98,117,103,62,32,0,0,0,0,0,116,114,117,101,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,99,111,109,112,97,114,101,32,37,115,32,119,105,116,104,32,37,115,0,0,0,95,95,105,110,100,101,120,0,101,120,116,101,114,110,97,108,32,104,111,111,107,0,0,0,95,95,116,111,115,116,114,105,110,103,0,0,0,0,0,0,115,101,101,97,108,108,0,0,102,117,110,99,0,0,0,0,116,111,111,32,109,97,110,121,32,114,101,115,117,108,116,115,32,116,111,32,117,110,112,97,99,107,0,0,0,0,0,0,108,111,97,100,108,105,98,0,97,99,116,105,118,101,108,105,110,101,115,0,0,0,0,0,109,97,116,104,0,0,0,0,120,112,99,97,108,108,0,0,101,108,115,101,105,102,0,0,10,9,110,111,32,102,105,101,108,100,32,112,97,99,107,97,103,101,46,112,114,101,108,111,97,100,91,39,37,115,39,93,0,0,0,0,0,0,0,0,111,115,0,0,0,0,0,0,110,97,109,101,119,104,97,116,0,0,0,0,0,0,0,0,117,110,112,97,99,107,0,0,99,104,117,110,107,32,104,97,115,32,116,111,111,32,109,97,110,121,32,108,105,110,101,115,0,0,0,0,0,0,0,0,112,97,116,104,0,0,0,0,39,112,97,99,107,97,103,101,46,112,114,101,108,111,97,100,39,32,109,117,115,116,32,98,101,32,97,32,116,97,98,108,101,0,0,0,0,0,0,0,95,95,105,110,100,101,120,0,101,110,100,0,0,0,0,0,103,101,116,110,0,0,0,0,110,97,109,101,0,0,0,0,116,121,112,101,0,0,0,0,101,120,101,99,117,116,101,0,110,101,115,116,105,110,103,32,111,102,32,91,91,46,46,46,93,93,32,105,115,32,100,101,112,114,101,99,97,116,101,100,0,0,0,0,0,0,0,0,109,111,100,0,0,0,0,0,99,117,114,0,0,0,0,0,110,117,112,115,0,0,0,0,116,111,115,116,114,105,110,103,0,0,0,0,0,0,0,0,112,111,112,101,110,0,0,0,117,110,102,105,110,105,115,104,101,100,32,108,111,110,103,32,99,111,109,109,101,110,116,0,103,101,116,108,111,99,97,108,0,0,0,0,0,0,0,0,114,0,0,0,0,0,0,0,115,101,116,0,0,0,0,0,99,117,114,114,101,110,116,108,105,110,101,0,0,0,0,0,116,111,110,117,109,98,101,114,0,0,0,0,0,0,0,0,115,116,97,116,117,115,0,0,63,0,0,0,0,0,0,0,117,110,102,105,110,105,115,104,101,100,32,108,111,110,103,32,115,116,114,105,110,103,0,0,115,116,114,105,110,103,32,108,101,110,103,116,104,32,111,118,101,114,102,108,111,119,0,0,105,111,0,0,0,0,0,0,10,9,110,111,32,102,105,108,101,32,39,37,115,39,0,0,98,97,100,32,99,111,100,101,0,0,0,0,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,121,105,101,108,100,32,97,99,114,111,115,115,32,109,101,116,97,109,101,116,104,111,100,47,67,45,99,97,108,108,32,98,111,117,110,100,97,114,121,0,0,0,0,0,0,108,105,110,101,0,0,0,0,119,104,97,116,0,0,0,0,115,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,115,116,114,105,110,103,0,0,101,115,99,97,112,101,32,115,101,113,117,101,110,99,101,32,116,111,111,32,108,97,114,103,101,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,99,111,110,115,116,97,110,116,32,116,97,98,108,101,32,111,118,101,114,102,108,111,119,0,102,117,108,108,0,0,0,0,108,97,115,116,108,105,110,101,100,101,102,105,110,101,100,0,115,101,116,102,101,110,118,0,97,116,116,101,109,112,116,32,116,111,32,99,111,109,112,97,114,101,32,116,119,111,32,37,115,32,118,97,108,117,101,115,0,0,0,0,0,0,0,0,117,110,102,105,110,105,115,104,101,100,32,115,116,114,105,110,103,0,0,0,0,0,0,0,39,112,97,99,107,97,103,101,46,37,115,39,32,109,117,115,116,32,98,101,32,97,32,115,116,114,105,110,103,0,0,0,115,116,114,105,110,103,32,115,108,105,99,101,32,116,111,111,32,108,111,110,103,0,0,0,110,111,0,0,0,0,0,0,108,105,110,101,100,101,102,105,110,101,100,0,0,0,0,0,115,101,108,101,99,116,0,0,108,101,120,105,99,97,108,32,101,108,101,109,101,110,116,32,116,111,111,32,108,111,110,103,0,0,0,0,0,0,0,0,102,117,110,99,116,105,111,110,32,111,114,32,101,120,112,114,101,115,115,105,111,110,32,116,111,111,32,99,111,109,112,108,101,120,0,0,0,0,0,0,47,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,118,97,108,117,101,0,0,0,102,105,108,101,32,40,37,112,41,0,0,0,0,0,0,0,115,104,111,114,116,95,115,114,99,0,0,0,0,0,0,0,114,97,119,115,101,116,0,0,109,97,108,102,111,114,109,101,100,32,110,117,109,98,101,114,0,0,0,0,0,0,0,0,108,117,97,111,112,101,110,95,37,115,0,0,0,0,0,0,117,110,97,98,108,101,32,116,111,32,100,117,109,112,32,103,105,118,101,110,32,102,117,110,99,116,105,111,110,0,0,0,102,105,108,101,32,40,99,108,111,115,101,100,41,0,0,0,115,111,117,114,99,101,0,0,114,97,119,103,101,116,0,0,43,45,0,0,0,0,0,0,69,101,0,0,0,0,0,0,95,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,102,111,114,109,97,116,32,40,119,105,100,116,104,32,111,114,32,112,114,101,99,105,115,105,111,110,32,116,111,111,32,108,111,110,103,41,0,0,0,0,95,95,116,111,115,116,114,105,110,103,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,0,0,100,101,98,117,103,0,0,0,114,97,119,101,113,117,97,108,0,0,0,0,0,0,0,0,99,111,110,116,114,111,108,32,115,116,114,117,99,116,117,114,101,32,116,111,111,32,108,111,110,103,0,0,0,0,0,0,46,0,0,0,0,0,0,0,101,108,115,101,0,0,0,0,105,110,118,97,108,105,100,32,102,111,114,109,97,116,32,40,114,101,112,101,97,116,101,100,32,102,108,97,103,115,41,0,95,95,103,99,0,0,0,0,105,111,0,0,0,0,0,0,102,117,110,99,116,105,111,110,32,111,114,32,108,101,118,101,108,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,112,114,105,110,116,0,0,0,46,0,0,0,0,0,0,0,108,111,97,100,101,114,115,0,45,43,32,35,48,0,0,0,115,101,116,118,98,117,102,0,102,111,114,101,97,99,104,105,0,0,0,0,0,0,0,0,62,37,115,0,0,0,0,0,112,99,97,108,108,0,0,0,100,105,102,102,116,105,109,101,0,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,108,111,110,103,32,115,116,114,105,110,103,32,100,101,108,105,109,105,116,101,114,0,0,0,102,109,111,100,0,0,0,0,76,79,65,68,76,73,66,58,32,0,0,0,0,0,0,0,115,101,101,107,0,0,0,0,102,108,110,83,117,0,0,0,110,101,120,116,0,0,0,0,115,116,100,101,114,114,0,0,37,115,32,110,101,97,114,32,39,37,115,39,0,0,0,0,103,101,116,105,110,102,111,0,37,115,37,115,0,0,0,0,92,48,48,48,0,0,0,0,119,114,111,110,103,32,110,117,109,98,101,114,32,111,102,32,97,114,103,117,109,101,110,116,115,0,0,0,0,0,0,0,95,95,105,110,100,101,120,0,39,115,101,116,102,101,110,118,39,32,99,97,110,110,111,116,32,99,104,97,110,103,101,32,101,110,118,105,114,111,110,109,101,110,116,32,111,102,32,103,105,118,101,110,32,111,98,106,101,99,116,0,0,0,0,0,108,111,97,100,115,116,114,105,110,103,0,0,0,0,0,0,114,117,110,110,105,110,103,0,99,97,108,108,105,110,103,32,39,37,115,39,32,111,110,32,98,97,100,32,115,101,108,102,32,40,37,115,41,0,0,0,37,115,58,37,100,58,32,37,115,0,0,0,0,0,0,0,108,111,111,112,32,105,110,32,115,101,116,116,97,98,108,101,0,0,0,0,0,0,0,0,100,121,110,97,109,105,99,32,108,105,98,114,97,114,105,101,115,32,110,111,116,32,101,110,97,98,108,101,100,59,32,99,104,101,99,107,32,121,111,117,114,32,76,117,97,32,105,110,115,116,97,108,108,97,116,105,111,110,0,0,0,0,0,0,99,111,114,111,117,116,105,110,101,0,0,0,0,0,0,0,92,114,0,0,0,0,0,0,99,111,100,101,32,116,111,111,32,100,101,101,112,0,0,0,105,110,116,101,114,118,97,108,32,105,115,32,101,109,112,116,121,0,0,0,0,0,0,0,95,95,99,108,111,115,101,0,116,97,105,108,32,114,101,116,117,114,110,0,0,0,0,0,99,97,110,110,111,116,32,114,101,115,117,109,101,32,110,111,110,45,115,117,115,112,101,110,100,101,100,32,99,111,114,111,117,116,105,110,101,0,0,0,108,111,97,100,0,0,0,0,110,117,109,98,101,114,0,0,37,99,0,0,0,0,0,0,105,110,118,97,108,105,100,32,107,101,121,32,116,111,32,39,110,101,120,116,39,0,0,0,101,114,114,111,114,32,108,111,97,100,105,110,103,32,109,111,100,117,108,101,32,39,37,115,39,32,102,114,111,109,32,102,105,108,101,32,39,37,115,39,58,10,9,37,115,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,32,39,37,37,37,99,39,32,116,111,32,39,102,111,114,109,97,116,39,0,0,0,0,0,0,0,115,101,108,102,0,0,0,0,116,97,110,0,0,0,0,0,102,105,108,101,32,105,115,32,97,108,114,101,97,100,121,32,99,108,111,115,101,100,0,0,99,111,117,110,116,0,0,0,108,111,97,100,102,105,108,101,0,0,0,0,0,0,0,0,112,101,114,102,111,114,109,32,97,114,105,116,104,109,101,116,105,99,32,111,110,0,0,0,37,0,0,0,0,0,0,0,99,104,97,114,40,37,100,41,0,0,0,0,0,0,0,0,10,9,110,111,32,109,111,100,117,108,101,32,39,37,115,39,32,105,110,32,102,105,108,101,32,39,37,115,39,0,0,0,110,111,32,118,97,108,117,101,0,0,0,0,0,0,0,0,121,100,97,121,0,0,0,0,116,97,110,104,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,117,115,101,32,97,32,99,108,111,115,101,100,32,102,105,108,101,0,0,0,0,108,105,110,101,0,0,0,0,103,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,98,97,100,32,97,114,103,117,109,101,110,116,32,35,37,100,32,40,37,115,41,0,0,0,60,101,111,102,62,0,0,0,1,0,0,0,0,0,0,0,39,115,116,114,105,110,103,46,103,102,105,110,100,39,32,119,97,115,32,114,101,110,97,109,101,100,32,116,111,32,39,115,116,114,105,110,103,46,103,109,97,116,99,104,39,0,0,0,119,100,97,121,0,0,0,0,115,113,114,116,0,0,0,0,119,0,0,0,0,0,0,0,114,101,116,117,114,110,0,0,103,101,116,102,101,110,118,0,60,115,116,114,105,110,103,62,0,0,0,0,0,0,0,0,59,1,59,0,0,0,0,0,105,110,118,97,108,105,100,32,114,101,112,108,97,99,101,109,101,110,116,32,118,97,108,117,101,32,40,97,32,37,115,41,0,0,0,0,0,0,0,0,42,116,0,0,0,0,0,0,115,105,110,0,0,0,0,0,39,112,111,112,101,110,39,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,0,0,99,97,108,108,0,0,0,0,103,99,105,110,102,111,0,0,60,110,97,109,101,62,0,0,59,59,0,0,0,0,0,0,115,116,114,105,110,103,47,102,117,110,99,116,105,111,110,47,116,97,98,108,101,32,101,120,112,101,99,116,101,100,0,0,37,99,0,0,0,0,0,0,115,105,110,104,0,0,0,0,114,0,0,0,0,0,0,0,108,101,118,101,108,32,111,117,116,32,111,102,32,114,97,110,103,101,0,0,0,0,0,0,101,114,114,111,114,0,0,0,99,104,117,110,107,32,104,97,115,32,116,111,111,32,109,97,110,121,32,115,121,110,116,97,120,32,108,101,118,101,108,115,0,0,0,0,0,0,0,0,60,110,117,109,98,101,114,62,0,0,0,0,0,0,0,0,126,61,0,0,0,0,0,0,95,80,65,67,75,65,71,69,0,0,0,0,0,0,0,0,37,46,49,52,103,0,0,0,105,110,118,97,108,105,100,32,112,97,116,116,101,114,110,32,99,97,112,116,117,114,101,0,37,115,58,32,37,115,0,0,100,111,0,0,0,0,0,0,114,97,110,100,111,109,115,101,101,100,0,0,0,0,0,0,37,108,102,0,0,0,0,0,116,97,98,108,101,0,0,0,110,105,108,32,111,114,32,116,97,98,108,101,32,101,120,112,101,99,116,101,100,0,0,0,100,111,102,105,108,101,0,0,95,95,99,97,108,108,0,0,39,37,115,39,32,101,120,112,101,99,116,101,100,0,0,0,99,111,110,115,116,97,110,116,32,116,97,98,108,101,32,111,118,101,114,102,108,111,119,0,112,97,99,107,97,103,101,0,95,77,0,0,0,0,0,0,117,110,98,97,108,97,110,99,101,100,32,112,97,116,116,101,114,110,0,0,0,0,0,0,103,102,105,110,100,0,0,0,110,117,109,101,114,105,99,0,114,97,110,100,111,109,0,0,105,110,118,97,108,105,100,32,102,111,114,109,97,116,0,0,102,111,114,101,97,99,104,0,32,105,110,32,102,117,110,99,116,105,111,110,32,60,37,115,58,37,100,62,0,0,0,0,99,111,108,108,101,99,116,103,97,114,98,97,103,101,0,0,99,97,110,110,111,116,32,37,115,32,37,115,58,32,37,115,0,0,0,0,0,0,0,0,95,95,99,111,110,99,97,116,0,0,0,0,0,0,0,0,39,37,115,39,32,101,120,112,101,99,116,101,100,32,40,116,111,32,99,108,111,115,101,32,39,37,115,39,32,97,116,32,108,105,110,101,32,37,100,41,0,0,0,0,0,0,0,0,100,97,116,101,0,0,0,0,60,61,0,0,0,0,0,0,104,117,103,101,0,0,0,0,39,109,111,100,117,108,101,39,32,110,111,116,32,99,97,108,108,101,100,32,102,114,111,109,32,97,32,76,117,97,32,102,117,110,99,116,105,111,110,0,109,97,108,102,111,114,109,101,100,32,112,97,116,116,101,114,110,32,40,109,105,115,115,105,110,103,32,39,93,39,41,0,109,111,110,101,116,97,114,121,0,0,0,0,0,0,0,0,114,97,100,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,0,0,32,63,0,0,0,0,0,0,97,115,115,101,114,116,0,0,10,0,0,0,0,0,0,0,115,116,100,111,117,116,0,0,95,95,108,101,0,0,0,0,40,102,111,114,32,115,116,101,112,41,0,0,0,0,0,0,62,61,0,0,0,0,0,0,103,101,116,104,111,111,107,0,102,0,0,0,0,0,0,0,109,97,108,102,111,114,109,101,100,32,112,97,116,116,101,114,110,32,40,101,110,100,115,32,119,105,116,104,32,39,37,37,39,41,0,0,0,0,0,0,99,116,121,112,101,0,0,0,112,111,119,0,0,0,0,0,116,111,111,32,109,97,110,121,32,97,114,103,117,109,101,110,116,115,0,0,0,0,0,0,32,105,110,32,109,97,105,110,32,99,104,117,110,107,0,0,98,111,111,108,101,97,110,32,111,114,32,112,114,111,120,121,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,0,80,65,78,73,67,58,32,117,110,112,114,111,116,101,99,116,101,100,32,101,114,114,111,114,32,105,110,32,99,97,108,108,32,116,111,32,76,117,97,32,65,80,73,32,40,37,115,41,10,0,0,0,0,0,0,0,114,101,115,117,109,101,0,0,95,95,108,116,0,0,0,0,40,102,111,114,32,108,105,109,105,116,41,0,0,0,0,0,109,101,116,104,111,100,0,0,61,61,0,0,0,0,0,0,108,111,111,112,32,105,110,32,103,101,116,116,97,98,108,101,0,0,0,0,0,0,0,0,95,78,65,77,69,0,0,0,109,105,115,115,105,110,103,32,39,91,39,32,97,102,116,101,114,32,39,37,37,102,39,32,105,110,32,112,97,116,116,101,114,110,0,0,0,0,0,0,61,63,0,0,0,0,0,0,99,111,108,108,97,116,101,0,109,111,100,102,0,0,0,0,102,105,108,101,0,0,0,0,32,105,110,32,102,117,110,99,116,105,111,110,32,39,37,115,39,0,0,0,0,0,0,0,110,101,119,112,114,111,120,121,0,0,0,0,0,0,0,0,114,101,97,100,0,0,0,0,67,32,115,116,97,99,107,32,111,118,101,114,102,108,111,119,0,0,0,0,0,0,0,0,95,95,108,101,110,0,0,0,117,115,101,114,100,97,116,97,0,0,0,0,0,0,0,0,40,102,111,114,32,105,110,100,101,120,41,0,0,0,0,0,46,46,46,0,0,0,0,0,116,97,98,108,101,32,111,118,101,114,102,108,111,119,0,0,46,46,0,0,0,0,0,0,110,105,108,0,0,0,0,0,110,97,109,101,32,99,111,110,102,108,105,99,116,32,102,111,114,32,109,111,100,117,108,101,32,39,37,115,39,0,0,0,117,110,102,105,110,105,115,104,101,100,32,99,97,112,116,117,114,101,0,0,0,0,0,0,99,97,110,110,111,116,32,117,115,101,32,39,46,46,46,39,32,111,117,116,115,105,100,101,32,97,32,118,97,114,97,114,103,32,102,117,110,99,116,105,111,110,0,0,0,0,0,0,97,108,108,0,0,0,0,0,109,105,110,0,0,0,0,0,99,108,111,115,101,100,32,102,105,108,101,0,0,0,0,0,37,100,58,0,0,0,0,0,95,95,109,111,100,101,0,0,114,101,111,112,101,110,0,0,95,95,117,110,109,0,0,0,40,102,111,114,32,99,111,110,116,114,111,108,41,0,0,0,37,112,0,0,0,0,0,0,99,111,110,99,97,116,101,110,97,116,101,0,0,0,0,0,110,111,116,32,101,110,111,117,103,104,32,109,101,109,111,114,121,0,0,0,0,0,0,0,119,104,105,108,101,0,0,0,109,111,100,117,108,101,32,39,37,115,39,32,110,111,116,32,102,111,117,110,100,58,37,115,0,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,99,97,112,116,117,114,101,32,105,110,100,101,120,0,0,0,102,105,101,108,100,32,39,37,115,39,32,109,105,115,115,105,110,103,32,105,110,32,100,97,116,101,32,116,97,98,108,101,0,0,0,0,0,0,0,0,109,97,120,0,0,0,0,0,37,46,49,52,103,0,0,0,37,115,58,0,0,0,0,0,107,118,0,0,0,0,0,0,114,98,0,0,0,0,0,0,95,95,112,111,119,0,0,0,40,102,111,114,32,115,116,97,116,101,41,0,0,0,0,0,40,42,116,101,109,112,111,114,97,114,121,41,0,0,0,0,63,0,0,0,0,0,0,0,40,110,117,108,108,41,0,0,117,110,116,105,108,0,0,0,116,97,98,108,101,32,105,110,100,101,120,32,105,115,32,110,105,108,0,0,0,0,0,0,116,111,111,32,109,97,110,121,32,99,97,112,116,117,114,101,115,0,0,0,0,0,0,0,105,115,100,115,116,0,0,0,108,111,103,0,0,0,0,0,115,116,97,110,100,97,114,100,32,37,115,32,102,105,108,101,32,105,115,32,99,108,111,115,101,100,0,0,0,0,0,0,83,110,108,0,0,0,0,0,112,97,105,114,115,0,0,0,95,95,109,111,100,0,0,0,40,102,111,114,32,103,101,110,101,114,97,116,111,114,41,0,61,40,116,97,105,108,32,99,97,108,108,41,0,0,0,0,97,116,116,101,109,112,116,32,116,111,32,37,115,32,97,32,37,115,32,118,97,108,117,101,0,0,0,0,0,0,0,0,116,114,117,101,0,0,0,0,39,112,97,99,107,97,103,101,46,108,111,97,100,101,114,115,39,32,109,117,115,116,32,98,101,32,97,32,116,97,98,108,101,0,0,0,0,0,0,0,94,36,42,43,63,46,40,91,37,45,0,0,0,0,0,0,121,101,97,114,0,0,0,0,110,111,116,32,101,110,111,117,103,104,32,109,101,109,111,114,121,0,0,0,0,0,0,0,108,111,103,49,48,0,0,0,119,114,105,116,101,0,0,0,10,9,0,0,0,0,0,0,105,112,97,105,114,115,0,0,111,112,101,110,0,0,0,0,95,95,100,105,118,0,0,0,39,61,39,32,111,114,32,39,105,110,39,32,101,120,112,101,99,116,101,100,0,0,0,0,116,97,105,108,0,0,0,0,116,104,101,110,0,0,0,0,108,111,111,112,32,111,114,32,112,114,101,118,105,111,117,115,32,101,114,114,111,114,32,108,111,97,100,105,110,103,32,109,111,100,117,108,101,32,39,37,115,39,0,0,0,0,0,0,117,112,112,101,114,0,0,0,109,111,110,116,104,0,0,0,108,100,101,120,112,0,0,0,116,121,112,101,0,0,0,0,10,9,46,46,46,0,0,0,95,86,69,82,83,73,79,78,0,0,0,0,0,0,0,0,114,0,0,0,0,0,0,0,95,95,109,117,108,0,0,0,110,111,32,108,111,111,112,32,116,111,32,98,114,101,97,107,0,0,0,0,0,0,0,0,76,117,97,0,0,0,0,0,114,101,116,117,114,110,0,0,114,101,113,117,105,114,101,0,115,117,98,0,0,0,0,0,100,97,121,0,0,0,0,0,102,114,101,120,112,0,0,0,116,109,112,102,105,108,101,0,112,97,99,107,97,103,101,0,98,114,101,97,107,0,0,0,115,116,97,99,107,32,116,114,97,99,101,98,97,99,107,58,0,0,0,0,0,0,0,0,76,117,97,32,53,46,49,0,64,37,115,0,0,0,0,0,95,95,115,117,98,0,0,0,109,97,105,110,0,0,0,0,95,95,103,99,0,0,0,0,114,101,112,101,97,116,0,0,109,111,100,117,108,101,0,0,114,101,118,101,114,115,101,0,103,109,97,116,99,104,0,0,104,111,117,114,0,0,0,0,115,121,110,116,97,120,32,101,114,114,111,114,0,0,0,0,102,108,111,111,114,0,0,0,114,101,97,100,0,0,0,0,99,111,110,99,97,116,0,0,10,0,0,0,0,0,0,0,95,71,0,0,0,0,0,0,61,115,116,100,105,110,0,0,95,95,97,100,100,0,0,0,117,112,118,97,108,117,101,115,0,0,0,0,0,0,0,0,67,0,0,0,0,0,0,0,99,108,111,99,107,0,0,0,99,111,100,101,32,115,105,122,101,32,111,118,101,114,102,108,111,119,0,0,0,0,0,0,111,114,0,0,0,0,0,0,112,105,0,0,0,0,0,0,112,114,101,108,111,97,100,0,114,101,112,0,0,0,0,0,105,110,118,97,108,105,100,32,118,97,108,117,101,32,40,37,115,41,32,97,116,32,105,110,100,101,120,32,37,100,32,105,110,32,116,97,98,108,101,32,102,111,114,32,39,99,111,110,99,97,116,39,0,0,0,0,109,105,110,0,0,0,0,0,101,120,112,0,0,0,0,0,111,117,116,112,117,116,0,0,76,117,97,32,102,117,110,99,116,105,111,110,32,101,120,112,101,99,116,101,100,0,0,0,110,97,109,101,32,99,111,110,102,108,105,99,116,32,102,111,114,32,109,111,100,117,108,101,32,39,37,115,39,0,0,0,115,116,100,105,110,0,0,0,95,95,101,113,0,0,0,0,117,110,101,120,112,101,99,116,101,100,32,115,121,109,98,111,108,0,0,0,0,0,0,0,61,91,67,93,0,0,0,0,110,111,116,0,0,0,0,0,103,101,116,102,101,110,118,0,108,111,97,100,101,100,0,0,109,97,116,99,104,0,0,0,119,114,111,110,103,32,110,117,109,98,101,114,32,111,102,32,97,114,103,117,109,101,110,116,115,32,116,111,32,39,105,110,115,101,114,116,39,0,0,0,115,101,99,0,0,0,0,0,100,101,103,0,0,0,0,0,111,112,101,110,0,0,0,0,116,114,97,99,101,98,97,99,107,0,0,0,0,0,0,0,99,111,114,111,117,116,105,110,101,32,101,120,112,101,99,116,101,100,0,0,0,0,0,0,95,76,79,65,68,69,68,0,99,114,101,97,116,101,0,0,95,95,109,111,100,101,0,0,102,117,110,99,116,105,111,110,32,97,114,103,117,109,101,110,116,115,32,101,120,112,101,99,116,101,100,0,0,0,0,0,110,0,0,0,0,0,0,0,110,105,108,0,0,0,0,0,105,110,100,101,120,0,0,0,95,76,79,65,68,69,68,0,108,111,119,101,114,0,0,0,39,115,101,116,110,39,32,105,115,32,111,98,115,111,108,101,116,101,0,0,0,0,0,0,98,105,110,97,114,121,32,115,116,114,105,110,103,0,0,0,117,110,97,98,108,101,32,116,111,32,103,101,110,101,114,97,116,101,32,97,32,117,110,105,113,117,101,32,102,105,108,101,110,97,109,101,0,0,0,0,99,111,115,0,0,0,0,0,108,105,110,101,115,0,0,0,115,101,116,117,112,118,97,108,117,101,0,0,0,0,0,0,100,101,97,100,0,0,0,0,118,97,108,117,101,32,101,120,112,101,99,116,101,100,0,0,95,95,103,99,0,0,0,0,101,114,114,111,114,32,105,110,32,101,114,114,111,114,32,104,97,110,100,108,105,110,103,0,98,111,111,108,101,97,110,0,97,109,98,105,103,117,111,117,115,32,115,121,110,116,97,120,32,40,102,117,110,99,116,105,111,110,32,99,97,108,108,32,120,32,110,101,119,32,115,116,97,116,101,109,101,110,116,41,0,0,0,0,0,0,0,0,109,101,116,104,111,100,0,0,116,97,98,108,101,32,105,110,100,101,120,32,105,115,32,78,97,78,0,0,0,0,0,0,108,111,99,97,108,0,0,0,99,111,110,102,105,103,0,0,108,101,110,0,0,0,0,0,118,97,114,105,97,98,108,101,115,32,105,110,32,97,115,115,105,103,110,109,101,110,116,0,105,110,118,97,108,105,100,32,111,114,100,101,114,32,102,117,110,99,116,105,111,110,32,102,111,114,32,115,111,114,116,105,110,103,0,0,0,0,0,0,116,109,112,110,97,109,101,0,99,111,115,104,0,0,0,0,105,110,112,117,116,0,0,0,115,101,116,109,101,116,97,116,97,98,108,101,0,0,0,0,110,111,114,109,97,108,0,0,115,116,97,99,107,32,111,118,101,114,102,108,111,119,32,40,37,115,41,0,0,0,0,0,95,95,110,101,119,105,110,100,101,120,0,0,0,0,0,0,102,117,110,99,116,105,111,110,32,97,116,32,108,105,110,101,32,37,100,32,104,97,115,32,109,111,114,101,32,116,104,97].concat([110,32,37,100,32,37,115,0,117,112,118,97,108,117,101,0,105,110,0,0,0,0,0,0,47,10,59,10,63,10,33,10,45,0,0,0,0,0,0,0,103,115,117,98,0,0,0,0,116,105,109,101,0,0,0,0,99,101,105,108,0,0,0,0,102,108,117,115,104,0,0,0,115,101,116,108,111,99,97,108,0,0,0,0,0,0,0,0,115,117,115,112,101,110,100,101,100,0,0,0,0,0,0,0,105,110,118,97,108,105,100,32,111,112,116,105,111,110,32,39,37,115,39,0,0,0,0,0,95,95,105,110,100,101,120,0,109,97,105,110,32,102,117,110,99,116,105,111,110,32,104,97,115,32,109,111,114,101,32,116,104,97,110,32,37,100,32,37,115,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,110,111,32,118,97,108,117,101,0,0,0,0,0,0,0,0,110,111,32,99,97,108,108,105,110,103,32,101,110,118,105,114,111,110,109,101,110,116,0,0,104,0,0,0,0,0,0,0])\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3117 , \"i8\", ALLOC_NONE, Runtime.GLOBAL_BASE)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3118 var tempDoublePtr = Runtime.alignMemory(allocate(12, \"i8\", ALLOC_STATIC), 8);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3119 assert(tempDoublePtr % 8 == 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3120 function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3121 HEAP8[tempDoublePtr] = HEAP8[ptr];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3122 HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3123 HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3124 HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3125 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3126 function copyTempDouble(ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3127 HEAP8[tempDoublePtr] = HEAP8[ptr];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3128 HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3129 HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3130 HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3131 HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3132 HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3133 HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3134 HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3135 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3136 Module[\"_strlen\"] = _strlen;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3137 var _llvm_va_start=undefined;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3138 function _llvm_va_end() {}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3139 Module[\"_memcpy\"] = _memcpy;var _llvm_memcpy_p0i8_p0i8_i32=_memcpy;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3140 var _floor=Math.floor;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3141 var _llvm_pow_f64=Math.pow;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3142 function _llvm_lifetime_start() {}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3143 function _llvm_lifetime_end() {}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3144 function _strchr(ptr, chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3145 ptr--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3146 do {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3147 ptr++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3148 var val = HEAP8[(ptr)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3149 if (val == chr) return ptr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3150 } while (val);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3151 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3152 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3153 var ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:35,EIDRM:36,ECHRNG:37,EL2NSYNC:38,EL3HLT:39,EL3RST:40,ELNRNG:41,EUNATCH:42,ENOCSI:43,EL2HLT:44,EDEADLK:45,ENOLCK:46,EBADE:50,EBADR:51,EXFULL:52,ENOANO:53,EBADRQC:54,EBADSLT:55,EDEADLOCK:56,EBFONT:57,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:74,EDOTDOT:76,EBADMSG:77,ENOTUNIQ:80,EBADFD:81,EREMCHG:82,ELIBACC:83,ELIBBAD:84,ELIBSCN:85,ELIBMAX:86,ELIBEXEC:87,ENOSYS:88,ENOTEMPTY:90,ENAMETOOLONG:91,ELOOP:92,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:106,EPROTOTYPE:107,ENOTSOCK:108,ENOPROTOOPT:109,ESHUTDOWN:110,ECONNREFUSED:111,EADDRINUSE:112,ECONNABORTED:113,ENETUNREACH:114,ENETDOWN:115,ETIMEDOUT:116,EHOSTDOWN:117,EHOSTUNREACH:118,EINPROGRESS:119,EALREADY:120,EDESTADDRREQ:121,EMSGSIZE:122,EPROTONOSUPPORT:123,ESOCKTNOSUPPORT:124,EADDRNOTAVAIL:125,ENETRESET:126,EISCONN:127,ENOTCONN:128,ETOOMANYREFS:129,EUSERS:131,EDQUOT:132,ESTALE:133,ENOTSUP:134,ENOMEDIUM:135,EILSEQ:138,EOVERFLOW:139,ECANCELED:140,ENOTRECOVERABLE:141,EOWNERDEAD:142,ESTRPIPE:143};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3154 var ERRNO_MESSAGES={0:\"Success\",1:\"Not super-user\",2:\"No such file or directory\",3:\"No such process\",4:\"Interrupted system call\",5:\"I/O error\",6:\"No such device or address\",7:\"Arg list too long\",8:\"Exec format error\",9:\"Bad file number\",10:\"No children\",11:\"No more processes\",12:\"Not enough core\",13:\"Permission denied\",14:\"Bad address\",15:\"Block device required\",16:\"Mount device busy\",17:\"File exists\",18:\"Cross-device link\",19:\"No such device\",20:\"Not a directory\",21:\"Is a directory\",22:\"Invalid argument\",23:\"Too many open files in system\",24:\"Too many open files\",25:\"Not a typewriter\",26:\"Text file busy\",27:\"File too large\",28:\"No space left on device\",29:\"Illegal seek\",30:\"Read only file system\",31:\"Too many links\",32:\"Broken pipe\",33:\"Math arg out of domain of func\",34:\"Math result not representable\",35:\"No message of desired type\",36:\"Identifier removed\",37:\"Channel number out of range\",38:\"Level 2 not synchronized\",39:\"Level 3 halted\",40:\"Level 3 reset\",41:\"Link number out of range\",42:\"Protocol driver not attached\",43:\"No CSI structure available\",44:\"Level 2 halted\",45:\"Deadlock condition\",46:\"No record locks available\",50:\"Invalid exchange\",51:\"Invalid request descriptor\",52:\"Exchange full\",53:\"No anode\",54:\"Invalid request code\",55:\"Invalid slot\",56:\"File locking deadlock error\",57:\"Bad font file fmt\",60:\"Device not a stream\",61:\"No data (for no delay io)\",62:\"Timer expired\",63:\"Out of streams resources\",64:\"Machine is not on the network\",65:\"Package not installed\",66:\"The object is remote\",67:\"The link has been severed\",68:\"Advertise error\",69:\"Srmount error\",70:\"Communication error on send\",71:\"Protocol error\",74:\"Multihop attempted\",76:\"Cross mount point (not really error)\",77:\"Trying to read unreadable message\",80:\"Given log. name not unique\",81:\"f.d. invalid for this operation\",82:\"Remote address changed\",83:\"Can access a needed shared lib\",84:\"Accessing a corrupted shared lib\",85:\".lib section in a.out corrupted\",86:\"Attempting to link in too many libs\",87:\"Attempting to exec a shared library\",88:\"Function not implemented\",90:\"Directory not empty\",91:\"File or path name too long\",92:\"Too many symbolic links\",95:\"Operation not supported on transport endpoint\",96:\"Protocol family not supported\",104:\"Connection reset by peer\",105:\"No buffer space available\",106:\"Address family not supported by protocol family\",107:\"Protocol wrong type for socket\",108:\"Socket operation on non-socket\",109:\"Protocol not available\",110:\"Can't send after socket shutdown\",111:\"Connection refused\",112:\"Address already in use\",113:\"Connection aborted\",114:\"Network is unreachable\",115:\"Network interface is not configured\",116:\"Connection timed out\",117:\"Host is down\",118:\"Host is unreachable\",119:\"Connection already in progress\",120:\"Socket already connected\",121:\"Destination address required\",122:\"Message too long\",123:\"Unknown protocol\",124:\"Socket type not supported\",125:\"Address not available\",126:\"Connection reset by network\",127:\"Socket is already connected\",128:\"Socket is not connected\",129:\"Too many references\",131:\"Too many users\",132:\"Quota exceeded\",133:\"Stale file handle\",134:\"Not supported\",135:\"No medium (in tape drive)\",138:\"Illegal byte sequence\",139:\"Value too large for defined data type\",140:\"Operation canceled\",141:\"State not recoverable\",142:\"Previous owner died\",143:\"Streams pipe error\"};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3155 var ___errno_state=0;function ___setErrNo(value) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3156 // For convenient setting and returning of errno.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3157 HEAP32[((___errno_state)>>2)]=value\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3158 return value;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3159 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3160 var VFS=undefined;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3161 var PATH={splitPath:function (filename) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3162 var splitPathRe = /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3163 return splitPathRe.exec(filename).slice(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3164 },normalizeArray:function (parts, allowAboveRoot) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3165 // if the path tries to go above the root, `up` ends up > 0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3166 var up = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3167 for (var i = parts.length - 1; i >= 0; i--) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3168 var last = parts[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3169 if (last === '.') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3170 parts.splice(i, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3171 } else if (last === '..') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3172 parts.splice(i, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3173 up++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3174 } else if (up) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3175 parts.splice(i, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3176 up--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3177 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3178 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3179 // if the path is allowed to go above the root, restore leading ..s\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3180 if (allowAboveRoot) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3181 for (; up--; up) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3182 parts.unshift('..');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3183 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3184 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3185 return parts;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3186 },normalize:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3187 var isAbsolute = path.charAt(0) === '/',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3188 trailingSlash = path.substr(-1) === '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3189 // Normalize the path\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3190 path = PATH.normalizeArray(path.split('/').filter(function(p) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3191 return !!p;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3192 }), !isAbsolute).join('/');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3193 if (!path && !isAbsolute) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3194 path = '.';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3195 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3196 if (path && trailingSlash) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3197 path += '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3198 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3199 return (isAbsolute ? '/' : '') + path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3200 },dirname:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3201 var result = PATH.splitPath(path),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3202 root = result[0],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3203 dir = result[1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3204 if (!root && !dir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3205 // No dirname whatsoever\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3206 return '.';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3207 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3208 if (dir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3209 // It has a dirname, strip trailing slash\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3210 dir = dir.substr(0, dir.length - 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3211 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3212 return root + dir;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3213 },basename:function (path, ext) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3214 // EMSCRIPTEN return '/'' for '/', not an empty string\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3215 if (path === '/') return '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3216 var f = PATH.splitPath(path)[2];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3217 if (ext && f.substr(-1 * ext.length) === ext) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3218 f = f.substr(0, f.length - ext.length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3219 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3220 return f;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3221 },extname:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3222 return PATH.splitPath(path)[3];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3223 },join:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3224 var paths = Array.prototype.slice.call(arguments, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3225 return PATH.normalize(paths.filter(function(p, index) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3226 if (typeof p !== 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3227 throw new TypeError('Arguments to path.join must be strings');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3228 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3229 return p;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3230 }).join('/'));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3231 },resolve:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3232 var resolvedPath = '',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3233 resolvedAbsolute = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3234 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3235 var path = (i >= 0) ? arguments[i] : FS.cwd();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3236 // Skip empty and invalid entries\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3237 if (typeof path !== 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3238 throw new TypeError('Arguments to path.resolve must be strings');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3239 } else if (!path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3240 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3241 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3242 resolvedPath = path + '/' + resolvedPath;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3243 resolvedAbsolute = path.charAt(0) === '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3244 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3245 // At this point the path should be resolved to a full absolute path, but\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3246 // handle relative paths to be safe (might happen when process.cwd() fails)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3247 resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3248 return !!p;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3249 }), !resolvedAbsolute).join('/');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3250 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3251 },relative:function (from, to) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3252 from = PATH.resolve(from).substr(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3253 to = PATH.resolve(to).substr(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3254 function trim(arr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3255 var start = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3256 for (; start < arr.length; start++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3257 if (arr[start] !== '') break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3258 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3259 var end = arr.length - 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3260 for (; end >= 0; end--) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3261 if (arr[end] !== '') break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3262 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3263 if (start > end) return [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3264 return arr.slice(start, end - start + 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3265 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3266 var fromParts = trim(from.split('/'));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3267 var toParts = trim(to.split('/'));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3268 var length = Math.min(fromParts.length, toParts.length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3269 var samePartsLength = length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3270 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3271 if (fromParts[i] !== toParts[i]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3272 samePartsLength = i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3273 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3274 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3275 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3276 var outputParts = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3277 for (var i = samePartsLength; i < fromParts.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3278 outputParts.push('..');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3279 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3280 outputParts = outputParts.concat(toParts.slice(samePartsLength));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3281 return outputParts.join('/');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3282 }};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3283 var TTY={ttys:[],init:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3284 // https://github.com/kripken/emscripten/pull/1555\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3285 // if (ENVIRONMENT_IS_NODE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3286 // // currently, FS.init does not distinguish if process.stdin is a file or TTY\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3287 // // device, it always assumes it's a TTY device. because of this, we're forcing\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3288 // // process.stdin to UTF8 encoding to at least make stdin reading compatible\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3289 // // with text files until FS.init can be refactored.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3290 // process['stdin']['setEncoding']('utf8');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3291 // }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3292 },shutdown:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3293 // https://github.com/kripken/emscripten/pull/1555\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3294 // if (ENVIRONMENT_IS_NODE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3295 // // inolen: any idea as to why node -e 'process.stdin.read()' wouldn't exit immediately (with process.stdin being a tty)?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3296 // // isaacs: because now it's reading from the stream, you've expressed interest in it, so that read() kicks off a _read() which creates a ReadReq operation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3297 // // inolen: I thought read() in that case was a synchronous operation that just grabbed some amount of buffered data if it exists?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3298 // // isaacs: it is. but it also triggers a _read() call, which calls readStart() on the handle\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3299 // // isaacs: do process.stdin.pause() and i'd think it'd probably close the pending call\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3300 // process['stdin']['pause']();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3301 // }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3302 },register:function (dev, ops) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3303 TTY.ttys[dev] = { input: [], output: [], ops: ops };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3304 FS.registerDevice(dev, TTY.stream_ops);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3305 },stream_ops:{open:function (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3306 var tty = TTY.ttys[stream.node.rdev];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3307 if (!tty) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3308 throw new FS.ErrnoError(ERRNO_CODES.ENODEV);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3309 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3310 stream.tty = tty;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3311 stream.seekable = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3312 },close:function (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3313 // flush any pending line data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3314 if (stream.tty.output.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3315 stream.tty.ops.put_char(stream.tty, 10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3316 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3317 },read:function (stream, buffer, offset, length, pos /* ignored */) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3318 if (!stream.tty || !stream.tty.ops.get_char) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3319 throw new FS.ErrnoError(ERRNO_CODES.ENXIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3320 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3321 var bytesRead = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3322 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3323 var result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3324 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3325 result = stream.tty.ops.get_char(stream.tty);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3326 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3327 throw new FS.ErrnoError(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3328 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3329 if (result === undefined && bytesRead === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3330 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3331 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3332 if (result === null || result === undefined) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3333 bytesRead++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3334 buffer[offset+i] = result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3335 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3336 if (bytesRead) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3337 stream.node.timestamp = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3338 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3339 return bytesRead;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3340 },write:function (stream, buffer, offset, length, pos) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3341 if (!stream.tty || !stream.tty.ops.put_char) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3342 throw new FS.ErrnoError(ERRNO_CODES.ENXIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3343 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3344 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3345 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3346 stream.tty.ops.put_char(stream.tty, buffer[offset+i]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3347 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3348 throw new FS.ErrnoError(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3349 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3350 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3351 if (length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3352 stream.node.timestamp = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3353 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3354 return i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3355 }},default_tty_ops:{get_char:function (tty) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3356 if (!tty.input.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3357 var result = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3358 if (ENVIRONMENT_IS_NODE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3359 result = process['stdin']['read']();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3360 if (!result) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3361 if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3362 return null; // EOF\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3363 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3364 return undefined; // no data available\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3365 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3366 } else if (typeof window != 'undefined' &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3367 typeof window.prompt == 'function') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3368 // Browser.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3369 result = window.prompt('Input: '); // returns null on cancel\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3370 if (result !== null) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3371 result += '\\n';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3372 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3373 } else if (typeof readline == 'function') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3374 // Command line.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3375 result = readline();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3376 if (result !== null) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3377 result += '\\n';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3378 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3379 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3380 if (!result) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3381 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3382 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3383 tty.input = intArrayFromString(result, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3384 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3385 return tty.input.shift();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3386 },put_char:function (tty, val) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3387 if (val === null || val === 10) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3388 Module['print'](tty.output.join(''));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3389 tty.output = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3390 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3391 tty.output.push(TTY.utf8.processCChar(val));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3392 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3393 }},default_tty1_ops:{put_char:function (tty, val) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3394 if (val === null || val === 10) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3395 Module['printErr'](tty.output.join(''));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3396 tty.output = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3397 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3398 tty.output.push(TTY.utf8.processCChar(val));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3399 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3400 }}};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3401 var MEMFS={CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,ensureFlexible:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3402 if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3403 var contents = node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3404 node.contents = Array.prototype.slice.call(contents);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3405 node.contentMode = MEMFS.CONTENT_FLEXIBLE;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3406 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3407 },mount:function (mount) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3408 return MEMFS.create_node(null, '/', 0040000 | 0777, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3409 },create_node:function (parent, name, mode, dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3410 if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3411 // no supported\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3412 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3413 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3414 var node = FS.createNode(parent, name, mode, dev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3415 if (FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3416 node.node_ops = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3417 getattr: MEMFS.node_ops.getattr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3418 setattr: MEMFS.node_ops.setattr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3419 lookup: MEMFS.node_ops.lookup,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3420 mknod: MEMFS.node_ops.mknod,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3421 mknod: MEMFS.node_ops.mknod,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3422 rename: MEMFS.node_ops.rename,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3423 unlink: MEMFS.node_ops.unlink,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3424 rmdir: MEMFS.node_ops.rmdir,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3425 readdir: MEMFS.node_ops.readdir,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3426 symlink: MEMFS.node_ops.symlink\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3427 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3428 node.stream_ops = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3429 llseek: MEMFS.stream_ops.llseek\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3430 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3431 node.contents = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3432 } else if (FS.isFile(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3433 node.node_ops = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3434 getattr: MEMFS.node_ops.getattr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3435 setattr: MEMFS.node_ops.setattr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3436 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3437 node.stream_ops = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3438 llseek: MEMFS.stream_ops.llseek,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3439 read: MEMFS.stream_ops.read,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3440 write: MEMFS.stream_ops.write,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3441 allocate: MEMFS.stream_ops.allocate,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3442 mmap: MEMFS.stream_ops.mmap\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3443 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3444 node.contents = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3445 node.contentMode = MEMFS.CONTENT_FLEXIBLE;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3446 } else if (FS.isLink(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3447 node.node_ops = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3448 getattr: MEMFS.node_ops.getattr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3449 setattr: MEMFS.node_ops.setattr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3450 readlink: MEMFS.node_ops.readlink\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3451 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3452 node.stream_ops = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3453 } else if (FS.isChrdev(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3454 node.node_ops = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3455 getattr: MEMFS.node_ops.getattr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3456 setattr: MEMFS.node_ops.setattr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3457 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3458 node.stream_ops = FS.chrdev_stream_ops;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3459 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3460 node.timestamp = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3461 // add the new node to the parent\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3462 if (parent) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3463 parent.contents[name] = node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3464 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3465 return node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3466 },node_ops:{getattr:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3467 var attr = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3468 // device numbers reuse inode numbers.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3469 attr.dev = FS.isChrdev(node.mode) ? node.id : 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3470 attr.ino = node.id;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3471 attr.mode = node.mode;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3472 attr.nlink = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3473 attr.uid = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3474 attr.gid = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3475 attr.rdev = node.rdev;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3476 if (FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3477 attr.size = 4096;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3478 } else if (FS.isFile(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3479 attr.size = node.contents.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3480 } else if (FS.isLink(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3481 attr.size = node.link.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3482 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3483 attr.size = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3484 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3485 attr.atime = new Date(node.timestamp);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3486 attr.mtime = new Date(node.timestamp);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3487 attr.ctime = new Date(node.timestamp);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3488 // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3489 // but this is not required by the standard.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3490 attr.blksize = 4096;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3491 attr.blocks = Math.ceil(attr.size / attr.blksize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3492 return attr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3493 },setattr:function (node, attr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3494 if (attr.mode !== undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3495 node.mode = attr.mode;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3496 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3497 if (attr.timestamp !== undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3498 node.timestamp = attr.timestamp;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3499 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3500 if (attr.size !== undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3501 MEMFS.ensureFlexible(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3502 var contents = node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3503 if (attr.size < contents.length) contents.length = attr.size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3504 else while (attr.size > contents.length) contents.push(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3505 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3506 },lookup:function (parent, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3507 throw new FS.ErrnoError(ERRNO_CODES.ENOENT);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3508 },mknod:function (parent, name, mode, dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3509 return MEMFS.create_node(parent, name, mode, dev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3510 },rename:function (old_node, new_dir, new_name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3511 // if we're overwriting a directory at new_name, make sure it's empty.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3512 if (FS.isDir(old_node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3513 var new_node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3514 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3515 new_node = FS.lookupNode(new_dir, new_name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3516 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3517 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3518 if (new_node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3519 for (var i in new_node.contents) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3520 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3521 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3522 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3523 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3524 // do the internal rewiring\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3525 delete old_node.parent.contents[old_node.name];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3526 old_node.name = new_name;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3527 new_dir.contents[new_name] = old_node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3528 },unlink:function (parent, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3529 delete parent.contents[name];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3530 },rmdir:function (parent, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3531 var node = FS.lookupNode(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3532 for (var i in node.contents) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3533 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3534 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3535 delete parent.contents[name];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3536 },readdir:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3537 var entries = ['.', '..']\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3538 for (var key in node.contents) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3539 if (!node.contents.hasOwnProperty(key)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3540 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3541 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3542 entries.push(key);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3543 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3544 return entries;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3545 },symlink:function (parent, newname, oldpath) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3546 var node = MEMFS.create_node(parent, newname, 0777 | 0120000, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3547 node.link = oldpath;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3548 return node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3549 },readlink:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3550 if (!FS.isLink(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3551 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3552 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3553 return node.link;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3554 }},stream_ops:{read:function (stream, buffer, offset, length, position) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3555 var contents = stream.node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3556 var size = Math.min(contents.length - position, length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3557 if (size > 8 && contents.subarray) { // non-trivial, and typed array\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3558 buffer.set(contents.subarray(position, position + size), offset);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3559 } else\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3560 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3561 for (var i = 0; i < size; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3562 buffer[offset + i] = contents[position + i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3563 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3564 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3565 return size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3566 },write:function (stream, buffer, offset, length, position, canOwn) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3567 var node = stream.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3568 node.timestamp = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3569 var contents = node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3570 if (length && contents.length === 0 && position === 0 && buffer.subarray) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3571 // just replace it with the new data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3572 assert(buffer.length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3573 if (canOwn && buffer.buffer === HEAP8.buffer && offset === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3574 node.contents = buffer; // this is a subarray of the heap, and we can own it\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3575 node.contentMode = MEMFS.CONTENT_OWNING;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3576 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3577 node.contents = new Uint8Array(buffer.subarray(offset, offset+length));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3578 node.contentMode = MEMFS.CONTENT_FIXED;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3579 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3580 return length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3581 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3582 MEMFS.ensureFlexible(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3583 var contents = node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3584 while (contents.length < position) contents.push(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3585 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3586 contents[position + i] = buffer[offset + i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3587 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3588 return length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3589 },llseek:function (stream, offset, whence) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3590 var position = offset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3591 if (whence === 1) { // SEEK_CUR.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3592 position += stream.position;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3593 } else if (whence === 2) { // SEEK_END.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3594 if (FS.isFile(stream.node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3595 position += stream.node.contents.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3596 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3597 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3598 if (position < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3599 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3600 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3601 stream.ungotten = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3602 stream.position = position;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3603 return position;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3604 },allocate:function (stream, offset, length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3605 MEMFS.ensureFlexible(stream.node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3606 var contents = stream.node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3607 var limit = offset + length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3608 while (limit > contents.length) contents.push(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3609 },mmap:function (stream, buffer, offset, length, position, prot, flags) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3610 if (!FS.isFile(stream.node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3611 throw new FS.ErrnoError(ERRNO_CODES.ENODEV);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3612 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3613 var ptr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3614 var allocated;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3615 var contents = stream.node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3616 // Only make a new copy when MAP_PRIVATE is specified.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3617 if ( !(flags & 0x02) &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3618 (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3619 // We can't emulate MAP_SHARED when the file is not backed by the buffer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3620 // we're mapping to (e.g. the HEAP buffer).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3621 allocated = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3622 ptr = contents.byteOffset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3623 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3624 // Try to avoid unnecessary slices.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3625 if (position > 0 || position + length < contents.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3626 if (contents.subarray) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3627 contents = contents.subarray(position, position + length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3628 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3629 contents = Array.prototype.slice.call(contents, position, position + length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3630 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3631 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3632 allocated = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3633 ptr = _malloc(length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3634 if (!ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3635 throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3636 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3637 buffer.set(contents, ptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3638 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3639 return { ptr: ptr, allocated: allocated };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3640 }}};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3641 var _stdin=allocate(1, \"i32*\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3642 var _stdout=allocate(1, \"i32*\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3643 var _stderr=allocate(1, \"i32*\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3644 function _fflush(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3645 // int fflush(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3646 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3647 // we don't currently perform any user-space buffering of data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3648 }var FS={root:null,devices:[null],streams:[null],nextInode:1,nameTable:null,currentPath:\"/\",initialized:false,ignorePermissions:true,ErrnoError:function ErrnoError(errno) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3649 this.errno = errno;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3650 for (var key in ERRNO_CODES) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3651 if (ERRNO_CODES[key] === errno) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3652 this.code = key;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3653 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3654 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3655 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3656 this.message = ERRNO_MESSAGES[errno];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3657 },handleFSError:function (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3658 if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + new Error().stack;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3659 return ___setErrNo(e.errno);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3660 },cwd:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3661 return FS.currentPath;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3662 },lookupPath:function (path, opts) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3663 path = PATH.resolve(FS.currentPath, path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3664 opts = opts || { recurse_count: 0 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3665 if (opts.recurse_count > 8) { // max recursive lookup of 8\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3666 throw new FS.ErrnoError(ERRNO_CODES.ELOOP);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3667 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3668 // split the path\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3669 var parts = PATH.normalizeArray(path.split('/').filter(function(p) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3670 return !!p;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3671 }), false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3672 // start at the root\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3673 var current = FS.root;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3674 var current_path = '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3675 for (var i = 0; i < parts.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3676 var islast = (i === parts.length-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3677 if (islast && opts.parent) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3678 // stop resolving\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3679 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3680 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3681 current = FS.lookupNode(current, parts[i]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3682 current_path = PATH.join(current_path, parts[i]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3683 // jump to the mount's root node if this is a mountpoint\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3684 if (FS.isMountpoint(current)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3685 current = current.mount.root;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3686 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3687 // follow symlinks\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3688 // by default, lookupPath will not follow a symlink if it is the final path component.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3689 // setting opts.follow = true will override this behavior.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3690 if (!islast || opts.follow) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3691 var count = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3692 while (FS.isLink(current.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3693 var link = FS.readlink(current_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3694 current_path = PATH.resolve(PATH.dirname(current_path), link);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3695 var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3696 current = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3697 if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3698 throw new FS.ErrnoError(ERRNO_CODES.ELOOP);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3699 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3700 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3701 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3702 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3703 return { path: current_path, node: current };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3704 },getPath:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3705 var path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3706 while (true) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3707 if (FS.isRoot(node)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3708 return path ? PATH.join(node.mount.mountpoint, path) : node.mount.mountpoint;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3709 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3710 path = path ? PATH.join(node.name, path) : node.name;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3711 node = node.parent;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3712 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3713 },hashName:function (parentid, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3714 var hash = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3715 for (var i = 0; i < name.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3716 hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3717 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3718 return ((parentid + hash) >>> 0) % FS.nameTable.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3719 },hashAddNode:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3720 var hash = FS.hashName(node.parent.id, node.name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3721 node.name_next = FS.nameTable[hash];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3722 FS.nameTable[hash] = node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3723 },hashRemoveNode:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3724 var hash = FS.hashName(node.parent.id, node.name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3725 if (FS.nameTable[hash] === node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3726 FS.nameTable[hash] = node.name_next;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3727 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3728 var current = FS.nameTable[hash];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3729 while (current) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3730 if (current.name_next === node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3731 current.name_next = node.name_next;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3732 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3733 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3734 current = current.name_next;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3735 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3736 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3737 },lookupNode:function (parent, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3738 var err = FS.mayLookup(parent);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3739 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3740 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3741 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3742 var hash = FS.hashName(parent.id, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3743 for (var node = FS.nameTable[hash]; node; node = node.name_next) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3744 if (node.parent.id === parent.id && node.name === name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3745 return node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3746 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3747 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3748 // if we failed to find it in the cache, call into the VFS\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3749 return FS.lookup(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3750 },createNode:function (parent, name, mode, rdev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3751 var node = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3752 id: FS.nextInode++,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3753 name: name,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3754 mode: mode,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3755 node_ops: {},\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3756 stream_ops: {},\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3757 rdev: rdev,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3758 parent: null,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3759 mount: null\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3760 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3761 if (!parent) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3762 parent = node; // root node sets parent to itself\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3763 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3764 node.parent = parent;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3765 node.mount = parent.mount;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3766 // compatibility\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3767 var readMode = 292 | 73;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3768 var writeMode = 146;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3769 // NOTE we must use Object.defineProperties instead of individual calls to\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3770 // Object.defineProperty in order to make closure compiler happy\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3771 Object.defineProperties(node, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3772 read: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3773 get: function() { return (node.mode & readMode) === readMode; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3774 set: function(val) { val ? node.mode |= readMode : node.mode &= ~readMode; }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3775 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3776 write: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3777 get: function() { return (node.mode & writeMode) === writeMode; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3778 set: function(val) { val ? node.mode |= writeMode : node.mode &= ~writeMode; }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3779 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3780 isFolder: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3781 get: function() { return FS.isDir(node.mode); },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3782 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3783 isDevice: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3784 get: function() { return FS.isChrdev(node.mode); },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3785 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3786 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3787 FS.hashAddNode(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3788 return node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3789 },destroyNode:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3790 FS.hashRemoveNode(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3791 },isRoot:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3792 return node === node.parent;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3793 },isMountpoint:function (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3794 return node.mounted;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3795 },isFile:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3796 return (mode & 0170000) === 0100000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3797 },isDir:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3798 return (mode & 0170000) === 0040000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3799 },isLink:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3800 return (mode & 0170000) === 0120000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3801 },isChrdev:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3802 return (mode & 0170000) === 0020000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3803 },isBlkdev:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3804 return (mode & 0170000) === 0060000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3805 },isFIFO:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3806 return (mode & 0170000) === 0010000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3807 },isSocket:function (mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3808 return (mode & 0140000) === 0140000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3809 },flagModes:{\"r\":0,\"rs\":8192,\"r+\":2,\"w\":1537,\"wx\":3585,\"xw\":3585,\"w+\":1538,\"wx+\":3586,\"xw+\":3586,\"a\":521,\"ax\":2569,\"xa\":2569,\"a+\":522,\"ax+\":2570,\"xa+\":2570},modeStringToFlags:function (str) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3810 var flags = FS.flagModes[str];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3811 if (typeof flags === 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3812 throw new Error('Unknown file open mode: ' + str);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3813 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3814 return flags;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3815 },flagsToPermissionString:function (flag) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3816 var accmode = flag & 3;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3817 var perms = ['r', 'w', 'rw'][accmode];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3818 if ((flag & 1024)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3819 perms += 'w';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3820 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3821 return perms;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3822 },nodePermissions:function (node, perms) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3823 if (FS.ignorePermissions) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3824 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3825 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3826 // return 0 if any user, group or owner bits are set.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3827 if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3828 return ERRNO_CODES.EACCES;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3829 } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3830 return ERRNO_CODES.EACCES;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3831 } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3832 return ERRNO_CODES.EACCES;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3833 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3834 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3835 },mayLookup:function (dir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3836 return FS.nodePermissions(dir, 'x');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3837 },mayCreate:function (dir, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3838 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3839 var node = FS.lookupNode(dir, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3840 return ERRNO_CODES.EEXIST;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3841 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3842 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3843 return FS.nodePermissions(dir, 'wx');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3844 },mayDelete:function (dir, name, isdir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3845 var node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3846 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3847 node = FS.lookupNode(dir, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3848 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3849 return e.errno;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3850 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3851 var err = FS.nodePermissions(dir, 'wx');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3852 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3853 return err;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3854 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3855 if (isdir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3856 if (!FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3857 return ERRNO_CODES.ENOTDIR;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3858 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3859 if (FS.isRoot(node) || FS.getPath(node) === FS.currentPath) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3860 return ERRNO_CODES.EBUSY;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3861 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3862 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3863 if (FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3864 return ERRNO_CODES.EISDIR;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3865 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3866 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3867 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3868 },mayOpen:function (node, flags) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3869 if (!node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3870 return ERRNO_CODES.ENOENT;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3871 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3872 if (FS.isLink(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3873 return ERRNO_CODES.ELOOP;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3874 } else if (FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3875 if ((flags & 3) !== 0 || // opening for write\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3876 (flags & 1024)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3877 return ERRNO_CODES.EISDIR;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3878 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3879 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3880 return FS.nodePermissions(node, FS.flagsToPermissionString(flags));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3881 },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3882 fd_start = fd_start || 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3883 fd_end = fd_end || FS.MAX_OPEN_FDS;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3884 for (var fd = fd_start; fd <= fd_end; fd++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3885 if (!FS.streams[fd]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3886 return fd;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3887 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3888 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3889 throw new FS.ErrnoError(ERRNO_CODES.EMFILE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3890 },getStream:function (fd) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3891 return FS.streams[fd];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3892 },createStream:function (stream, fd_start, fd_end) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3893 var fd = FS.nextfd(fd_start, fd_end);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3894 stream.fd = fd;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3895 // compatibility\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3896 Object.defineProperties(stream, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3897 object: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3898 get: function() { return stream.node; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3899 set: function(val) { stream.node = val; }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3900 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3901 isRead: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3902 get: function() { return (stream.flags & 3) !== 1; }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3903 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3904 isWrite: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3905 get: function() { return (stream.flags & 3) !== 0; }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3906 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3907 isAppend: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3908 get: function() { return (stream.flags & 8); }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3909 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3910 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3911 FS.streams[fd] = stream;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3912 return stream;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3913 },closeStream:function (fd) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3914 FS.streams[fd] = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3915 },chrdev_stream_ops:{open:function (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3916 var device = FS.getDevice(stream.node.rdev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3917 // override node's stream ops with the device's\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3918 stream.stream_ops = device.stream_ops;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3919 // forward the open call\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3920 if (stream.stream_ops.open) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3921 stream.stream_ops.open(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3922 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3923 },llseek:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3924 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3925 }},major:function (dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3926 return ((dev) >> 8);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3927 },minor:function (dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3928 return ((dev) & 0xff);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3929 },makedev:function (ma, mi) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3930 return ((ma) << 8 | (mi));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3931 },registerDevice:function (dev, ops) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3932 FS.devices[dev] = { stream_ops: ops };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3933 },getDevice:function (dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3934 return FS.devices[dev];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3935 },mount:function (type, opts, mountpoint) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3936 var mount = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3937 type: type,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3938 opts: opts,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3939 mountpoint: mountpoint,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3940 root: null\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3941 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3942 var lookup;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3943 if (mountpoint) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3944 lookup = FS.lookupPath(mountpoint, { follow: false });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3945 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3946 // create a root node for the fs\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3947 var root = type.mount(mount);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3948 root.mount = mount;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3949 mount.root = root;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3950 // assign the mount info to the mountpoint's node\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3951 if (lookup) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3952 lookup.node.mount = mount;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3953 lookup.node.mounted = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3954 // compatibility update FS.root if we mount to /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3955 if (mountpoint === '/') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3956 FS.root = mount.root;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3957 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3958 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3959 return root;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3960 },lookup:function (parent, name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3961 return parent.node_ops.lookup(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3962 },mknod:function (path, mode, dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3963 var lookup = FS.lookupPath(path, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3964 var parent = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3965 var name = PATH.basename(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3966 var err = FS.mayCreate(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3967 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3968 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3969 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3970 if (!parent.node_ops.mknod) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3971 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3972 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3973 return parent.node_ops.mknod(parent, name, mode, dev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3974 },create:function (path, mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3975 mode = mode !== undefined ? mode : 0666;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3976 mode &= 4095;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3977 mode |= 0100000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3978 return FS.mknod(path, mode, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3979 },mkdir:function (path, mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3980 mode = mode !== undefined ? mode : 0777;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3981 mode &= 511 | 0001000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3982 mode |= 0040000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3983 return FS.mknod(path, mode, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3984 },mkdev:function (path, mode, dev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3985 if (typeof(dev) === 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3986 dev = mode;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3987 mode = 0666;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3988 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3989 mode |= 0020000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3990 return FS.mknod(path, mode, dev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3991 },symlink:function (oldpath, newpath) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3992 var lookup = FS.lookupPath(newpath, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3993 var parent = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3994 var newname = PATH.basename(newpath);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3995 var err = FS.mayCreate(parent, newname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3996 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3997 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3998 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3999 if (!parent.node_ops.symlink) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4000 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4001 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4002 return parent.node_ops.symlink(parent, newname, oldpath);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4003 },rename:function (old_path, new_path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4004 var old_dirname = PATH.dirname(old_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4005 var new_dirname = PATH.dirname(new_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4006 var old_name = PATH.basename(old_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4007 var new_name = PATH.basename(new_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4008 // parents must exist\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4009 var lookup, old_dir, new_dir;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4010 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4011 lookup = FS.lookupPath(old_path, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4012 old_dir = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4013 lookup = FS.lookupPath(new_path, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4014 new_dir = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4015 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4016 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4017 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4018 // need to be part of the same mount\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4019 if (old_dir.mount !== new_dir.mount) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4020 throw new FS.ErrnoError(ERRNO_CODES.EXDEV);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4021 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4022 // source must exist\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4023 var old_node = FS.lookupNode(old_dir, old_name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4024 // old path should not be an ancestor of the new path\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4025 var relative = PATH.relative(old_path, new_dirname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4026 if (relative.charAt(0) !== '.') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4027 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4028 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4029 // new path should not be an ancestor of the old path\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4030 relative = PATH.relative(new_path, old_dirname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4031 if (relative.charAt(0) !== '.') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4032 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4033 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4034 // see if the new path already exists\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4035 var new_node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4036 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4037 new_node = FS.lookupNode(new_dir, new_name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4038 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4039 // not fatal\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4040 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4041 // early out if nothing needs to change\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4042 if (old_node === new_node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4043 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4044 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4045 // we'll need to delete the old entry\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4046 var isdir = FS.isDir(old_node.mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4047 var err = FS.mayDelete(old_dir, old_name, isdir);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4048 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4049 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4050 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4051 // need delete permissions if we'll be overwriting.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4052 // need create permissions if new doesn't already exist.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4053 err = new_node ?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4054 FS.mayDelete(new_dir, new_name, isdir) :\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4055 FS.mayCreate(new_dir, new_name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4056 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4057 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4058 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4059 if (!old_dir.node_ops.rename) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4060 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4061 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4062 if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4063 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4064 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4065 // if we are going to change the parent, check write permissions\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4066 if (new_dir !== old_dir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4067 err = FS.nodePermissions(old_dir, 'w');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4068 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4069 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4070 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4071 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4072 // remove the node from the lookup hash\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4073 FS.hashRemoveNode(old_node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4074 // do the underlying fs rename\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4075 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4076 old_dir.node_ops.rename(old_node, new_dir, new_name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4077 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4078 throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4079 } finally {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4080 // add the node back to the hash (in case node_ops.rename\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4081 // changed its name)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4082 FS.hashAddNode(old_node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4083 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4084 },rmdir:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4085 var lookup = FS.lookupPath(path, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4086 var parent = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4087 var name = PATH.basename(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4088 var node = FS.lookupNode(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4089 var err = FS.mayDelete(parent, name, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4090 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4091 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4092 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4093 if (!parent.node_ops.rmdir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4094 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4095 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4096 if (FS.isMountpoint(node)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4097 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4098 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4099 parent.node_ops.rmdir(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4100 FS.destroyNode(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4101 },readdir:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4102 var lookup = FS.lookupPath(path, { follow: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4103 var node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4104 if (!node.node_ops.readdir) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4105 throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4106 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4107 return node.node_ops.readdir(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4108 },unlink:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4109 var lookup = FS.lookupPath(path, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4110 var parent = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4111 var name = PATH.basename(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4112 var node = FS.lookupNode(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4113 var err = FS.mayDelete(parent, name, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4114 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4115 // POSIX says unlink should set EPERM, not EISDIR\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4116 if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4117 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4118 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4119 if (!parent.node_ops.unlink) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4120 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4121 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4122 if (FS.isMountpoint(node)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4123 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4124 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4125 parent.node_ops.unlink(parent, name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4126 FS.destroyNode(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4127 },readlink:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4128 var lookup = FS.lookupPath(path, { follow: false });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4129 var link = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4130 if (!link.node_ops.readlink) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4131 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4132 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4133 return link.node_ops.readlink(link);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4134 },stat:function (path, dontFollow) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4135 var lookup = FS.lookupPath(path, { follow: !dontFollow });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4136 var node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4137 if (!node.node_ops.getattr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4138 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4139 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4140 return node.node_ops.getattr(node);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4141 },lstat:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4142 return FS.stat(path, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4143 },chmod:function (path, mode, dontFollow) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4144 var node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4145 if (typeof path === 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4146 var lookup = FS.lookupPath(path, { follow: !dontFollow });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4147 node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4148 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4149 node = path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4150 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4151 if (!node.node_ops.setattr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4152 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4153 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4154 node.node_ops.setattr(node, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4155 mode: (mode & 4095) | (node.mode & ~4095),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4156 timestamp: Date.now()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4157 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4158 },lchmod:function (path, mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4159 FS.chmod(path, mode, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4160 },fchmod:function (fd, mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4161 var stream = FS.getStream(fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4162 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4163 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4164 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4165 FS.chmod(stream.node, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4166 },chown:function (path, uid, gid, dontFollow) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4167 var node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4168 if (typeof path === 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4169 var lookup = FS.lookupPath(path, { follow: !dontFollow });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4170 node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4171 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4172 node = path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4173 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4174 if (!node.node_ops.setattr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4175 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4176 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4177 node.node_ops.setattr(node, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4178 timestamp: Date.now()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4179 // we ignore the uid / gid for now\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4180 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4181 },lchown:function (path, uid, gid) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4182 FS.chown(path, uid, gid, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4183 },fchown:function (fd, uid, gid) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4184 var stream = FS.getStream(fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4185 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4186 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4187 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4188 FS.chown(stream.node, uid, gid);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4189 },truncate:function (path, len) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4190 if (len < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4191 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4192 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4193 var node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4194 if (typeof path === 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4195 var lookup = FS.lookupPath(path, { follow: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4196 node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4197 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4198 node = path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4199 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4200 if (!node.node_ops.setattr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4201 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4202 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4203 if (FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4204 throw new FS.ErrnoError(ERRNO_CODES.EISDIR);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4205 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4206 if (!FS.isFile(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4207 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4208 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4209 var err = FS.nodePermissions(node, 'w');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4210 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4211 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4212 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4213 node.node_ops.setattr(node, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4214 size: len,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4215 timestamp: Date.now()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4216 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4217 },ftruncate:function (fd, len) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4218 var stream = FS.getStream(fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4219 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4220 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4221 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4222 if ((stream.flags & 3) === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4223 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4224 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4225 FS.truncate(stream.node, len);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4226 },utime:function (path, atime, mtime) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4227 var lookup = FS.lookupPath(path, { follow: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4228 var node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4229 node.node_ops.setattr(node, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4230 timestamp: Math.max(atime, mtime)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4231 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4232 },open:function (path, flags, mode, fd_start, fd_end) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4233 path = PATH.normalize(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4234 flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4235 mode = typeof mode === 'undefined' ? 0666 : mode;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4236 if ((flags & 512)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4237 mode = (mode & 4095) | 0100000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4238 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4239 mode = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4240 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4241 var node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4242 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4243 var lookup = FS.lookupPath(path, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4244 follow: !(flags & 0200000)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4245 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4246 node = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4247 path = lookup.path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4248 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4249 // ignore\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4250 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4251 // perhaps we need to create the node\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4252 if ((flags & 512)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4253 if (node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4254 // if O_CREAT and O_EXCL are set, error out if the node already exists\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4255 if ((flags & 2048)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4256 throw new FS.ErrnoError(ERRNO_CODES.EEXIST);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4257 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4258 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4259 // node doesn't exist, try to create it\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4260 node = FS.mknod(path, mode, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4261 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4262 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4263 if (!node) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4264 throw new FS.ErrnoError(ERRNO_CODES.ENOENT);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4265 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4266 // can't truncate a device\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4267 if (FS.isChrdev(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4268 flags &= ~1024;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4269 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4270 // check permissions\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4271 var err = FS.mayOpen(node, flags);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4272 if (err) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4273 throw new FS.ErrnoError(err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4274 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4275 // do truncation if necessary\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4276 if ((flags & 1024)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4277 FS.truncate(node, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4278 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4279 // register the stream with the filesystem\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4280 var stream = FS.createStream({\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4281 path: path,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4282 node: node,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4283 flags: flags,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4284 seekable: true,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4285 position: 0,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4286 stream_ops: node.stream_ops,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4287 // used by the file family libc calls (fopen, fwrite, ferror, etc.)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4288 ungotten: [],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4289 error: false\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4290 }, fd_start, fd_end);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4291 // call the new stream's open function\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4292 if (stream.stream_ops.open) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4293 stream.stream_ops.open(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4294 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4295 return stream;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4296 },close:function (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4297 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4298 if (stream.stream_ops.close) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4299 stream.stream_ops.close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4300 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4301 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4302 throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4303 } finally {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4304 FS.closeStream(stream.fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4305 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4306 },llseek:function (stream, offset, whence) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4307 if (!stream.seekable || !stream.stream_ops.llseek) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4308 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4309 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4310 return stream.stream_ops.llseek(stream, offset, whence);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4311 },read:function (stream, buffer, offset, length, position) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4312 if (length < 0 || position < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4313 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4314 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4315 if ((stream.flags & 3) === 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4316 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4317 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4318 if (FS.isDir(stream.node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4319 throw new FS.ErrnoError(ERRNO_CODES.EISDIR);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4320 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4321 if (!stream.stream_ops.read) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4322 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4323 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4324 var seeking = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4325 if (typeof position === 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4326 position = stream.position;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4327 seeking = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4328 } else if (!stream.seekable) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4329 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4330 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4331 var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4332 if (!seeking) stream.position += bytesRead;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4333 return bytesRead;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4334 },write:function (stream, buffer, offset, length, position, canOwn) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4335 if (length < 0 || position < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4336 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4337 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4338 if ((stream.flags & 3) === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4339 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4340 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4341 if (FS.isDir(stream.node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4342 throw new FS.ErrnoError(ERRNO_CODES.EISDIR);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4343 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4344 if (!stream.stream_ops.write) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4345 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4346 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4347 var seeking = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4348 if (typeof position === 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4349 position = stream.position;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4350 seeking = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4351 } else if (!stream.seekable) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4352 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4353 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4354 if (stream.flags & 8) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4355 // seek to the end before writing in append mode\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4356 FS.llseek(stream, 0, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4357 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4358 var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4359 if (!seeking) stream.position += bytesWritten;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4360 return bytesWritten;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4361 },allocate:function (stream, offset, length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4362 if (offset < 0 || length <= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4363 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4364 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4365 if ((stream.flags & 3) === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4366 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4367 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4368 if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4369 throw new FS.ErrnoError(ERRNO_CODES.ENODEV);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4370 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4371 if (!stream.stream_ops.allocate) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4372 throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4373 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4374 stream.stream_ops.allocate(stream, offset, length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4375 },mmap:function (stream, buffer, offset, length, position, prot, flags) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4376 // TODO if PROT is PROT_WRITE, make sure we have write access\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4377 if ((stream.flags & 3) === 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4378 throw new FS.ErrnoError(ERRNO_CODES.EACCES);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4379 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4380 if (!stream.stream_ops.mmap) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4381 throw new FS.errnoError(ERRNO_CODES.ENODEV);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4382 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4383 return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4384 },ioctl:function (stream, cmd, arg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4385 if (!stream.stream_ops.ioctl) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4386 throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4387 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4388 return stream.stream_ops.ioctl(stream, cmd, arg);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4389 },readFile:function (path, opts) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4390 opts = opts || {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4391 opts.flags = opts.flags || 'r';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4392 opts.encoding = opts.encoding || 'binary';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4393 var ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4394 var stream = FS.open(path, opts.flags);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4395 var stat = FS.stat(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4396 var length = stat.size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4397 var buf = new Uint8Array(length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4398 FS.read(stream, buf, 0, length, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4399 if (opts.encoding === 'utf8') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4400 ret = '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4401 var utf8 = new Runtime.UTF8Processor();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4402 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4403 ret += utf8.processCChar(buf[i]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4404 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4405 } else if (opts.encoding === 'binary') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4406 ret = buf;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4407 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4408 throw new Error('Invalid encoding type \"' + opts.encoding + '\"');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4409 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4410 FS.close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4411 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4412 },writeFile:function (path, data, opts) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4413 opts = opts || {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4414 opts.flags = opts.flags || 'w';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4415 opts.encoding = opts.encoding || 'utf8';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4416 var stream = FS.open(path, opts.flags, opts.mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4417 if (opts.encoding === 'utf8') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4418 var utf8 = new Runtime.UTF8Processor();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4419 var buf = new Uint8Array(utf8.processJSString(data));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4420 FS.write(stream, buf, 0, buf.length, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4421 } else if (opts.encoding === 'binary') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4422 FS.write(stream, data, 0, data.length, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4423 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4424 throw new Error('Invalid encoding type \"' + opts.encoding + '\"');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4425 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4426 FS.close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4427 },createDefaultDirectories:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4428 FS.mkdir('/tmp');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4429 },createDefaultDevices:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4430 // create /dev\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4431 FS.mkdir('/dev');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4432 // setup /dev/null\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4433 FS.registerDevice(FS.makedev(1, 3), {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4434 read: function() { return 0; },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4435 write: function() { return 0; }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4436 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4437 FS.mkdev('/dev/null', FS.makedev(1, 3));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4438 // setup /dev/tty and /dev/tty1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4439 // stderr needs to print output using Module['printErr']\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4440 // so we register a second tty just for it.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4441 TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4442 TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4443 FS.mkdev('/dev/tty', FS.makedev(5, 0));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4444 FS.mkdev('/dev/tty1', FS.makedev(6, 0));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4445 // we're not going to emulate the actual shm device,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4446 // just create the tmp dirs that reside in it commonly\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4447 FS.mkdir('/dev/shm');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4448 FS.mkdir('/dev/shm/tmp');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4449 },createStandardStreams:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4450 // TODO deprecate the old functionality of a single\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4451 // input / output callback and that utilizes FS.createDevice\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4452 // and instead require a unique set of stream ops\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4453 // by default, we symlink the standard streams to the\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4454 // default tty devices. however, if the standard streams\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4455 // have been overwritten we create a unique device for\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4456 // them instead.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4457 if (Module['stdin']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4458 FS.createDevice('/dev', 'stdin', Module['stdin']);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4459 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4460 FS.symlink('/dev/tty', '/dev/stdin');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4461 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4462 if (Module['stdout']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4463 FS.createDevice('/dev', 'stdout', null, Module['stdout']);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4464 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4465 FS.symlink('/dev/tty', '/dev/stdout');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4466 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4467 if (Module['stderr']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4468 FS.createDevice('/dev', 'stderr', null, Module['stderr']);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4469 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4470 FS.symlink('/dev/tty1', '/dev/stderr');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4471 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4472 // open default streams for the stdin, stdout and stderr devices\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4473 var stdin = FS.open('/dev/stdin', 'r');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4474 HEAP32[((_stdin)>>2)]=stdin.fd;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4475 assert(stdin.fd === 1, 'invalid handle for stdin (' + stdin.fd + ')');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4476 var stdout = FS.open('/dev/stdout', 'w');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4477 HEAP32[((_stdout)>>2)]=stdout.fd;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4478 assert(stdout.fd === 2, 'invalid handle for stdout (' + stdout.fd + ')');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4479 var stderr = FS.open('/dev/stderr', 'w');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4480 HEAP32[((_stderr)>>2)]=stderr.fd;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4481 assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4482 },staticInit:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4483 FS.nameTable = new Array(4096);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4484 FS.root = FS.createNode(null, '/', 0040000 | 0777, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4485 FS.mount(MEMFS, {}, '/');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4486 FS.createDefaultDirectories();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4487 FS.createDefaultDevices();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4488 },init:function (input, output, error) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4489 assert(!FS.init.initialized, 'FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4490 FS.init.initialized = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4491 // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4492 Module['stdin'] = input || Module['stdin'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4493 Module['stdout'] = output || Module['stdout'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4494 Module['stderr'] = error || Module['stderr'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4495 FS.createStandardStreams();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4496 },quit:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4497 FS.init.initialized = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4498 for (var i = 0; i < FS.streams.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4499 var stream = FS.streams[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4500 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4501 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4502 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4503 FS.close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4504 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4505 },getMode:function (canRead, canWrite) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4506 var mode = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4507 if (canRead) mode |= 292 | 73;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4508 if (canWrite) mode |= 146;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4509 return mode;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4510 },joinPath:function (parts, forceRelative) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4511 var path = PATH.join.apply(null, parts);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4512 if (forceRelative && path[0] == '/') path = path.substr(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4513 return path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4514 },absolutePath:function (relative, base) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4515 return PATH.resolve(base, relative);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4516 },standardizePath:function (path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4517 return PATH.normalize(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4518 },findObject:function (path, dontResolveLastLink) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4519 var ret = FS.analyzePath(path, dontResolveLastLink);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4520 if (ret.exists) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4521 return ret.object;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4522 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4523 ___setErrNo(ret.error);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4524 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4525 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4526 },analyzePath:function (path, dontResolveLastLink) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4527 // operate from within the context of the symlink's target\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4528 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4529 var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4530 path = lookup.path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4531 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4532 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4533 var ret = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4534 isRoot: false, exists: false, error: 0, name: null, path: null, object: null,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4535 parentExists: false, parentPath: null, parentObject: null\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4536 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4537 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4538 var lookup = FS.lookupPath(path, { parent: true });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4539 ret.parentExists = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4540 ret.parentPath = lookup.path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4541 ret.parentObject = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4542 ret.name = PATH.basename(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4543 lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4544 ret.exists = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4545 ret.path = lookup.path;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4546 ret.object = lookup.node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4547 ret.name = lookup.node.name;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4548 ret.isRoot = lookup.path === '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4549 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4550 ret.error = e.errno;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4551 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4552 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4553 },createFolder:function (parent, name, canRead, canWrite) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4554 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4555 var mode = FS.getMode(canRead, canWrite);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4556 return FS.mkdir(path, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4557 },createPath:function (parent, path, canRead, canWrite) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4558 parent = typeof parent === 'string' ? parent : FS.getPath(parent);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4559 var parts = path.split('/').reverse();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4560 while (parts.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4561 var part = parts.pop();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4562 if (!part) continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4563 var current = PATH.join(parent, part);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4564 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4565 FS.mkdir(current);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4566 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4567 // ignore EEXIST\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4568 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4569 parent = current;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4570 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4571 return current;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4572 },createFile:function (parent, name, properties, canRead, canWrite) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4573 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4574 var mode = FS.getMode(canRead, canWrite);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4575 return FS.create(path, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4576 },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4577 var path = name ? PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4578 var mode = FS.getMode(canRead, canWrite);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4579 var node = FS.create(path, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4580 if (data) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4581 if (typeof data === 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4582 var arr = new Array(data.length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4583 for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4584 data = arr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4585 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4586 // make sure we can write to the file\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4587 FS.chmod(path, mode | 146);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4588 var stream = FS.open(path, 'w');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4589 FS.write(stream, data, 0, data.length, 0, canOwn);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4590 FS.close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4591 FS.chmod(path, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4592 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4593 return node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4594 },createDevice:function (parent, name, input, output) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4595 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4596 var mode = FS.getMode(!!input, !!output);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4597 if (!FS.createDevice.major) FS.createDevice.major = 64;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4598 var dev = FS.makedev(FS.createDevice.major++, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4599 // Create a fake device that a set of stream ops to emulate\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4600 // the old behavior.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4601 FS.registerDevice(dev, {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4602 open: function(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4603 stream.seekable = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4604 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4605 close: function(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4606 // flush any pending line data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4607 if (output && output.buffer && output.buffer.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4608 output(10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4609 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4610 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4611 read: function(stream, buffer, offset, length, pos /* ignored */) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4612 var bytesRead = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4613 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4614 var result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4615 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4616 result = input();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4617 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4618 throw new FS.ErrnoError(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4619 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4620 if (result === undefined && bytesRead === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4621 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4622 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4623 if (result === null || result === undefined) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4624 bytesRead++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4625 buffer[offset+i] = result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4626 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4627 if (bytesRead) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4628 stream.node.timestamp = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4629 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4630 return bytesRead;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4631 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4632 write: function(stream, buffer, offset, length, pos) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4633 for (var i = 0; i < length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4634 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4635 output(buffer[offset+i]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4636 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4637 throw new FS.ErrnoError(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4638 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4639 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4640 if (length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4641 stream.node.timestamp = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4642 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4643 return i;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4644 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4645 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4646 return FS.mkdev(path, mode, dev);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4647 },createLink:function (parent, name, target, canRead, canWrite) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4648 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4649 return FS.symlink(target, path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4650 },forceLoadFile:function (obj) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4651 if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4652 var success = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4653 if (typeof XMLHttpRequest !== 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4654 throw new Error(\"Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4655 } else if (Module['read']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4656 // Command-line.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4657 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4658 // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4659 // read() will try to parse UTF8.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4660 obj.contents = intArrayFromString(Module['read'](obj.url), true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4661 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4662 success = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4663 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4664 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4665 throw new Error('Cannot load without read() or XMLHttpRequest.');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4666 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4667 if (!success) ___setErrNo(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4668 return success;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4669 },createLazyFile:function (parent, name, url, canRead, canWrite) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4670 if (typeof XMLHttpRequest !== 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4671 if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4672 // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4673 var LazyUint8Array = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4674 this.lengthKnown = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4675 this.chunks = []; // Loaded chunks. Index is the chunk number\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4676 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4677 LazyUint8Array.prototype.get = function(idx) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4678 if (idx > this.length-1 || idx < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4679 return undefined;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4680 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4681 var chunkOffset = idx % this.chunkSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4682 var chunkNum = Math.floor(idx / this.chunkSize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4683 return this.getter(chunkNum)[chunkOffset];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4684 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4685 LazyUint8Array.prototype.setDataGetter = function(getter) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4686 this.getter = getter;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4687 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4688 LazyUint8Array.prototype.cacheLength = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4689 // Find length\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4690 var xhr = new XMLHttpRequest();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4691 xhr.open('HEAD', url, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4692 xhr.send(null);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4693 if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error(\"Couldn't load \" + url + \". Status: \" + xhr.status);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4694 var datalength = Number(xhr.getResponseHeader(\"Content-length\"));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4695 var header;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4696 var hasByteServing = (header = xhr.getResponseHeader(\"Accept-Ranges\")) && header === \"bytes\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4697 var chunkSize = 1024*1024; // Chunk size in bytes\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4698 if (!hasByteServing) chunkSize = datalength;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4699 // Function to get a range from the remote URL.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4700 var doXHR = (function(from, to) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4701 if (from > to) throw new Error(\"invalid range (\" + from + \", \" + to + \") or no bytes requested!\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4702 if (to > datalength-1) throw new Error(\"only \" + datalength + \" bytes available! programmer error!\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4703 // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4704 var xhr = new XMLHttpRequest();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4705 xhr.open('GET', url, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4706 if (datalength !== chunkSize) xhr.setRequestHeader(\"Range\", \"bytes=\" + from + \"-\" + to);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4707 // Some hints to the browser that we want binary data.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4708 if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4709 if (xhr.overrideMimeType) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4710 xhr.overrideMimeType('text/plain; charset=x-user-defined');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4711 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4712 xhr.send(null);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4713 if (!(xhr.status >= 200 && xhr.status < 300 || xhr.status === 304)) throw new Error(\"Couldn't load \" + url + \". Status: \" + xhr.status);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4714 if (xhr.response !== undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4715 return new Uint8Array(xhr.response || []);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4716 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4717 return intArrayFromString(xhr.responseText || '', true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4718 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4719 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4720 var lazyArray = this;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4721 lazyArray.setDataGetter(function(chunkNum) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4722 var start = chunkNum * chunkSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4723 var end = (chunkNum+1) * chunkSize - 1; // including this byte\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4724 end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4725 if (typeof(lazyArray.chunks[chunkNum]) === \"undefined\") {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4726 lazyArray.chunks[chunkNum] = doXHR(start, end);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4727 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4728 if (typeof(lazyArray.chunks[chunkNum]) === \"undefined\") throw new Error(\"doXHR failed!\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4729 return lazyArray.chunks[chunkNum];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4730 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4731 this._length = datalength;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4732 this._chunkSize = chunkSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4733 this.lengthKnown = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4734 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4735 var lazyArray = new LazyUint8Array();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4736 Object.defineProperty(lazyArray, \"length\", {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4737 get: function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4738 if(!this.lengthKnown) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4739 this.cacheLength();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4740 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4741 return this._length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4742 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4743 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4744 Object.defineProperty(lazyArray, \"chunkSize\", {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4745 get: function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4746 if(!this.lengthKnown) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4747 this.cacheLength();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4748 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4749 return this._chunkSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4750 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4751 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4752 var properties = { isDevice: false, contents: lazyArray };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4753 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4754 var properties = { isDevice: false, url: url };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4755 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4756 var node = FS.createFile(parent, name, properties, canRead, canWrite);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4757 // This is a total hack, but I want to get this lazy file code out of the\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4758 // core of MEMFS. If we want to keep this lazy file concept I feel it should\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4759 // be its own thin LAZYFS proxying calls to MEMFS.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4760 if (properties.contents) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4761 node.contents = properties.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4762 } else if (properties.url) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4763 node.contents = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4764 node.url = properties.url;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4765 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4766 // override each stream op with one that tries to force load the lazy file first\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4767 var stream_ops = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4768 var keys = Object.keys(node.stream_ops);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4769 keys.forEach(function(key) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4770 var fn = node.stream_ops[key];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4771 stream_ops[key] = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4772 if (!FS.forceLoadFile(node)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4773 throw new FS.ErrnoError(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4774 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4775 return fn.apply(null, arguments);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4776 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4777 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4778 // use a custom read function\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4779 stream_ops.read = function(stream, buffer, offset, length, position) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4780 if (!FS.forceLoadFile(node)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4781 throw new FS.ErrnoError(ERRNO_CODES.EIO);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4782 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4783 var contents = stream.node.contents;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4784 var size = Math.min(contents.length - position, length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4785 if (contents.slice) { // normal array\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4786 for (var i = 0; i < size; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4787 buffer[offset + i] = contents[position + i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4788 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4789 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4790 for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4791 buffer[offset + i] = contents.get(position + i);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4792 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4793 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4794 return size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4795 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4796 node.stream_ops = stream_ops;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4797 return node;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4798 },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4799 Browser.init();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4800 // TODO we should allow people to just pass in a complete filename instead\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4801 // of parent and name being that we just join them anyways\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4802 var fullname = name ? PATH.resolve(PATH.join(parent, name)) : parent;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4803 function processData(byteArray) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4804 function finish(byteArray) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4805 if (!dontCreateFile) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4806 FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4807 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4808 if (onload) onload();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4809 removeRunDependency('cp ' + fullname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4810 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4811 var handled = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4812 Module['preloadPlugins'].forEach(function(plugin) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4813 if (handled) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4814 if (plugin['canHandle'](fullname)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4815 plugin['handle'](byteArray, fullname, finish, function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4816 if (onerror) onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4817 removeRunDependency('cp ' + fullname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4818 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4819 handled = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4820 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4821 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4822 if (!handled) finish(byteArray);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4823 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4824 addRunDependency('cp ' + fullname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4825 if (typeof url == 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4826 Browser.asyncLoad(url, function(byteArray) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4827 processData(byteArray);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4828 }, onerror);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4829 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4830 processData(url);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4831 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4832 },indexedDB:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4833 return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4834 },DB_NAME:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4835 return 'EM_FS_' + window.location.pathname;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4836 },DB_VERSION:20,DB_STORE_NAME:\"FILE_DATA\",saveFilesToDB:function (paths, onload, onerror) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4837 onload = onload || function(){};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4838 onerror = onerror || function(){};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4839 var indexedDB = FS.indexedDB();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4840 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4841 var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4842 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4843 return onerror(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4844 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4845 openRequest.onupgradeneeded = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4846 console.log('creating db');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4847 var db = openRequest.result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4848 db.createObjectStore(FS.DB_STORE_NAME);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4849 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4850 openRequest.onsuccess = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4851 var db = openRequest.result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4852 var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4853 var files = transaction.objectStore(FS.DB_STORE_NAME);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4854 var ok = 0, fail = 0, total = paths.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4855 function finish() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4856 if (fail == 0) onload(); else onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4857 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4858 paths.forEach(function(path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4859 var putRequest = files.put(FS.analyzePath(path).object.contents, path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4860 putRequest.onsuccess = function() { ok++; if (ok + fail == total) finish() };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4861 putRequest.onerror = function() { fail++; if (ok + fail == total) finish() };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4862 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4863 transaction.onerror = onerror;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4864 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4865 openRequest.onerror = onerror;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4866 },loadFilesFromDB:function (paths, onload, onerror) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4867 onload = onload || function(){};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4868 onerror = onerror || function(){};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4869 var indexedDB = FS.indexedDB();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4870 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4871 var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4872 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4873 return onerror(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4874 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4875 openRequest.onupgradeneeded = onerror; // no database to load from\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4876 openRequest.onsuccess = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4877 var db = openRequest.result;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4878 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4879 var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4880 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4881 onerror(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4882 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4883 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4884 var files = transaction.objectStore(FS.DB_STORE_NAME);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4885 var ok = 0, fail = 0, total = paths.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4886 function finish() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4887 if (fail == 0) onload(); else onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4888 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4889 paths.forEach(function(path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4890 var getRequest = files.get(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4891 getRequest.onsuccess = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4892 if (FS.analyzePath(path).exists) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4893 FS.unlink(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4894 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4895 FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4896 ok++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4897 if (ok + fail == total) finish();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4898 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4899 getRequest.onerror = function() { fail++; if (ok + fail == total) finish() };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4900 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4901 transaction.onerror = onerror;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4902 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4903 openRequest.onerror = onerror;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4904 }};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4905 var SOCKFS={mount:function (mount) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4906 return FS.createNode(null, '/', 0040000 | 0777, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4907 },nextname:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4908 if (!SOCKFS.nextname.current) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4909 SOCKFS.nextname.current = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4910 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4911 return 'socket[' + (SOCKFS.nextname.current++) + ']';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4912 },createSocket:function (family, type, protocol) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4913 var streaming = type == 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4914 if (protocol) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4915 assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4916 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4917 // create our internal socket structure\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4918 var sock = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4919 family: family,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4920 type: type,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4921 protocol: protocol,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4922 server: null,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4923 peers: {},\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4924 pending: [],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4925 recv_queue: [],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4926 sock_ops: SOCKFS.websocket_sock_ops\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4927 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4928 // create the filesystem node to store the socket structure\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4929 var name = SOCKFS.nextname();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4930 var node = FS.createNode(SOCKFS.root, name, 0140000, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4931 node.sock = sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4932 // and the wrapping stream that enables library functions such\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4933 // as read and write to indirectly interact with the socket\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4934 var stream = FS.createStream({\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4935 path: name,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4936 node: node,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4937 flags: FS.modeStringToFlags('r+'),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4938 seekable: false,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4939 stream_ops: SOCKFS.stream_ops\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4940 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4941 // map the new stream to the socket structure (sockets have a 1:1\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4942 // relationship with a stream)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4943 sock.stream = stream;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4944 return sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4945 },getSocket:function (fd) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4946 var stream = FS.getStream(fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4947 if (!stream || !FS.isSocket(stream.node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4948 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4949 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4950 return stream.node.sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4951 },stream_ops:{poll:function (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4952 var sock = stream.node.sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4953 return sock.sock_ops.poll(sock);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4954 },ioctl:function (stream, request, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4955 var sock = stream.node.sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4956 return sock.sock_ops.ioctl(sock, request, varargs);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4957 },read:function (stream, buffer, offset, length, position /* ignored */) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4958 var sock = stream.node.sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4959 var msg = sock.sock_ops.recvmsg(sock, length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4960 if (!msg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4961 // socket is closed\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4962 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4963 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4964 buffer.set(msg.buffer, offset);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4965 return msg.buffer.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4966 },write:function (stream, buffer, offset, length, position /* ignored */) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4967 var sock = stream.node.sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4968 return sock.sock_ops.sendmsg(sock, buffer, offset, length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4969 },close:function (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4970 var sock = stream.node.sock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4971 sock.sock_ops.close(sock);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4972 }},websocket_sock_ops:{createPeer:function (sock, addr, port) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4973 var ws;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4974 if (typeof addr === 'object') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4975 ws = addr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4976 addr = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4977 port = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4978 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4979 if (ws) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4980 // for sockets that've already connected (e.g. we're the server)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4981 // we can inspect the _socket property for the address\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4982 if (ws._socket) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4983 addr = ws._socket.remoteAddress;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4984 port = ws._socket.remotePort;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4985 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4986 // if we're just now initializing a connection to the remote,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4987 // inspect the url property\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4988 else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4989 var result = /ws[s]?:\\/\\/([^:]+):(\\d+)/.exec(ws.url);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4990 if (!result) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4991 throw new Error('WebSocket URL must be in the format ws(s)://address:port');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4992 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4993 addr = result[1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4994 port = parseInt(result[2], 10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4995 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4996 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4997 // create the actual websocket object and connect\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4998 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4999 var url = 'ws://' + addr + ':' + port;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5000 // the node ws library API is slightly different than the browser's\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5001 var opts = ENVIRONMENT_IS_NODE ? {} : ['binary'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5002 ws = new WebSocket(url, opts);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5003 ws.binaryType = 'arraybuffer';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5004 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5005 throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5006 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5007 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5008 var peer = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5009 addr: addr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5010 port: port,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5011 socket: ws,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5012 dgram_send_queue: []\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5013 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5014 SOCKFS.websocket_sock_ops.addPeer(sock, peer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5015 SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5016 // if this is a bound dgram socket, send the port number first to allow\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5017 // us to override the ephemeral port reported to us by remotePort on the\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5018 // remote end.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5019 if (sock.type === 2 && typeof sock.sport !== 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5020 peer.dgram_send_queue.push(new Uint8Array([\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5021 255, 255, 255, 255,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5022 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5023 ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5024 ]));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5025 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5026 return peer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5027 },getPeer:function (sock, addr, port) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5028 return sock.peers[addr + ':' + port];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5029 },addPeer:function (sock, peer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5030 sock.peers[peer.addr + ':' + peer.port] = peer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5031 },removePeer:function (sock, peer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5032 delete sock.peers[peer.addr + ':' + peer.port];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5033 },handlePeerEvents:function (sock, peer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5034 var first = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5035 var handleOpen = function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5036 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5037 var queued = peer.dgram_send_queue.shift();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5038 while (queued) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5039 peer.socket.send(queued);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5040 queued = peer.dgram_send_queue.shift();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5041 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5042 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5043 // not much we can do here in the way of proper error handling as we've already\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5044 // lied and said this data was sent. shut it down.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5045 peer.socket.close();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5046 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5047 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5048 var handleMessage = function(data) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5049 assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5050 data = new Uint8Array(data); // make a typed array view on the array buffer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5051 // if this is the port message, override the peer's port with it\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5052 var wasfirst = first;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5053 first = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5054 if (wasfirst &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5055 data.length === 10 &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5056 data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5057 data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5058 // update the peer's port and it's key in the peer map\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5059 var newport = ((data[8] << 8) | data[9]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5060 SOCKFS.websocket_sock_ops.removePeer(sock, peer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5061 peer.port = newport;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5062 SOCKFS.websocket_sock_ops.addPeer(sock, peer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5063 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5064 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5065 sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5066 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5067 if (ENVIRONMENT_IS_NODE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5068 peer.socket.on('open', handleOpen);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5069 peer.socket.on('message', function(data, flags) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5070 if (!flags.binary) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5071 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5072 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5073 handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5074 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5075 peer.socket.on('error', function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5076 // don't throw\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5077 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5078 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5079 peer.socket.onopen = handleOpen;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5080 peer.socket.onmessage = function(event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5081 handleMessage(event.data);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5082 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5083 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5084 },poll:function (sock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5085 if (sock.type === 1 && sock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5086 // listen sockets should only say they're available for reading\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5087 // if there are pending clients.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5088 return sock.pending.length ? (0 /* XXX missing C define POLLRDNORM */ | 1) : 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5089 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5090 var mask = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5091 var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5092 SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5093 null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5094 if (sock.recv_queue.length ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5095 !dest || // connection-less sockets are always ready to read\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5096 (dest && dest.socket.readyState === dest.socket.CLOSING) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5097 (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5098 mask |= (0 /* XXX missing C define POLLRDNORM */ | 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5099 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5100 if (!dest || // connection-less sockets are always ready to write\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5101 (dest && dest.socket.readyState === dest.socket.OPEN)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5102 mask |= 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5103 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5104 if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5105 (dest && dest.socket.readyState === dest.socket.CLOSED)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5106 mask |= 16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5107 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5108 return mask;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5109 },ioctl:function (sock, request, arg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5110 switch (request) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5111 case 1:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5112 var bytes = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5113 if (sock.recv_queue.length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5114 bytes = sock.recv_queue[0].data.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5115 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5116 HEAP32[((arg)>>2)]=bytes;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5117 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5118 default:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5119 return ERRNO_CODES.EINVAL;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5120 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5121 },close:function (sock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5122 // if we've spawned a listen server, close it\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5123 if (sock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5124 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5125 sock.server.close();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5126 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5127 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5128 sock.server = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5129 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5130 // close any peer connections\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5131 var peers = Object.keys(sock.peers);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5132 for (var i = 0; i < peers.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5133 var peer = sock.peers[peers[i]];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5134 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5135 peer.socket.close();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5136 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5137 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5138 SOCKFS.websocket_sock_ops.removePeer(sock, peer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5139 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5140 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5141 },bind:function (sock, addr, port) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5142 if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5143 throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5144 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5145 sock.saddr = addr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5146 sock.sport = port || _mkport();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5147 // in order to emulate dgram sockets, we need to launch a listen server when\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5148 // binding on a connection-less socket\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5149 // note: this is only required on the server side\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5150 if (sock.type === 2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5151 // close the existing server if it exists\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5152 if (sock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5153 sock.server.close();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5154 sock.server = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5155 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5156 // swallow error operation not supported error that occurs when binding in the\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5157 // browser where this isn't supported\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5158 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5159 sock.sock_ops.listen(sock, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5160 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5161 if (!(e instanceof FS.ErrnoError)) throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5162 if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5163 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5164 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5165 },connect:function (sock, addr, port) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5166 if (sock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5167 throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5168 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5169 // TODO autobind\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5170 // if (!sock.addr && sock.type == 2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5171 // }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5172 // early out if we're already connected / in the middle of connecting\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5173 if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5174 var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5175 if (dest) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5176 if (dest.socket.readyState === dest.socket.CONNECTING) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5177 throw new FS.ErrnoError(ERRNO_CODES.EALREADY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5178 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5179 throw new FS.ErrnoError(ERRNO_CODES.EISCONN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5180 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5181 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5182 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5183 // add the socket to our peer list and set our\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5184 // destination address / port to match\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5185 var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5186 sock.daddr = peer.addr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5187 sock.dport = peer.port;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5188 // always \"fail\" in non-blocking mode\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5189 throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5190 },listen:function (sock, backlog) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5191 if (!ENVIRONMENT_IS_NODE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5192 throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5193 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5194 if (sock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5195 throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5196 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5197 var WebSocketServer = require('ws').Server;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5198 var host = sock.saddr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5199 sock.server = new WebSocketServer({\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5200 host: host,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5201 port: sock.sport\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5202 // TODO support backlog\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5203 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5204 sock.server.on('connection', function(ws) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5205 if (sock.type === 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5206 var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5207 // create a peer on the new socket\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5208 var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5209 newsock.daddr = peer.addr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5210 newsock.dport = peer.port;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5211 // push to queue for accept to pick up\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5212 sock.pending.push(newsock);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5213 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5214 // create a peer on the listen socket so calling sendto\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5215 // with the listen socket and an address will resolve\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5216 // to the correct client\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5217 SOCKFS.websocket_sock_ops.createPeer(sock, ws);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5218 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5219 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5220 sock.server.on('closed', function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5221 sock.server = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5222 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5223 sock.server.on('error', function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5224 // don't throw\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5225 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5226 },accept:function (listensock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5227 if (!listensock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5228 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5229 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5230 var newsock = listensock.pending.shift();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5231 newsock.stream.flags = listensock.stream.flags;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5232 return newsock;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5233 },getname:function (sock, peer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5234 var addr, port;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5235 if (peer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5236 if (sock.daddr === undefined || sock.dport === undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5237 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5238 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5239 addr = sock.daddr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5240 port = sock.dport;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5241 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5242 // TODO saddr and sport will be set for bind()'d UDP sockets, but what\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5243 // should we be returning for TCP sockets that've been connect()'d?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5244 addr = sock.saddr || 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5245 port = sock.sport || 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5246 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5247 return { addr: addr, port: port };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5248 },sendmsg:function (sock, buffer, offset, length, addr, port) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5249 if (sock.type === 2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5250 // connection-less sockets will honor the message address,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5251 // and otherwise fall back to the bound destination address\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5252 if (addr === undefined || port === undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5253 addr = sock.daddr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5254 port = sock.dport;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5255 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5256 // if there was no address to fall back to, error out\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5257 if (addr === undefined || port === undefined) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5258 throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5259 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5260 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5261 // connection-based sockets will only use the bound\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5262 addr = sock.daddr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5263 port = sock.dport;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5264 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5265 // find the peer for the destination address\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5266 var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5267 // early out if not connected with a connection-based socket\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5268 if (sock.type === 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5269 if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5270 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5271 } else if (dest.socket.readyState === dest.socket.CONNECTING) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5272 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5273 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5274 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5275 // create a copy of the incoming data to send, as the WebSocket API\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5276 // doesn't work entirely with an ArrayBufferView, it'll just send\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5277 // the entire underlying buffer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5278 var data;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5279 if (buffer instanceof Array || buffer instanceof ArrayBuffer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5280 data = buffer.slice(offset, offset + length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5281 } else { // ArrayBufferView\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5282 data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5283 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5284 // if we're emulating a connection-less dgram socket and don't have\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5285 // a cached connection, queue the buffer to send upon connect and\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5286 // lie, saying the data was sent now.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5287 if (sock.type === 2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5288 if (!dest || dest.socket.readyState !== dest.socket.OPEN) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5289 // if we're not connected, open a new connection\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5290 if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5291 dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5292 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5293 dest.dgram_send_queue.push(data);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5294 return length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5295 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5296 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5297 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5298 // send the actual data\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5299 dest.socket.send(data);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5300 return length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5301 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5302 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5303 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5304 },recvmsg:function (sock, length) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5305 // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5306 if (sock.type === 1 && sock.server) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5307 // tcp servers should not be recv()'ing on the listen socket\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5308 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5309 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5310 var queued = sock.recv_queue.shift();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5311 if (!queued) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5312 if (sock.type === 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5313 var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5314 if (!dest) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5315 // if we have a destination address but are not connected, error out\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5316 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5317 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5318 else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5319 // return null if the socket has closed\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5320 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5321 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5322 else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5323 // else, our socket is in a valid state but truly has nothing available\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5324 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5325 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5326 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5327 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5328 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5329 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5330 // queued.data will be an ArrayBuffer if it's unadulterated, but if it's\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5331 // requeued TCP data it'll be an ArrayBufferView\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5332 var queuedLength = queued.data.byteLength || queued.data.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5333 var queuedOffset = queued.data.byteOffset || 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5334 var queuedBuffer = queued.data.buffer || queued.data;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5335 var bytesRead = Math.min(length, queuedLength);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5336 var res = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5337 buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5338 addr: queued.addr,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5339 port: queued.port\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5340 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5341 // push back any unread data for TCP connections\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5342 if (sock.type === 1 && bytesRead < queuedLength) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5343 var bytesRemaining = queuedLength - bytesRead;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5344 queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5345 sock.recv_queue.unshift(queued);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5346 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5347 return res;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5348 }}};function _send(fd, buf, len, flags) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5349 var sock = SOCKFS.getSocket(fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5350 if (!sock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5351 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5352 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5353 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5354 // TODO honor flags\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5355 return _write(fd, buf, len);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5356 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5357 function _pwrite(fildes, buf, nbyte, offset) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5358 // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5359 // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5360 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5361 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5362 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5363 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5364 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5365 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5366 var slab = HEAP8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5367 return FS.write(stream, slab, buf, nbyte, offset);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5368 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5369 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5370 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5371 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5372 }function _write(fildes, buf, nbyte) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5373 // ssize_t write(int fildes, const void *buf, size_t nbyte);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5374 // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5375 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5376 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5377 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5378 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5379 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5380 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5381 var slab = HEAP8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5382 return FS.write(stream, slab, buf, nbyte);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5383 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5384 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5385 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5386 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5387 }function _fputc(c, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5388 // int fputc(int c, FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5389 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5390 var chr = unSign(c & 0xFF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5391 HEAP8[((_fputc.ret)|0)]=chr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5392 var ret = _write(stream, _fputc.ret, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5393 if (ret == -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5394 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5395 if (streamObj) streamObj.error = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5396 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5397 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5398 return chr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5399 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5400 }function _putchar(c) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5401 // int putchar(int c);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5402 // http://pubs.opengroup.org/onlinepubs/000095399/functions/putchar.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5403 return _fputc(c, HEAP32[((_stdout)>>2)]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5404 } \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5405 Module[\"_saveSetjmp\"] = _saveSetjmp;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5406 Module[\"_testSetjmp\"] = _testSetjmp;function _longjmp(env, value) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5407 asm['setThrew'](env, value || 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5408 throw 'longjmp';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5409 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5410 function __exit(status) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5411 // void _exit(int status);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5412 // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5413 Module.print('exit(' + status + ') called');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5414 Module['exit'](status);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5415 }function _exit(status) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5416 __exit(status);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5417 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5418 var _setjmp=undefined;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5419 Module[\"_memset\"] = _memset;var _llvm_memset_p0i8_i64=_memset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5420 function _iscntrl(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5421 return (0 <= chr && chr <= 0x1F) || chr === 0x7F;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5422 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5423 function _isspace(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5424 return (chr == 32) || (chr >= 9 && chr <= 13);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5425 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5426 function _isalpha(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5427 return (chr >= 97 && chr <= 122) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5428 (chr >= 65 && chr <= 90);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5429 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5430 function _isalnum(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5431 return (chr >= 48 && chr <= 57) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5432 (chr >= 97 && chr <= 122) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5433 (chr >= 65 && chr <= 90);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5434 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5435 function _localeconv() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5436 // %struct.timeval = type { char* decimal point, other stuff... }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5437 // var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5438 var me = _localeconv;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5439 if (!me.ret) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5440 me.ret = allocate([allocate(intArrayFromString('.'), 'i8', ALLOC_NORMAL)], 'i8*', ALLOC_NORMAL); // just decimal point, for now\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5441 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5442 return me.ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5443 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5444 function _memchr(ptr, chr, num) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5445 chr = unSign(chr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5446 for (var i = 0; i < num; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5447 if (HEAP8[(ptr)] == chr) return ptr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5448 ptr++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5449 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5450 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5451 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5452 function __parseInt(str, endptr, base, min, max, bits, unsign) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5453 // Skip space.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5454 while (_isspace(HEAP8[(str)])) str++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5455 // Check for a plus/minus sign.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5456 var multiplier = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5457 if (HEAP8[(str)] == 45) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5458 multiplier = -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5459 str++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5460 } else if (HEAP8[(str)] == 43) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5461 str++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5462 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5463 // Find base.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5464 var finalBase = base;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5465 if (!finalBase) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5466 if (HEAP8[(str)] == 48) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5467 if (HEAP8[((str+1)|0)] == 120 ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5468 HEAP8[((str+1)|0)] == 88) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5469 finalBase = 16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5470 str += 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5471 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5472 finalBase = 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5473 str++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5474 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5475 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5476 } else if (finalBase==16) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5477 if (HEAP8[(str)] == 48) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5478 if (HEAP8[((str+1)|0)] == 120 ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5479 HEAP8[((str+1)|0)] == 88) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5480 str += 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5481 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5482 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5483 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5484 if (!finalBase) finalBase = 10;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5485 // Get digits.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5486 var chr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5487 var ret = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5488 while ((chr = HEAP8[(str)]) != 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5489 var digit = parseInt(String.fromCharCode(chr), finalBase);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5490 if (isNaN(digit)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5491 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5492 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5493 ret = ret * finalBase + digit;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5494 str++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5495 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5496 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5497 // Apply sign.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5498 ret *= multiplier;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5499 // Set end pointer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5500 if (endptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5501 HEAP32[((endptr)>>2)]=str\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5502 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5503 // Unsign if needed.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5504 if (unsign) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5505 if (Math.abs(ret) > max) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5506 ret = max;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5507 ___setErrNo(ERRNO_CODES.ERANGE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5508 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5509 ret = unSign(ret, bits);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5510 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5511 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5512 // Validate range.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5513 if (ret > max || ret < min) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5514 ret = ret > max ? max : min;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5515 ___setErrNo(ERRNO_CODES.ERANGE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5516 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5517 if (bits == 64) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5518 return ((asm[\"setTempRet0\"]((tempDouble=ret,(+(Math.abs(tempDouble))) >= (+(1)) ? (tempDouble > (+(0)) ? ((Math.min((+(Math.floor((tempDouble)/(+(4294967296))))), (+(4294967295))))|0)>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+(4294967296)))))))>>>0) : 0)),ret>>>0)|0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5519 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5520 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5521 }function _strtoul(str, endptr, base) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5522 return __parseInt(str, endptr, base, 0, 4294967295, 32, true); // ULONG_MAX.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5523 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5524 function __reallyNegative(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5525 return x < 0 || (x === 0 && (1/x) === -Infinity);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5526 }function __formatString(format, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5527 var textIndex = format;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5528 var argIndex = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5529 function getNextArg(type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5530 // NOTE: Explicitly ignoring type safety. Otherwise this fails:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5531 // int x = 4; printf(\"%c\\n\", (char)x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5532 var ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5533 if (type === 'double') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5534 ret = HEAPF64[(((varargs)+(argIndex))>>3)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5535 } else if (type == 'i64') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5536 ret = [HEAP32[(((varargs)+(argIndex))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5537 HEAP32[(((varargs)+(argIndex+8))>>2)]];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5538 argIndex += 8; // each 32-bit chunk is in a 64-bit block\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5539 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5540 type = 'i32'; // varargs are always i32, i64, or double\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5541 ret = HEAP32[(((varargs)+(argIndex))>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5542 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5543 argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5544 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5545 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5546 var ret = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5547 var curr, next, currArg;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5548 while(1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5549 var startTextIndex = textIndex;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5550 curr = HEAP8[(textIndex)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5551 if (curr === 0) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5552 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5553 if (curr == 37) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5554 // Handle flags.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5555 var flagAlwaysSigned = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5556 var flagLeftAlign = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5557 var flagAlternative = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5558 var flagZeroPad = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5559 flagsLoop: while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5560 switch (next) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5561 case 43:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5562 flagAlwaysSigned = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5563 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5564 case 45:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5565 flagLeftAlign = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5566 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5567 case 35:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5568 flagAlternative = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5569 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5570 case 48:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5571 if (flagZeroPad) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5572 break flagsLoop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5573 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5574 flagZeroPad = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5575 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5576 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5577 default:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5578 break flagsLoop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5579 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5580 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5581 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5582 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5583 // Handle width.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5584 var width = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5585 if (next == 42) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5586 width = getNextArg('i32');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5587 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5588 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5589 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5590 while (next >= 48 && next <= 57) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5591 width = width * 10 + (next - 48);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5592 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5593 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5594 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5595 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5596 // Handle precision.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5597 var precisionSet = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5598 if (next == 46) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5599 var precision = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5600 precisionSet = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5601 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5602 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5603 if (next == 42) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5604 precision = getNextArg('i32');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5605 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5606 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5607 while(1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5608 var precisionChr = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5609 if (precisionChr < 48 ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5610 precisionChr > 57) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5611 precision = precision * 10 + (precisionChr - 48);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5612 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5613 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5614 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5615 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5616 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5617 var precision = 6; // Standard default.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5618 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5619 // Handle integer sizes. WARNING: These assume a 32-bit architecture!\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5620 var argSize;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5621 switch (String.fromCharCode(next)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5622 case 'h':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5623 var nextNext = HEAP8[((textIndex+2)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5624 if (nextNext == 104) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5625 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5626 argSize = 1; // char (actually i32 in varargs)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5627 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5628 argSize = 2; // short (actually i32 in varargs)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5629 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5630 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5631 case 'l':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5632 var nextNext = HEAP8[((textIndex+2)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5633 if (nextNext == 108) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5634 textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5635 argSize = 8; // long long\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5636 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5637 argSize = 4; // long\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5638 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5639 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5640 case 'L': // long long\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5641 case 'q': // int64_t\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5642 case 'j': // intmax_t\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5643 argSize = 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5644 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5645 case 'z': // size_t\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5646 case 't': // ptrdiff_t\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5647 case 'I': // signed ptrdiff_t or unsigned size_t\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5648 argSize = 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5649 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5650 default:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5651 argSize = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5652 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5653 if (argSize) textIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5654 next = HEAP8[((textIndex+1)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5655 // Handle type specifier.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5656 switch (String.fromCharCode(next)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5657 case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5658 // Integer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5659 var signed = next == 100 || next == 105;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5660 argSize = argSize || 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5661 var currArg = getNextArg('i' + (argSize * 8));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5662 var origArg = currArg;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5663 var argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5664 // Flatten i64-1 [low, high] into a (slightly rounded) double\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5665 if (argSize == 8) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5666 currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5667 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5668 // Truncate to requested size.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5669 if (argSize <= 4) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5670 var limit = Math.pow(256, argSize) - 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5671 currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5672 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5673 // Format the number.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5674 var currAbsArg = Math.abs(currArg);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5675 var prefix = '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5676 if (next == 100 || next == 105) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5677 if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], null); else\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5678 argText = reSign(currArg, 8 * argSize, 1).toString(10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5679 } else if (next == 117) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5680 if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], true); else\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5681 argText = unSign(currArg, 8 * argSize, 1).toString(10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5682 currArg = Math.abs(currArg);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5683 } else if (next == 111) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5684 argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5685 } else if (next == 120 || next == 88) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5686 prefix = (flagAlternative && currArg != 0) ? '0x' : '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5687 if (argSize == 8 && i64Math) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5688 if (origArg[1]) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5689 argText = (origArg[1]>>>0).toString(16);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5690 var lower = (origArg[0]>>>0).toString(16);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5691 while (lower.length < 8) lower = '0' + lower;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5692 argText += lower;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5693 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5694 argText = (origArg[0]>>>0).toString(16);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5695 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5696 } else\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5697 if (currArg < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5698 // Represent negative numbers in hex as 2's complement.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5699 currArg = -currArg;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5700 argText = (currAbsArg - 1).toString(16);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5701 var buffer = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5702 for (var i = 0; i < argText.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5703 buffer.push((0xF - parseInt(argText[i], 16)).toString(16));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5704 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5705 argText = buffer.join('');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5706 while (argText.length < argSize * 2) argText = 'f' + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5707 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5708 argText = currAbsArg.toString(16);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5709 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5710 if (next == 88) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5711 prefix = prefix.toUpperCase();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5712 argText = argText.toUpperCase();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5713 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5714 } else if (next == 112) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5715 if (currAbsArg === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5716 argText = '(nil)';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5717 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5718 prefix = '0x';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5719 argText = currAbsArg.toString(16);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5720 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5721 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5722 if (precisionSet) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5723 while (argText.length < precision) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5724 argText = '0' + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5725 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5726 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5727 // Add sign if needed\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5728 if (flagAlwaysSigned) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5729 if (currArg < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5730 prefix = '-' + prefix;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5731 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5732 prefix = '+' + prefix;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5733 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5734 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5735 // Add padding.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5736 while (prefix.length + argText.length < width) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5737 if (flagLeftAlign) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5738 argText += ' ';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5739 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5740 if (flagZeroPad) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5741 argText = '0' + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5742 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5743 prefix = ' ' + prefix;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5744 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5745 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5746 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5747 // Insert the result into the buffer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5748 argText = prefix + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5749 argText.split('').forEach(function(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5750 ret.push(chr.charCodeAt(0));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5751 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5752 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5753 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5754 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5755 // Float.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5756 var currArg = getNextArg('double');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5757 var argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5758 if (isNaN(currArg)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5759 argText = 'nan';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5760 flagZeroPad = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5761 } else if (!isFinite(currArg)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5762 argText = (currArg < 0 ? '-' : '') + 'inf';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5763 flagZeroPad = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5764 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5765 var isGeneral = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5766 var effectivePrecision = Math.min(precision, 20);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5767 // Convert g/G to f/F or e/E, as per:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5768 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5769 if (next == 103 || next == 71) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5770 isGeneral = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5771 precision = precision || 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5772 var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5773 if (precision > exponent && exponent >= -4) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5774 next = ((next == 103) ? 'f' : 'F').charCodeAt(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5775 precision -= exponent + 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5776 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5777 next = ((next == 103) ? 'e' : 'E').charCodeAt(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5778 precision--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5779 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5780 effectivePrecision = Math.min(precision, 20);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5781 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5782 if (next == 101 || next == 69) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5783 argText = currArg.toExponential(effectivePrecision);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5784 // Make sure the exponent has at least 2 digits.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5785 if (/[eE][-+]\\d$/.test(argText)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5786 argText = argText.slice(0, -1) + '0' + argText.slice(-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5787 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5788 } else if (next == 102 || next == 70) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5789 argText = currArg.toFixed(effectivePrecision);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5790 if (currArg === 0 && __reallyNegative(currArg)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5791 argText = '-' + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5792 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5793 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5794 var parts = argText.split('e');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5795 if (isGeneral && !flagAlternative) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5796 // Discard trailing zeros and periods.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5797 while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5798 (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5799 parts[0] = parts[0].slice(0, -1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5800 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5801 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5802 // Make sure we have a period in alternative mode.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5803 if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5804 // Zero pad until required precision.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5805 while (precision > effectivePrecision++) parts[0] += '0';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5806 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5807 argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5808 // Capitalize 'E' if needed.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5809 if (next == 69) argText = argText.toUpperCase();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5810 // Add sign.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5811 if (flagAlwaysSigned && currArg >= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5812 argText = '+' + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5813 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5814 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5815 // Add padding.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5816 while (argText.length < width) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5817 if (flagLeftAlign) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5818 argText += ' ';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5819 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5820 if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5821 argText = argText[0] + '0' + argText.slice(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5822 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5823 argText = (flagZeroPad ? '0' : ' ') + argText;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5824 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5825 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5826 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5827 // Adjust case.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5828 if (next < 97) argText = argText.toUpperCase();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5829 // Insert the result into the buffer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5830 argText.split('').forEach(function(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5831 ret.push(chr.charCodeAt(0));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5832 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5833 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5834 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5835 case 's': {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5836 // String.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5837 var arg = getNextArg('i8*');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5838 var argLength = arg ? _strlen(arg) : '(null)'.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5839 if (precisionSet) argLength = Math.min(argLength, precision);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5840 if (!flagLeftAlign) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5841 while (argLength < width--) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5842 ret.push(32);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5843 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5844 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5845 if (arg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5846 for (var i = 0; i < argLength; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5847 ret.push(HEAPU8[((arg++)|0)]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5848 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5849 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5850 ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5851 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5852 if (flagLeftAlign) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5853 while (argLength < width--) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5854 ret.push(32);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5855 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5856 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5857 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5858 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5859 case 'c': {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5860 // Character.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5861 if (flagLeftAlign) ret.push(getNextArg('i8'));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5862 while (--width > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5863 ret.push(32);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5864 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5865 if (!flagLeftAlign) ret.push(getNextArg('i8'));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5866 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5867 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5868 case 'n': {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5869 // Write the length written so far to the next parameter.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5870 var ptr = getNextArg('i32*');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5871 HEAP32[((ptr)>>2)]=ret.length\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5872 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5873 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5874 case '%': {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5875 // Literal percent sign.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5876 ret.push(curr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5877 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5878 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5879 default: {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5880 // Unknown specifiers remain untouched.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5881 for (var i = startTextIndex; i < textIndex + 2; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5882 ret.push(HEAP8[(i)]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5883 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5884 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5885 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5886 textIndex += 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5887 // TODO: Support a/A (hex float) and m (last error) specifiers.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5888 // TODO: Support %1${specifier} for arg selection.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5889 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5890 ret.push(curr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5891 textIndex += 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5892 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5893 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5894 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5895 }function _snprintf(s, n, format, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5896 // int snprintf(char *restrict s, size_t n, const char *restrict format, ...);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5897 // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5898 var result = __formatString(format, varargs);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5899 var limit = (n === undefined) ? result.length\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5900 : Math.min(result.length, Math.max(n - 1, 0));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5901 if (s < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5902 s = -s;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5903 var buf = _malloc(limit+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5904 HEAP32[((s)>>2)]=buf;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5905 s = buf;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5906 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5907 for (var i = 0; i < limit; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5908 HEAP8[(((s)+(i))|0)]=result[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5909 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5910 if (limit < n || (n === undefined)) HEAP8[(((s)+(i))|0)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5911 return result.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5912 }function _sprintf(s, format, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5913 // int sprintf(char *restrict s, const char *restrict format, ...);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5914 // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5915 return _snprintf(s, undefined, format, varargs);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5916 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5917 Module[\"_strncpy\"] = _strncpy;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5918 Module[\"_strcat\"] = _strcat;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5919 function _strcspn(pstr, pset) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5920 var str = pstr, set, strcurr, setcurr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5921 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5922 strcurr = HEAP8[(str)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5923 if (!strcurr) return str - pstr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5924 set = pset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5925 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5926 setcurr = HEAP8[(set)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5927 if (!setcurr || setcurr == strcurr) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5928 set++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5929 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5930 if (setcurr) return str - pstr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5931 str++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5932 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5933 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5934 function _strncat(pdest, psrc, num) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5935 var len = _strlen(pdest);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5936 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5937 while(1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5938 HEAP8[((pdest+len+i)|0)]=HEAP8[((psrc+i)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5939 if (HEAP8[(((pdest)+(len+i))|0)] == 0) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5940 i ++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5941 if (i == num) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5942 HEAP8[(((pdest)+(len+i))|0)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5943 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5944 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5945 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5946 return pdest;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5947 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5948 var _llvm_memset_p0i8_i32=_memset;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5949 Module[\"_memcmp\"] = _memcmp;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5950 function _strncmp(px, py, n) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5951 var i = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5952 while (i < n) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5953 var x = HEAPU8[(((px)+(i))|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5954 var y = HEAPU8[(((py)+(i))|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5955 if (x == y && x == 0) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5956 if (x == 0) return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5957 if (y == 0) return 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5958 if (x == y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5959 i ++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5960 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5961 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5962 return x > y ? 1 : -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5963 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5964 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5965 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5966 }function _strcmp(px, py) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5967 return _strncmp(px, py, TOTAL_MEMORY);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5968 }var _strcoll=_strcmp;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5969 function _strstr(ptr1, ptr2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5970 var check = 0, start;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5971 do {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5972 if (!check) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5973 start = ptr1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5974 check = ptr2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5975 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5976 var curr1 = HEAP8[((ptr1++)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5977 var curr2 = HEAP8[((check++)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5978 if (curr2 == 0) return start;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5979 if (curr2 != curr1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5980 // rewind to one character after start, to find ez in eeez\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5981 ptr1 = start + 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5982 check = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5983 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5984 } while (curr1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5985 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5986 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5987 var ___dirent_struct_layout={__size__:1040,d_ino:0,d_name:4,d_off:1028,d_reclen:1032,d_type:1036};function _open(path, oflag, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5988 // int open(const char *path, int oflag, ...);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5989 // http://pubs.opengroup.org/onlinepubs/009695399/functions/open.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5990 var mode = HEAP32[((varargs)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5991 path = Pointer_stringify(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5992 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5993 var stream = FS.open(path, oflag, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5994 return stream.fd;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5995 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5996 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5997 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5998 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5999 }function _fopen(filename, mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6000 // FILE *fopen(const char *restrict filename, const char *restrict mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6001 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fopen.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6002 var flags;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6003 mode = Pointer_stringify(mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6004 if (mode[0] == 'r') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6005 if (mode.indexOf('+') != -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6006 flags = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6007 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6008 flags = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6009 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6010 } else if (mode[0] == 'w') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6011 if (mode.indexOf('+') != -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6012 flags = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6013 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6014 flags = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6015 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6016 flags |= 512;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6017 flags |= 1024;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6018 } else if (mode[0] == 'a') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6019 if (mode.indexOf('+') != -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6020 flags = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6021 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6022 flags = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6023 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6024 flags |= 512;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6025 flags |= 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6026 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6027 ___setErrNo(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6028 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6029 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6030 var ret = _open(filename, flags, allocate([0x1FF, 0, 0, 0], 'i32', ALLOC_STACK)); // All creation permissions.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6031 return (ret == -1) ? 0 : ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6032 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6033 function _recv(fd, buf, len, flags) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6034 var sock = SOCKFS.getSocket(fd);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6035 if (!sock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6036 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6037 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6038 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6039 // TODO honor flags\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6040 return _read(fd, buf, len);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6041 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6042 function _pread(fildes, buf, nbyte, offset) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6043 // ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6044 // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6045 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6046 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6047 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6048 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6049 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6050 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6051 var slab = HEAP8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6052 return FS.read(stream, slab, buf, nbyte, offset);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6053 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6054 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6055 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6056 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6057 }function _read(fildes, buf, nbyte) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6058 // ssize_t read(int fildes, void *buf, size_t nbyte);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6059 // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6060 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6061 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6062 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6063 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6064 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6065 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6066 var slab = HEAP8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6067 return FS.read(stream, slab, buf, nbyte);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6068 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6069 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6070 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6071 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6072 }function _fread(ptr, size, nitems, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6073 // size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6074 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fread.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6075 var bytesToRead = nitems * size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6076 if (bytesToRead == 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6077 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6078 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6079 var bytesRead = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6080 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6081 while (streamObj.ungotten.length && bytesToRead > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6082 HEAP8[((ptr++)|0)]=streamObj.ungotten.pop()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6083 bytesToRead--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6084 bytesRead++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6085 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6086 var err = _read(stream, ptr, bytesToRead);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6087 if (err == -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6088 if (streamObj) streamObj.error = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6089 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6090 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6091 bytesRead += err;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6092 if (bytesRead < bytesToRead) streamObj.eof = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6093 return Math.floor(bytesRead / size);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6094 }function _fgetc(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6095 // int fgetc(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6096 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fgetc.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6097 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6098 if (!streamObj) return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6099 if (streamObj.eof || streamObj.error) return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6100 var ret = _fread(_fgetc.ret, 1, 1, stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6101 if (ret == 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6102 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6103 } else if (ret == -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6104 streamObj.error = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6105 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6106 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6107 return HEAPU8[((_fgetc.ret)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6108 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6109 }var _getc=_fgetc;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6110 function _close(fildes) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6111 // int close(int fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6112 // http://pubs.opengroup.org/onlinepubs/000095399/functions/close.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6113 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6114 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6115 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6116 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6117 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6118 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6119 FS.close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6120 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6121 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6122 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6123 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6124 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6125 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6126 function _fsync(fildes) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6127 // int fsync(int fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6128 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fsync.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6129 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6130 if (stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6131 // We write directly to the file system, so there's nothing to do here.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6132 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6133 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6134 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6135 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6136 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6137 }function _fclose(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6138 // int fclose(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6139 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fclose.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6140 _fsync(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6141 return _close(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6142 }function _freopen(filename, mode, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6143 // FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6144 // http://pubs.opengroup.org/onlinepubs/000095399/functions/freopen.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6145 if (!filename) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6146 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6147 if (!streamObj) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6148 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6149 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6150 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6151 if (_freopen.buffer) _free(_freopen.buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6152 filename = intArrayFromString(streamObj.path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6153 filename = allocate(filename, 'i8', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6154 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6155 _fclose(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6156 return _fopen(filename, mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6157 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6158 function _ungetc(c, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6159 // int ungetc(int c, FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6160 // http://pubs.opengroup.org/onlinepubs/000095399/functions/ungetc.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6161 stream = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6162 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6163 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6164 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6165 if (c === -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6166 // do nothing for EOF character\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6167 return c;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6168 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6169 c = unSign(c & 0xFF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6170 stream.ungotten.push(c);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6171 stream.eof = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6172 return c;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6173 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6174 function _ferror(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6175 // int ferror(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6176 // http://pubs.opengroup.org/onlinepubs/000095399/functions/ferror.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6177 stream = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6178 return Number(stream && stream.error);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6179 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6180 function _fwrite(ptr, size, nitems, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6181 // size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6182 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6183 var bytesToWrite = nitems * size;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6184 if (bytesToWrite == 0) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6185 var bytesWritten = _write(stream, ptr, bytesToWrite);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6186 if (bytesWritten == -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6187 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6188 if (streamObj) streamObj.error = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6189 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6190 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6191 return Math.floor(bytesWritten / size);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6192 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6193 }function _fprintf(stream, format, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6194 // int fprintf(FILE *restrict stream, const char *restrict format, ...);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6195 // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6196 var result = __formatString(format, varargs);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6197 var stack = Runtime.stackSave();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6198 var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6199 Runtime.stackRestore(stack);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6200 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6201 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6202 function _feof(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6203 // int feof(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6204 // http://pubs.opengroup.org/onlinepubs/000095399/functions/feof.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6205 stream = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6206 return Number(stream && stream.eof);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6207 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6208 function _strerror_r(errnum, strerrbuf, buflen) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6209 if (errnum in ERRNO_MESSAGES) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6210 if (ERRNO_MESSAGES[errnum].length > buflen - 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6211 return ___setErrNo(ERRNO_CODES.ERANGE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6212 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6213 var msg = ERRNO_MESSAGES[errnum];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6214 for (var i = 0; i < msg.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6215 HEAP8[(((strerrbuf)+(i))|0)]=msg.charCodeAt(i)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6216 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6217 HEAP8[(((strerrbuf)+(i))|0)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6218 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6219 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6220 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6221 return ___setErrNo(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6222 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6223 }function _strerror(errnum) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6224 if (!_strerror.buffer) _strerror.buffer = _malloc(256);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6225 _strerror_r(errnum, _strerror.buffer, 256);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6226 return _strerror.buffer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6227 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6228 function ___errno_location() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6229 return ___errno_state;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6230 }var ___errno=___errno_location;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6231 function _fputs(s, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6232 // int fputs(const char *restrict s, FILE *restrict stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6233 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6234 return _write(stream, s, _strlen(s));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6235 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6236 function _fgets(s, n, stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6237 // char *fgets(char *restrict s, int n, FILE *restrict stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6238 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fgets.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6239 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6240 if (!streamObj) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6241 if (streamObj.error || streamObj.eof) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6242 var byte_;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6243 for (var i = 0; i < n - 1 && byte_ != 10; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6244 byte_ = _fgetc(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6245 if (byte_ == -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6246 if (streamObj.error || (streamObj.eof && i == 0)) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6247 else if (streamObj.eof) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6248 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6249 HEAP8[(((s)+(i))|0)]=byte_\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6250 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6251 HEAP8[(((s)+(i))|0)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6252 return s;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6253 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6254 function _tmpnam(s, dir, prefix) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6255 // char *tmpnam(char *s);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6256 // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpnam.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6257 // NOTE: The dir and prefix arguments are for internal use only.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6258 var folder = FS.findObject(dir || '/tmp');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6259 if (!folder || !folder.isFolder) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6260 dir = '/tmp';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6261 folder = FS.findObject(dir);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6262 if (!folder || !folder.isFolder) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6263 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6264 var name = prefix || 'file';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6265 do {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6266 name += String.fromCharCode(65 + Math.floor(Math.random() * 25));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6267 } while (name in folder.contents);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6268 var result = dir + '/' + name;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6269 if (!_tmpnam.buffer) _tmpnam.buffer = _malloc(256);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6270 if (!s) s = _tmpnam.buffer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6271 for (var i = 0; i < result.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6272 HEAP8[(((s)+(i))|0)]=result.charCodeAt(i);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6273 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6274 HEAP8[(((s)+(i))|0)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6275 return s;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6276 }function _tmpfile() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6277 // FILE *tmpfile(void);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6278 // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpfile.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6279 // TODO: Delete the created file on closing.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6280 if (_tmpfile.mode) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6281 _tmpfile.mode = allocate(intArrayFromString('w+'), 'i8', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6282 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6283 return _fopen(_tmpnam(0), _tmpfile.mode);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6284 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6285 function _clearerr(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6286 // void clearerr(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6287 // http://pubs.opengroup.org/onlinepubs/000095399/functions/clearerr.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6288 stream = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6289 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6290 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6291 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6292 stream.eof = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6293 stream.error = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6294 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6295 function __isFloat(text) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6296 return !!(/^[+-]?[0-9]*\\.?[0-9]+([eE][+-]?[0-9]+)?$/.exec(text));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6297 }function __scanString(format, get, unget, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6298 if (!__scanString.whiteSpace) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6299 __scanString.whiteSpace = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6300 __scanString.whiteSpace[32] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6301 __scanString.whiteSpace[9] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6302 __scanString.whiteSpace[10] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6303 __scanString.whiteSpace[11] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6304 __scanString.whiteSpace[12] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6305 __scanString.whiteSpace[13] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6306 __scanString.whiteSpace[' '] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6307 __scanString.whiteSpace['\\t'] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6308 __scanString.whiteSpace['\\n'] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6309 __scanString.whiteSpace['\\v'] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6310 __scanString.whiteSpace['\\f'] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6311 __scanString.whiteSpace['\\r'] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6312 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6313 // Supports %x, %4x, %d.%d, %lld, %s, %f, %lf.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6314 // TODO: Support all format specifiers.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6315 format = Pointer_stringify(format);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6316 var soFar = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6317 if (format.indexOf('%n') >= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6318 // need to track soFar\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6319 var _get = get;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6320 get = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6321 soFar++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6322 return _get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6323 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6324 var _unget = unget;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6325 unget = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6326 soFar--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6327 return _unget();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6328 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6329 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6330 var formatIndex = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6331 var argsi = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6332 var fields = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6333 var argIndex = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6334 var next;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6335 mainLoop:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6336 for (var formatIndex = 0; formatIndex < format.length;) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6337 if (format[formatIndex] === '%' && format[formatIndex+1] == 'n') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6338 var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6339 argIndex += Runtime.getAlignSize('void*', null, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6340 HEAP32[((argPtr)>>2)]=soFar;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6341 formatIndex += 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6342 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6343 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6344 if (format[formatIndex] === '%') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6345 var nextC = format.indexOf('c', formatIndex+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6346 if (nextC > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6347 var maxx = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6348 if (nextC > formatIndex+1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6349 var sub = format.substring(formatIndex+1, nextC)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6350 maxx = parseInt(sub);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6351 if (maxx != sub) maxx = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6352 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6353 if (maxx) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6354 var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6355 argIndex += Runtime.getAlignSize('void*', null, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6356 fields++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6357 for (var i = 0; i < maxx; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6358 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6359 HEAP8[((argPtr++)|0)]=next;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6360 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6361 formatIndex += nextC - formatIndex + 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6362 continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6363 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6364 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6365 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6366 // remove whitespace\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6367 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6368 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6369 if (next == 0) return fields;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6370 if (!(next in __scanString.whiteSpace)) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6371 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6372 unget();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6373 if (format[formatIndex] === '%') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6374 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6375 var suppressAssignment = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6376 if (format[formatIndex] == '*') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6377 suppressAssignment = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6378 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6379 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6380 var maxSpecifierStart = formatIndex;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6381 while (format[formatIndex].charCodeAt(0) >= 48 &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6382 format[formatIndex].charCodeAt(0) <= 57) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6383 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6384 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6385 var max_;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6386 if (formatIndex != maxSpecifierStart) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6387 max_ = parseInt(format.slice(maxSpecifierStart, formatIndex), 10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6388 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6389 var long_ = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6390 var half = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6391 var longLong = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6392 if (format[formatIndex] == 'l') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6393 long_ = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6394 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6395 if (format[formatIndex] == 'l') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6396 longLong = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6397 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6398 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6399 } else if (format[formatIndex] == 'h') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6400 half = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6401 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6402 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6403 var type = format[formatIndex];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6404 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6405 var curr = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6406 var buffer = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6407 // Read characters according to the format. floats are trickier, they may be in an unfloat state in the middle, then be a valid float later\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6408 if (type == 'f' || type == 'e' || type == 'g' ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6409 type == 'F' || type == 'E' || type == 'G') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6410 var last = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6411 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6412 while (next > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6413 buffer.push(String.fromCharCode(next));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6414 if (__isFloat(buffer.join(''))) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6415 last = buffer.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6416 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6417 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6418 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6419 for (var i = 0; i < buffer.length - last + 1; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6420 unget();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6421 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6422 buffer.length = last;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6423 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6424 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6425 var first = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6426 while ((curr < max_ || isNaN(max_)) && next > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6427 if (!(next in __scanString.whiteSpace) && // stop on whitespace\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6428 (type == 's' ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6429 ((type === 'd' || type == 'u' || type == 'i') && ((next >= 48 && next <= 57) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6430 (first && next == 45))) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6431 ((type === 'x' || type === 'X') && (next >= 48 && next <= 57 ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6432 next >= 97 && next <= 102 ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6433 next >= 65 && next <= 70))) &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6434 (formatIndex >= format.length || next !== format[formatIndex].charCodeAt(0))) { // Stop when we read something that is coming up\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6435 buffer.push(String.fromCharCode(next));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6436 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6437 curr++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6438 first = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6439 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6440 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6441 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6442 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6443 unget();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6444 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6445 if (buffer.length === 0) return 0; // Failure.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6446 if (suppressAssignment) continue;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6447 var text = buffer.join('');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6448 var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6449 argIndex += Runtime.getAlignSize('void*', null, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6450 switch (type) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6451 case 'd': case 'u': case 'i':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6452 if (half) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6453 HEAP16[((argPtr)>>1)]=parseInt(text, 10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6454 } else if (longLong) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6455 (tempI64 = [parseInt(text, 10)>>>0,(tempDouble=parseInt(text, 10),(+(Math.abs(tempDouble))) >= (+(1)) ? (tempDouble > (+(0)) ? ((Math.min((+(Math.floor((tempDouble)/(+(4294967296))))), (+(4294967295))))|0)>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/(+(4294967296)))))))>>>0) : 0)],HEAP32[((argPtr)>>2)]=tempI64[0],HEAP32[(((argPtr)+(4))>>2)]=tempI64[1]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6456 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6457 HEAP32[((argPtr)>>2)]=parseInt(text, 10);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6458 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6459 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6460 case 'X':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6461 case 'x':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6462 HEAP32[((argPtr)>>2)]=parseInt(text, 16)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6463 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6464 case 'F':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6465 case 'f':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6466 case 'E':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6467 case 'e':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6468 case 'G':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6469 case 'g':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6470 case 'E':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6471 // fallthrough intended\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6472 if (long_) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6473 HEAPF64[((argPtr)>>3)]=parseFloat(text)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6474 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6475 HEAPF32[((argPtr)>>2)]=parseFloat(text)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6476 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6477 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6478 case 's':\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6479 var array = intArrayFromString(text);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6480 for (var j = 0; j < array.length; j++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6481 HEAP8[(((argPtr)+(j))|0)]=array[j]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6482 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6483 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6484 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6485 fields++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6486 } else if (format[formatIndex] in __scanString.whiteSpace) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6487 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6488 while (next in __scanString.whiteSpace) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6489 if (next <= 0) break mainLoop; // End of input.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6490 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6491 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6492 unget(next);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6493 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6494 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6495 // Not a specifier.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6496 next = get();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6497 if (format[formatIndex].charCodeAt(0) !== next) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6498 unget(next);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6499 break mainLoop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6500 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6501 formatIndex++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6502 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6503 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6504 return fields;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6505 }function _fscanf(stream, format, varargs) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6506 // int fscanf(FILE *restrict stream, const char *restrict format, ... );\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6507 // http://pubs.opengroup.org/onlinepubs/000095399/functions/scanf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6508 var streamObj = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6509 if (!streamObj) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6510 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6511 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6512 var buffer = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6513 var get = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6514 var c = _fgetc(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6515 buffer.push(c);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6516 return c;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6517 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6518 var unget = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6519 _ungetc(buffer.pop(), stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6520 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6521 return __scanString(format, get, unget, varargs);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6522 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6523 function _setvbuf(stream, buf, type, size) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6524 // int setvbuf(FILE *restrict stream, char *restrict buf, int type, size_t size);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6525 // http://pubs.opengroup.org/onlinepubs/000095399/functions/setvbuf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6526 // TODO: Implement custom buffering.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6527 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6528 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6529 function _lseek(fildes, offset, whence) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6530 // off_t lseek(int fildes, off_t offset, int whence);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6531 // http://pubs.opengroup.org/onlinepubs/000095399/functions/lseek.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6532 var stream = FS.getStream(fildes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6533 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6534 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6535 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6536 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6537 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6538 return FS.llseek(stream, offset, whence);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6539 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6540 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6541 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6542 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6543 }function _fseek(stream, offset, whence) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6544 // int fseek(FILE *stream, long offset, int whence);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6545 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fseek.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6546 var ret = _lseek(stream, offset, whence);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6547 if (ret == -1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6548 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6549 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6550 stream = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6551 stream.eof = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6552 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6553 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6554 function _ftell(stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6555 // long ftell(FILE *stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6556 // http://pubs.opengroup.org/onlinepubs/000095399/functions/ftell.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6557 stream = FS.getStream(stream);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6558 if (!stream) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6559 ___setErrNo(ERRNO_CODES.EBADF);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6560 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6561 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6562 if (FS.isChrdev(stream.node.mode)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6563 ___setErrNo(ERRNO_CODES.ESPIPE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6564 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6565 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6566 return stream.position;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6567 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6568 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6569 var _tan=Math.tan;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6570 function _sinh(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6571 var p = Math.pow(Math.E, x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6572 return (p - (1 / p)) / 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6573 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6574 function _cosh(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6575 var p = Math.pow(Math.E, x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6576 return (p + (1 / p)) / 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6577 }function _tanh(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6578 return _sinh(x) / _cosh(x);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6579 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6580 var _sqrt=Math.sqrt;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6581 var _sin=Math.sin;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6582 function _srand(seed) {}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6583 function _rand() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6584 return Math.floor(Math.random()*0x80000000);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6585 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6586 function _modf(x, intpart) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6587 HEAPF64[((intpart)>>3)]=Math.floor(x)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6588 return x - HEAPF64[((intpart)>>3)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6589 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6590 var _log=Math.log;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6591 function _log10(x) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6592 return Math.log(x) / Math.LN10;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6593 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6594 function _ldexp(x, exp_) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6595 return x * Math.pow(2, exp_);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6596 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6597 function _frexp(x, exp_addr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6598 var sig = 0, exp_ = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6599 if (x !== 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6600 var sign = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6601 if (x < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6602 x = -x;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6603 sign = -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6604 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6605 var raw_exp = Math.log(x)/Math.log(2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6606 exp_ = Math.ceil(raw_exp);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6607 if (exp_ === raw_exp) exp_ += 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6608 sig = sign*x/Math.pow(2, exp_);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6609 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6610 HEAP32[((exp_addr)>>2)]=exp_\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6611 return sig;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6612 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6613 function _fmod(x, y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6614 return x % y;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6615 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6616 var _exp=Math.exp;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6617 var _cos=Math.cos;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6618 var _ceil=Math.ceil;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6619 var _atan=Math.atan;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6620 var _atan2=Math.atan2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6621 var _asin=Math.asin;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6622 var _acos=Math.acos;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6623 var _fabs=Math.abs;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6624 function _time(ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6625 var ret = Math.floor(Date.now()/1000);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6626 if (ptr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6627 HEAP32[((ptr)>>2)]=ret\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6628 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6629 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6630 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6631 var ___tm_struct_layout={__size__:44,tm_sec:0,tm_min:4,tm_hour:8,tm_mday:12,tm_mon:16,tm_year:20,tm_wday:24,tm_yday:28,tm_isdst:32,tm_gmtoff:36,tm_zone:40};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6632 var __tzname=allocate(8, \"i32*\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6633 var __daylight=allocate(1, \"i32*\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6634 var __timezone=allocate(1, \"i32*\", ALLOC_STATIC);function _tzset() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6635 // TODO: Use (malleable) environment variables instead of system settings.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6636 if (_tzset.called) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6637 _tzset.called = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6638 HEAP32[((__timezone)>>2)]=-(new Date()).getTimezoneOffset() * 60\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6639 var winter = new Date(2000, 0, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6640 var summer = new Date(2000, 6, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6641 HEAP32[((__daylight)>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset())\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6642 var winterName = 'GMT'; // XXX do not rely on browser timezone info, it is very unpredictable | winter.toString().match(/\\(([A-Z]+)\\)/)[1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6643 var summerName = 'GMT'; // XXX do not rely on browser timezone info, it is very unpredictable | summer.toString().match(/\\(([A-Z]+)\\)/)[1];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6644 var winterNamePtr = allocate(intArrayFromString(winterName), 'i8', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6645 var summerNamePtr = allocate(intArrayFromString(summerName), 'i8', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6646 HEAP32[((__tzname)>>2)]=winterNamePtr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6647 HEAP32[(((__tzname)+(4))>>2)]=summerNamePtr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6648 }function _mktime(tmPtr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6649 _tzset();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6650 var offsets = ___tm_struct_layout;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6651 var year = HEAP32[(((tmPtr)+(offsets.tm_year))>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6652 var timestamp = new Date(year >= 1900 ? year : year + 1900,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6653 HEAP32[(((tmPtr)+(offsets.tm_mon))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6654 HEAP32[(((tmPtr)+(offsets.tm_mday))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6655 HEAP32[(((tmPtr)+(offsets.tm_hour))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6656 HEAP32[(((tmPtr)+(offsets.tm_min))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6657 HEAP32[(((tmPtr)+(offsets.tm_sec))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6658 0).getTime() / 1000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6659 HEAP32[(((tmPtr)+(offsets.tm_wday))>>2)]=new Date(timestamp).getDay()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6660 var yday = Math.round((timestamp - (new Date(year, 0, 1)).getTime()) / (1000 * 60 * 60 * 24));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6661 HEAP32[(((tmPtr)+(offsets.tm_yday))>>2)]=yday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6662 return timestamp;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6663 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6664 function _setlocale(category, locale) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6665 if (!_setlocale.ret) _setlocale.ret = allocate([0], 'i8', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6666 return _setlocale.ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6667 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6668 function _rename(old_path, new_path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6669 // int rename(const char *old, const char *new);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6670 // http://pubs.opengroup.org/onlinepubs/000095399/functions/rename.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6671 old_path = Pointer_stringify(old_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6672 new_path = Pointer_stringify(new_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6673 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6674 FS.rename(old_path, new_path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6675 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6676 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6677 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6678 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6679 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6680 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6681 function _unlink(path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6682 // int unlink(const char *path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6683 // http://pubs.opengroup.org/onlinepubs/000095399/functions/unlink.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6684 path = Pointer_stringify(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6685 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6686 FS.unlink(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6687 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6688 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6689 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6690 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6691 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6692 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6693 function _rmdir(path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6694 // int rmdir(const char *path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6695 // http://pubs.opengroup.org/onlinepubs/000095399/functions/rmdir.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6696 path = Pointer_stringify(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6697 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6698 FS.rmdir(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6699 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6700 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6701 FS.handleFSError(e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6702 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6703 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6704 }function _remove(path) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6705 // int remove(const char *path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6706 // http://pubs.opengroup.org/onlinepubs/000095399/functions/remove.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6707 var ret = _unlink(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6708 if (ret == -1) ret = _rmdir(path);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6709 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6710 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6711 var _environ=allocate(1, \"i32*\", ALLOC_STATIC);var ___environ=_environ;function ___buildEnvironment(env) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6712 // WARNING: Arbitrary limit!\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6713 var MAX_ENV_VALUES = 64;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6714 var TOTAL_ENV_SIZE = 1024;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6715 // Statically allocate memory for the environment.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6716 var poolPtr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6717 var envPtr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6718 if (!___buildEnvironment.called) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6719 ___buildEnvironment.called = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6720 // Set default values. Use string keys for Closure Compiler compatibility.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6721 ENV['USER'] = 'root';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6722 ENV['PATH'] = '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6723 ENV['PWD'] = '/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6724 ENV['HOME'] = '/home/emscripten';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6725 ENV['LANG'] = 'en_US.UTF-8';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6726 ENV['_'] = './this.program';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6727 // Allocate memory.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6728 poolPtr = allocate(TOTAL_ENV_SIZE, 'i8', ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6729 envPtr = allocate(MAX_ENV_VALUES * 4,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6730 'i8*', ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6731 HEAP32[((envPtr)>>2)]=poolPtr\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6732 HEAP32[((_environ)>>2)]=envPtr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6733 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6734 envPtr = HEAP32[((_environ)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6735 poolPtr = HEAP32[((envPtr)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6736 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6737 // Collect key=value lines.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6738 var strings = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6739 var totalSize = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6740 for (var key in env) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6741 if (typeof env[key] === 'string') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6742 var line = key + '=' + env[key];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6743 strings.push(line);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6744 totalSize += line.length;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6745 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6746 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6747 if (totalSize > TOTAL_ENV_SIZE) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6748 throw new Error('Environment size exceeded TOTAL_ENV_SIZE!');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6749 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6750 // Make new.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6751 var ptrSize = 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6752 for (var i = 0; i < strings.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6753 var line = strings[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6754 for (var j = 0; j < line.length; j++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6755 HEAP8[(((poolPtr)+(j))|0)]=line.charCodeAt(j);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6756 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6757 HEAP8[(((poolPtr)+(j))|0)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6758 HEAP32[(((envPtr)+(i * ptrSize))>>2)]=poolPtr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6759 poolPtr += line.length + 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6760 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6761 HEAP32[(((envPtr)+(strings.length * ptrSize))>>2)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6762 }var ENV={};function _getenv(name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6763 // char *getenv(const char *name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6764 // http://pubs.opengroup.org/onlinepubs/009695399/functions/getenv.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6765 if (name === 0) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6766 name = Pointer_stringify(name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6767 if (!ENV.hasOwnProperty(name)) return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6768 if (_getenv.ret) _free(_getenv.ret);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6769 _getenv.ret = allocate(intArrayFromString(ENV[name]), 'i8', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6770 return _getenv.ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6771 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6772 function _system(command) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6773 // int system(const char *command);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6774 // http://pubs.opengroup.org/onlinepubs/000095399/functions/system.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6775 // Can't call external programs.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6776 ___setErrNo(ERRNO_CODES.EAGAIN);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6777 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6778 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6779 function _difftime(time1, time0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6780 return time1 - time0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6781 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6782 var ___tm_current=allocate(4*26, \"i8\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6783 var ___tm_timezone=allocate(intArrayFromString(\"GMT\"), \"i8\", ALLOC_STATIC);function _gmtime_r(time, tmPtr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6784 var date = new Date(HEAP32[((time)>>2)]*1000);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6785 var offsets = ___tm_struct_layout;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6786 HEAP32[(((tmPtr)+(offsets.tm_sec))>>2)]=date.getUTCSeconds()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6787 HEAP32[(((tmPtr)+(offsets.tm_min))>>2)]=date.getUTCMinutes()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6788 HEAP32[(((tmPtr)+(offsets.tm_hour))>>2)]=date.getUTCHours()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6789 HEAP32[(((tmPtr)+(offsets.tm_mday))>>2)]=date.getUTCDate()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6790 HEAP32[(((tmPtr)+(offsets.tm_mon))>>2)]=date.getUTCMonth()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6791 HEAP32[(((tmPtr)+(offsets.tm_year))>>2)]=date.getUTCFullYear()-1900\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6792 HEAP32[(((tmPtr)+(offsets.tm_wday))>>2)]=date.getUTCDay()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6793 HEAP32[(((tmPtr)+(offsets.tm_gmtoff))>>2)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6794 HEAP32[(((tmPtr)+(offsets.tm_isdst))>>2)]=0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6795 var start = new Date(date); // define date using UTC, start from Jan 01 00:00:00 UTC\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6796 start.setUTCDate(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6797 start.setUTCMonth(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6798 start.setUTCHours(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6799 start.setUTCMinutes(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6800 start.setUTCSeconds(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6801 start.setUTCMilliseconds(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6802 var yday = Math.floor((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6803 HEAP32[(((tmPtr)+(offsets.tm_yday))>>2)]=yday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6804 HEAP32[(((tmPtr)+(offsets.tm_zone))>>2)]=___tm_timezone\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6805 return tmPtr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6806 }function _gmtime(time) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6807 return _gmtime_r(time, ___tm_current);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6808 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6809 function _localtime_r(time, tmPtr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6810 _tzset();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6811 var offsets = ___tm_struct_layout;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6812 var date = new Date(HEAP32[((time)>>2)]*1000);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6813 HEAP32[(((tmPtr)+(offsets.tm_sec))>>2)]=date.getSeconds()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6814 HEAP32[(((tmPtr)+(offsets.tm_min))>>2)]=date.getMinutes()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6815 HEAP32[(((tmPtr)+(offsets.tm_hour))>>2)]=date.getHours()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6816 HEAP32[(((tmPtr)+(offsets.tm_mday))>>2)]=date.getDate()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6817 HEAP32[(((tmPtr)+(offsets.tm_mon))>>2)]=date.getMonth()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6818 HEAP32[(((tmPtr)+(offsets.tm_year))>>2)]=date.getFullYear()-1900\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6819 HEAP32[(((tmPtr)+(offsets.tm_wday))>>2)]=date.getDay()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6820 var start = new Date(date.getFullYear(), 0, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6821 var yday = Math.floor((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6822 HEAP32[(((tmPtr)+(offsets.tm_yday))>>2)]=yday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6823 HEAP32[(((tmPtr)+(offsets.tm_gmtoff))>>2)]=start.getTimezoneOffset() * 60\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6824 var dst = Number(start.getTimezoneOffset() != date.getTimezoneOffset());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6825 HEAP32[(((tmPtr)+(offsets.tm_isdst))>>2)]=dst\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6826 HEAP32[(((tmPtr)+(offsets.tm_zone))>>2)]=___tm_timezone\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6827 return tmPtr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6828 }function _localtime(time) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6829 return _localtime_r(time, ___tm_current);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6830 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6831 function __isLeapYear(year) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6832 return year%4 === 0 && (year%100 !== 0 || year%400 === 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6833 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6834 function __arraySum(array, index) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6835 var sum = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6836 for (var i = 0; i <= index; sum += array[i++]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6837 return sum;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6838 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6839 var __MONTH_DAYS_LEAP=[31,29,31,30,31,30,31,31,30,31,30,31];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6840 var __MONTH_DAYS_REGULAR=[31,28,31,30,31,30,31,31,30,31,30,31];function __addDays(date, days) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6841 var newDate = new Date(date.getTime());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6842 while(days > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6843 var leap = __isLeapYear(newDate.getFullYear());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6844 var currentMonth = newDate.getMonth();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6845 var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6846 if (days > daysInCurrentMonth-newDate.getDate()) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6847 // we spill over to next month\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6848 days -= (daysInCurrentMonth-newDate.getDate()+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6849 newDate.setDate(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6850 if (currentMonth < 11) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6851 newDate.setMonth(currentMonth+1)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6852 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6853 newDate.setMonth(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6854 newDate.setFullYear(newDate.getFullYear()+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6855 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6856 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6857 // we stay in current month \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6858 newDate.setDate(newDate.getDate()+days);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6859 return newDate;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6860 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6861 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6862 return newDate;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6863 }function _strftime(s, maxsize, format, tm) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6864 // size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6865 // http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6866 var date = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6867 tm_sec: HEAP32[(((tm)+(___tm_struct_layout.tm_sec))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6868 tm_min: HEAP32[(((tm)+(___tm_struct_layout.tm_min))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6869 tm_hour: HEAP32[(((tm)+(___tm_struct_layout.tm_hour))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6870 tm_mday: HEAP32[(((tm)+(___tm_struct_layout.tm_mday))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6871 tm_mon: HEAP32[(((tm)+(___tm_struct_layout.tm_mon))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6872 tm_year: HEAP32[(((tm)+(___tm_struct_layout.tm_year))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6873 tm_wday: HEAP32[(((tm)+(___tm_struct_layout.tm_wday))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6874 tm_yday: HEAP32[(((tm)+(___tm_struct_layout.tm_yday))>>2)],\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6875 tm_isdst: HEAP32[(((tm)+(___tm_struct_layout.tm_isdst))>>2)]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6876 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6877 var pattern = Pointer_stringify(format);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6878 // expand format\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6879 var EXPANSION_RULES_1 = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6880 '%c': '%a %b %d %H:%M:%S %Y', // Replaced by the locale's appropriate date and time representation - e.g., Mon Aug 3 14:02:01 2013\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6881 '%D': '%m/%d/%y', // Equivalent to %m / %d / %y\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6882 '%F': '%Y-%m-%d', // Equivalent to %Y - %m - %d\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6883 '%h': '%b', // Equivalent to %b\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6884 '%r': '%I:%M:%S %p', // Replaced by the time in a.m. and p.m. notation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6885 '%R': '%H:%M', // Replaced by the time in 24-hour notation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6886 '%T': '%H:%M:%S', // Replaced by the time\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6887 '%x': '%m/%d/%y', // Replaced by the locale's appropriate date representation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6888 '%X': '%H:%M:%S', // Replaced by the locale's appropriate date representation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6889 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6890 for (var rule in EXPANSION_RULES_1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6891 pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6892 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6893 var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6894 var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6895 var leadingSomething = function(value, digits, character) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6896 var str = typeof value === 'number' ? value.toString() : (value || '');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6897 while (str.length < digits) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6898 str = character[0]+str;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6899 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6900 return str;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6901 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6902 var leadingNulls = function(value, digits) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6903 return leadingSomething(value, digits, '0');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6904 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6905 var compareByDay = function(date1, date2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6906 var sgn = function(value) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6907 return value < 0 ? -1 : (value > 0 ? 1 : 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6908 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6909 var compare;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6910 if ((compare = sgn(date1.getFullYear()-date2.getFullYear())) === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6911 if ((compare = sgn(date1.getMonth()-date2.getMonth())) === 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6912 compare = sgn(date1.getDate()-date2.getDate());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6913 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6914 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6915 return compare;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6916 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6917 var getFirstWeekStartDate = function(janFourth) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6918 switch (janFourth.getDay()) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6919 case 0: // Sunday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6920 return new Date(janFourth.getFullYear()-1, 11, 29);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6921 case 1: // Monday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6922 return janFourth;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6923 case 2: // Tuesday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6924 return new Date(janFourth.getFullYear(), 0, 3);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6925 case 3: // Wednesday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6926 return new Date(janFourth.getFullYear(), 0, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6927 case 4: // Thursday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6928 return new Date(janFourth.getFullYear(), 0, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6929 case 5: // Friday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6930 return new Date(janFourth.getFullYear()-1, 11, 31);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6931 case 6: // Saturday\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6932 return new Date(janFourth.getFullYear()-1, 11, 30);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6933 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6934 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6935 var getWeekBasedYear = function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6936 var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6937 var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6938 var janFourthNextYear = new Date(thisDate.getFullYear()+1, 0, 4);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6939 var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6940 var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6941 if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6942 // this date is after the start of the first week of this year\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6943 if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6944 return thisDate.getFullYear()+1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6945 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6946 return thisDate.getFullYear();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6947 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6948 } else { \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6949 return thisDate.getFullYear()-1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6950 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6951 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6952 var EXPANSION_RULES_2 = {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6953 '%a': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6954 return WEEKDAYS[date.tm_wday].substring(0,3);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6955 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6956 '%A': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6957 return WEEKDAYS[date.tm_wday];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6958 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6959 '%b': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6960 return MONTHS[date.tm_mon].substring(0,3);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6961 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6962 '%B': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6963 return MONTHS[date.tm_mon];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6964 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6965 '%C': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6966 var year = date.tm_year+1900;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6967 return leadingNulls(Math.floor(year/100),2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6968 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6969 '%d': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6970 return leadingNulls(date.tm_mday, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6971 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6972 '%e': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6973 return leadingSomething(date.tm_mday, 2, ' ');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6974 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6975 '%g': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6976 // %g, %G, and %V give values according to the ISO 8601:2000 standard week-based year. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6977 // In this system, weeks begin on a Monday and week 1 of the year is the week that includes \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6978 // January 4th, which is also the week that includes the first Thursday of the year, and \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6979 // is also the first week that contains at least four days in the year. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6980 // If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6981 // the last week of the preceding year; thus, for Saturday 2nd January 1999, \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6982 // %G is replaced by 1998 and %V is replaced by 53. If December 29th, 30th, \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6983 // or 31st is a Monday, it and any following days are part of week 1 of the following year. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6984 // Thus, for Tuesday 30th December 1997, %G is replaced by 1998 and %V is replaced by 01.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6985 return getWeekBasedYear(date).toString().substring(2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6986 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6987 '%G': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6988 return getWeekBasedYear(date);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6989 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6990 '%H': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6991 return leadingNulls(date.tm_hour, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6992 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6993 '%I': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6994 return leadingNulls(date.tm_hour < 13 ? date.tm_hour : date.tm_hour-12, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6995 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6996 '%j': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6997 // Day of the year (001-366)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6998 return leadingNulls(date.tm_mday+__arraySum(__isLeapYear(date.tm_year+1900) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, date.tm_mon-1), 3);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6999 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7000 '%m': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7001 return leadingNulls(date.tm_mon+1, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7002 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7003 '%M': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7004 return leadingNulls(date.tm_min, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7005 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7006 '%n': function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7007 return '\\n';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7008 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7009 '%p': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7010 if (date.tm_hour > 0 && date.tm_hour < 13) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7011 return 'AM';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7012 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7013 return 'PM';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7014 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7015 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7016 '%S': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7017 return leadingNulls(date.tm_sec, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7018 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7019 '%t': function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7020 return '\\t';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7021 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7022 '%u': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7023 var day = new Date(date.tm_year+1900, date.tm_mon+1, date.tm_mday, 0, 0, 0, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7024 return day.getDay() || 7;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7025 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7026 '%U': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7027 // Replaced by the week number of the year as a decimal number [00,53]. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7028 // The first Sunday of January is the first day of week 1; \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7029 // days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7030 var janFirst = new Date(date.tm_year+1900, 0, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7031 var firstSunday = janFirst.getDay() === 0 ? janFirst : __addDays(janFirst, 7-janFirst.getDay());\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7032 var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7033 // is target date after the first Sunday?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7034 if (compareByDay(firstSunday, endDate) < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7035 // calculate difference in days between first Sunday and endDate\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7036 var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7037 var firstSundayUntilEndJanuary = 31-firstSunday.getDate();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7038 var days = firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7039 return leadingNulls(Math.ceil(days/7), 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7040 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7041 return compareByDay(firstSunday, janFirst) === 0 ? '01': '00';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7042 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7043 '%V': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7044 // Replaced by the week number of the year (Monday as the first day of the week) \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7045 // as a decimal number [01,53]. If the week containing 1 January has four \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7046 // or more days in the new year, then it is considered week 1. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7047 // Otherwise, it is the last week of the previous year, and the next week is week 1. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7048 // Both January 4th and the first Thursday of January are always in week 1. [ tm_year, tm_wday, tm_yday]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7049 var janFourthThisYear = new Date(date.tm_year+1900, 0, 4);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7050 var janFourthNextYear = new Date(date.tm_year+1901, 0, 4);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7051 var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7052 var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7053 var endDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7054 if (compareByDay(endDate, firstWeekStartThisYear) < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7055 // if given date is before this years first week, then it belongs to the 53rd week of last year\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7056 return '53';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7057 } \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7058 if (compareByDay(firstWeekStartNextYear, endDate) <= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7059 // if given date is after next years first week, then it belongs to the 01th week of next year\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7060 return '01';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7061 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7062 // given date is in between CW 01..53 of this calendar year\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7063 var daysDifference;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7064 if (firstWeekStartThisYear.getFullYear() < date.tm_year+1900) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7065 // first CW of this year starts last year\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7066 daysDifference = date.tm_yday+32-firstWeekStartThisYear.getDate()\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7067 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7068 // first CW of this year starts this year\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7069 daysDifference = date.tm_yday+1-firstWeekStartThisYear.getDate();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7070 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7071 return leadingNulls(Math.ceil(daysDifference/7), 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7072 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7073 '%w': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7074 var day = new Date(date.tm_year+1900, date.tm_mon+1, date.tm_mday, 0, 0, 0, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7075 return day.getDay();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7076 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7077 '%W': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7078 // Replaced by the week number of the year as a decimal number [00,53]. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7079 // The first Monday of January is the first day of week 1; \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7080 // days in the new year before this are in week 0. [ tm_year, tm_wday, tm_yday]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7081 var janFirst = new Date(date.tm_year, 0, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7082 var firstMonday = janFirst.getDay() === 1 ? janFirst : __addDays(janFirst, janFirst.getDay() === 0 ? 1 : 7-janFirst.getDay()+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7083 var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7084 // is target date after the first Monday?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7085 if (compareByDay(firstMonday, endDate) < 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7086 var februaryFirstUntilEndMonth = __arraySum(__isLeapYear(endDate.getFullYear()) ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR, endDate.getMonth()-1)-31;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7087 var firstMondayUntilEndJanuary = 31-firstMonday.getDate();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7088 var days = firstMondayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7089 return leadingNulls(Math.ceil(days/7), 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7090 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7091 return compareByDay(firstMonday, janFirst) === 0 ? '01': '00';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7092 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7093 '%y': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7094 // Replaced by the last two digits of the year as a decimal number [00,99]. [ tm_year]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7095 return (date.tm_year+1900).toString().substring(2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7096 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7097 '%Y': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7098 // Replaced by the year as a decimal number (for example, 1997). [ tm_year]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7099 return date.tm_year+1900;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7100 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7101 '%z': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7102 // Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ),\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7103 // or by no characters if no timezone is determinable. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7104 // For example, \"-0430\" means 4 hours 30 minutes behind UTC (west of Greenwich). \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7105 // If tm_isdst is zero, the standard time offset is used. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7106 // If tm_isdst is greater than zero, the daylight savings time offset is used. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7107 // If tm_isdst is negative, no characters are returned. \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7108 // FIXME: we cannot determine time zone (or can we?)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7109 return '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7110 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7111 '%Z': function(date) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7112 // Replaced by the timezone name or abbreviation, or by no bytes if no timezone information exists. [ tm_isdst]\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7113 // FIXME: we cannot determine time zone (or can we?)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7114 return '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7115 },\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7116 '%%': function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7117 return '%';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7118 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7119 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7120 for (var rule in EXPANSION_RULES_2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7121 if (pattern.indexOf(rule) >= 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7122 pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7123 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7124 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7125 var bytes = intArrayFromString(pattern, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7126 if (bytes.length > maxsize) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7127 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7128 } \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7129 writeArrayToMemory(bytes, s);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7130 return bytes.length-1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7131 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7132 function _clock() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7133 if (_clock.start === undefined) _clock.start = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7134 return Math.floor((Date.now() - _clock.start) * (1000/1000));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7135 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7136 function _toupper(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7137 if (chr >= 97 && chr <= 122) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7138 return chr - 97 + 65;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7139 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7140 return chr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7141 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7142 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7143 function _strpbrk(ptr1, ptr2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7144 var curr;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7145 var searchSet = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7146 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7147 var curr = HEAP8[((ptr2++)|0)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7148 if (!curr) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7149 searchSet[curr] = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7150 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7151 while (1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7152 curr = HEAP8[(ptr1)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7153 if (!curr) break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7154 if (curr in searchSet) return ptr1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7155 ptr1++;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7156 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7157 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7158 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7159 Module[\"_tolower\"] = _tolower;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7160 function _islower(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7161 return chr >= 97 && chr <= 122;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7162 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7163 function _ispunct(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7164 return (chr >= 33 && chr <= 47) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7165 (chr >= 58 && chr <= 64) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7166 (chr >= 91 && chr <= 96) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7167 (chr >= 123 && chr <= 126);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7168 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7169 function _isupper(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7170 return chr >= 65 && chr <= 90;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7171 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7172 function _isxdigit(chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7173 return (chr >= 48 && chr <= 57) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7174 (chr >= 97 && chr <= 102) ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7175 (chr >= 65 && chr <= 70);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7176 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7177 function _strrchr(ptr, chr) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7178 var ptr2 = ptr + _strlen(ptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7179 do {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7180 if (HEAP8[(ptr2)] == chr) return ptr2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7181 ptr2--;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7182 } while (ptr2 >= ptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7183 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7184 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7185 function _abort() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7186 Module['abort']();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7187 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7188 function _sbrk(bytes) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7189 // Implement a Linux-like 'memory area' for our 'process'.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7190 // Changes the size of the memory area by |bytes|; returns the\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7191 // address of the previous top ('break') of the memory area\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7192 // We control the \"dynamic\" memory - DYNAMIC_BASE to DYNAMICTOP\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7193 var self = _sbrk;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7194 if (!self.called) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7195 DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7196 self.called = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7197 assert(Runtime.dynamicAlloc);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7198 self.alloc = Runtime.dynamicAlloc;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7199 Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7200 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7201 var ret = DYNAMICTOP;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7202 if (bytes != 0) self.alloc(bytes);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7203 return ret; // Previous break location.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7204 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7205 function _sysconf(name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7206 // long sysconf(int name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7207 // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7208 switch(name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7209 case 8: return PAGE_SIZE;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7210 case 54:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7211 case 56:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7212 case 21:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7213 case 61:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7214 case 63:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7215 case 22:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7216 case 67:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7217 case 23:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7218 case 24:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7219 case 25:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7220 case 26:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7221 case 27:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7222 case 69:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7223 case 28:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7224 case 101:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7225 case 70:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7226 case 71:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7227 case 29:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7228 case 30:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7229 case 199:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7230 case 75:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7231 case 76:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7232 case 32:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7233 case 43:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7234 case 44:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7235 case 80:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7236 case 46:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7237 case 47:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7238 case 45:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7239 case 48:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7240 case 49:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7241 case 42:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7242 case 82:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7243 case 33:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7244 case 7:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7245 case 108:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7246 case 109:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7247 case 107:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7248 case 112:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7249 case 119:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7250 case 121:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7251 return 200809;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7252 case 13:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7253 case 104:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7254 case 94:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7255 case 95:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7256 case 34:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7257 case 35:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7258 case 77:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7259 case 81:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7260 case 83:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7261 case 84:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7262 case 85:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7263 case 86:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7264 case 87:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7265 case 88:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7266 case 89:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7267 case 90:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7268 case 91:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7269 case 94:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7270 case 95:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7271 case 110:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7272 case 111:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7273 case 113:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7274 case 114:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7275 case 115:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7276 case 116:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7277 case 117:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7278 case 118:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7279 case 120:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7280 case 40:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7281 case 16:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7282 case 79:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7283 case 19:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7284 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7285 case 92:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7286 case 93:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7287 case 5:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7288 case 72:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7289 case 6:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7290 case 74:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7291 case 92:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7292 case 93:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7293 case 96:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7294 case 97:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7295 case 98:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7296 case 99:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7297 case 102:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7298 case 103:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7299 case 105:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7300 return 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7301 case 38:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7302 case 66:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7303 case 50:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7304 case 51:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7305 case 4:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7306 return 1024;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7307 case 15:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7308 case 64:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7309 case 41:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7310 return 32;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7311 case 55:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7312 case 37:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7313 case 17:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7314 return 2147483647;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7315 case 18:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7316 case 1:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7317 return 47839;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7318 case 59:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7319 case 57:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7320 return 99;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7321 case 68:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7322 case 58:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7323 return 2048;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7324 case 0: return 2097152;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7325 case 3: return 65536;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7326 case 14: return 32768;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7327 case 73: return 32767;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7328 case 39: return 16384;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7329 case 60: return 1000;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7330 case 106: return 700;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7331 case 52: return 256;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7332 case 62: return 255;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7333 case 2: return 100;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7334 case 65: return 64;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7335 case 36: return 20;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7336 case 100: return 16;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7337 case 20: return 6;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7338 case 53: return 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7339 case 10: return 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7340 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7341 ___setErrNo(ERRNO_CODES.EINVAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7342 return -1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7343 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7344 var Browser={mainLoop:{scheduler:null,shouldPause:false,paused:false,queue:[],pause:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7345 Browser.mainLoop.shouldPause = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7346 },resume:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7347 if (Browser.mainLoop.paused) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7348 Browser.mainLoop.paused = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7349 Browser.mainLoop.scheduler();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7350 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7351 Browser.mainLoop.shouldPause = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7352 },updateStatus:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7353 if (Module['setStatus']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7354 var message = Module['statusMessage'] || 'Please wait...';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7355 var remaining = Browser.mainLoop.remainingBlockers;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7356 var expected = Browser.mainLoop.expectedBlockers;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7357 if (remaining) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7358 if (remaining < expected) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7359 Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7360 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7361 Module['setStatus'](message);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7362 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7363 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7364 Module['setStatus']('');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7365 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7366 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7367 }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7368 if (!Module[\"preloadPlugins\"]) Module[\"preloadPlugins\"] = []; // needs to exist even in workers\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7369 if (Browser.initted || ENVIRONMENT_IS_WORKER) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7370 Browser.initted = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7371 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7372 new Blob();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7373 Browser.hasBlobConstructor = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7374 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7375 Browser.hasBlobConstructor = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7376 console.log(\"warning: no blob constructor, cannot create blobs with mimetypes\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7377 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7378 Browser.BlobBuilder = typeof MozBlobBuilder != \"undefined\" ? MozBlobBuilder : (typeof WebKitBlobBuilder != \"undefined\" ? WebKitBlobBuilder : (!Browser.hasBlobConstructor ? console.log(\"warning: no BlobBuilder\") : null));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7379 Browser.URLObject = typeof window != \"undefined\" ? (window.URL ? window.URL : window.webkitURL) : undefined;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7380 if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7381 console.log(\"warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available.\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7382 Module.noImageDecoding = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7383 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7384 // Support for plugins that can process preloaded files. You can add more of these to\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7385 // your app by creating and appending to Module.preloadPlugins.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7386 //\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7387 // Each plugin is asked if it can handle a file based on the file's name. If it can,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7388 // it is given the file's raw data. When it is done, it calls a callback with the file's\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7389 // (possibly modified) data. For example, a plugin might decompress a file, or it\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7390 // might create some side data structure for use later (like an Image element, etc.).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7391 var imagePlugin = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7392 imagePlugin['canHandle'] = function(name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7393 return !Module.noImageDecoding && /\\.(jpg|jpeg|png|bmp)$/i.test(name);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7394 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7395 imagePlugin['handle'] = function(byteArray, name, onload, onerror) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7396 var b = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7397 if (Browser.hasBlobConstructor) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7398 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7399 b = new Blob([byteArray], { type: Browser.getMimetype(name) });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7400 if (b.size !== byteArray.length) { // Safari bug #118630\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7401 // Safari's Blob can only take an ArrayBuffer\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7402 b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7403 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7404 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7405 Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7406 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7407 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7408 if (!b) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7409 var bb = new Browser.BlobBuilder();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7410 bb.append((new Uint8Array(byteArray)).buffer); // we need to pass a buffer, and must copy the array to get the right data range\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7411 b = bb.getBlob();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7412 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7413 var url = Browser.URLObject.createObjectURL(b);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7414 var img = new Image();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7415 img.onload = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7416 assert(img.complete, 'Image ' + name + ' could not be decoded');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7417 var canvas = document.createElement('canvas');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7418 canvas.width = img.width;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7419 canvas.height = img.height;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7420 var ctx = canvas.getContext('2d');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7421 ctx.drawImage(img, 0, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7422 Module[\"preloadedImages\"][name] = canvas;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7423 Browser.URLObject.revokeObjectURL(url);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7424 if (onload) onload(byteArray);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7425 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7426 img.onerror = function(event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7427 console.log('Image ' + url + ' could not be decoded');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7428 if (onerror) onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7429 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7430 img.src = url;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7431 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7432 Module['preloadPlugins'].push(imagePlugin);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7433 var audioPlugin = {};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7434 audioPlugin['canHandle'] = function(name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7435 return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7436 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7437 audioPlugin['handle'] = function(byteArray, name, onload, onerror) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7438 var done = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7439 function finish(audio) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7440 if (done) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7441 done = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7442 Module[\"preloadedAudios\"][name] = audio;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7443 if (onload) onload(byteArray);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7444 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7445 function fail() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7446 if (done) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7447 done = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7448 Module[\"preloadedAudios\"][name] = new Audio(); // empty shim\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7449 if (onerror) onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7450 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7451 if (Browser.hasBlobConstructor) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7452 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7453 var b = new Blob([byteArray], { type: Browser.getMimetype(name) });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7454 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7455 return fail();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7456 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7457 var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7458 var audio = new Audio();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7459 audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7460 audio.onerror = function(event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7461 if (done) return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7462 console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7463 function encode64(data) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7464 var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7465 var PAD = '=';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7466 var ret = '';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7467 var leftchar = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7468 var leftbits = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7469 for (var i = 0; i < data.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7470 leftchar = (leftchar << 8) | data[i];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7471 leftbits += 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7472 while (leftbits >= 6) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7473 var curr = (leftchar >> (leftbits-6)) & 0x3f;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7474 leftbits -= 6;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7475 ret += BASE[curr];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7476 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7477 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7478 if (leftbits == 2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7479 ret += BASE[(leftchar&3) << 4];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7480 ret += PAD + PAD;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7481 } else if (leftbits == 4) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7482 ret += BASE[(leftchar&0xf) << 2];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7483 ret += PAD;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7484 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7485 return ret;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7486 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7487 audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7488 finish(audio); // we don't wait for confirmation this worked - but it's worth trying\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7489 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7490 audio.src = url;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7491 // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7492 Browser.safeSetTimeout(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7493 finish(audio); // try to use it even though it is not necessarily ready to play\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7494 }, 10000);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7495 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7496 return fail();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7497 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7498 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7499 Module['preloadPlugins'].push(audioPlugin);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7500 // Canvas event setup\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7501 var canvas = Module['canvas'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7502 canvas.requestPointerLock = canvas['requestPointerLock'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7503 canvas['mozRequestPointerLock'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7504 canvas['webkitRequestPointerLock'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7505 canvas.exitPointerLock = document['exitPointerLock'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7506 document['mozExitPointerLock'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7507 document['webkitExitPointerLock'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7508 function(){}; // no-op if function does not exist\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7509 canvas.exitPointerLock = canvas.exitPointerLock.bind(document);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7510 function pointerLockChange() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7511 Browser.pointerLock = document['pointerLockElement'] === canvas ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7512 document['mozPointerLockElement'] === canvas ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7513 document['webkitPointerLockElement'] === canvas;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7514 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7515 document.addEventListener('pointerlockchange', pointerLockChange, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7516 document.addEventListener('mozpointerlockchange', pointerLockChange, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7517 document.addEventListener('webkitpointerlockchange', pointerLockChange, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7518 if (Module['elementPointerLock']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7519 canvas.addEventListener(\"click\", function(ev) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7520 if (!Browser.pointerLock && canvas.requestPointerLock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7521 canvas.requestPointerLock();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7522 ev.preventDefault();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7523 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7524 }, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7525 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7526 },createContext:function (canvas, useWebGL, setInModule) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7527 var ctx;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7528 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7529 if (useWebGL) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7530 ctx = canvas.getContext('experimental-webgl', {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7531 alpha: false\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7532 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7533 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7534 ctx = canvas.getContext('2d');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7535 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7536 if (!ctx) throw ':(';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7537 } catch (e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7538 Module.print('Could not create canvas - ' + e);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7539 return null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7540 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7541 if (useWebGL) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7542 // Set the background of the WebGL canvas to black\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7543 canvas.style.backgroundColor = \"black\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7544 // Warn on context loss\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7545 canvas.addEventListener('webglcontextlost', function(event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7546 alert('WebGL context lost. You will need to reload the page.');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7547 }, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7548 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7549 if (setInModule) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7550 Module.ctx = ctx;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7551 Module.useWebGL = useWebGL;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7552 Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7553 Browser.init();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7554 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7555 return ctx;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7556 },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7557 Browser.lockPointer = lockPointer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7558 Browser.resizeCanvas = resizeCanvas;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7559 if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7560 if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7561 var canvas = Module['canvas'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7562 function fullScreenChange() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7563 Browser.isFullScreen = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7564 if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7565 document['mozFullScreenElement'] || document['mozFullscreenElement'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7566 document['fullScreenElement'] || document['fullscreenElement']) === canvas) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7567 canvas.cancelFullScreen = document['cancelFullScreen'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7568 document['mozCancelFullScreen'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7569 document['webkitCancelFullScreen'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7570 canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7571 if (Browser.lockPointer) canvas.requestPointerLock();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7572 Browser.isFullScreen = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7573 if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7574 } else if (Browser.resizeCanvas){\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7575 Browser.setWindowedCanvasSize();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7576 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7577 if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7578 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7579 if (!Browser.fullScreenHandlersInstalled) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7580 Browser.fullScreenHandlersInstalled = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7581 document.addEventListener('fullscreenchange', fullScreenChange, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7582 document.addEventListener('mozfullscreenchange', fullScreenChange, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7583 document.addEventListener('webkitfullscreenchange', fullScreenChange, false);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7584 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7585 canvas.requestFullScreen = canvas['requestFullScreen'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7586 canvas['mozRequestFullScreen'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7587 (canvas['webkitRequestFullScreen'] ? function() { canvas['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7588 canvas.requestFullScreen();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7589 },requestAnimationFrame:function (func) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7590 if (!window.requestAnimationFrame) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7591 window.requestAnimationFrame = window['requestAnimationFrame'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7592 window['mozRequestAnimationFrame'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7593 window['webkitRequestAnimationFrame'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7594 window['msRequestAnimationFrame'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7595 window['oRequestAnimationFrame'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7596 window['setTimeout'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7597 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7598 window.requestAnimationFrame(func);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7599 },safeCallback:function (func) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7600 return function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7601 if (!ABORT) return func.apply(null, arguments);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7602 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7603 },safeRequestAnimationFrame:function (func) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7604 return Browser.requestAnimationFrame(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7605 if (!ABORT) func();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7606 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7607 },safeSetTimeout:function (func, timeout) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7608 return setTimeout(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7609 if (!ABORT) func();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7610 }, timeout);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7611 },safeSetInterval:function (func, timeout) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7612 return setInterval(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7613 if (!ABORT) func();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7614 }, timeout);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7615 },getMimetype:function (name) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7616 return {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7617 'jpg': 'image/jpeg',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7618 'jpeg': 'image/jpeg',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7619 'png': 'image/png',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7620 'bmp': 'image/bmp',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7621 'ogg': 'audio/ogg',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7622 'wav': 'audio/wav',\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7623 'mp3': 'audio/mpeg'\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7624 }[name.substr(name.lastIndexOf('.')+1)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7625 },getUserMedia:function (func) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7626 if(!window.getUserMedia) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7627 window.getUserMedia = navigator['getUserMedia'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7628 navigator['mozGetUserMedia'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7629 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7630 window.getUserMedia(func);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7631 },getMovementX:function (event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7632 return event['movementX'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7633 event['mozMovementX'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7634 event['webkitMovementX'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7635 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7636 },getMovementY:function (event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7637 return event['movementY'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7638 event['mozMovementY'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7639 event['webkitMovementY'] ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7640 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7641 },mouseX:0,mouseY:0,mouseMovementX:0,mouseMovementY:0,calculateMouseEvent:function (event) { // event should be mousemove, mousedown or mouseup\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7642 if (Browser.pointerLock) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7643 // When the pointer is locked, calculate the coordinates\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7644 // based on the movement of the mouse.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7645 // Workaround for Firefox bug 764498\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7646 if (event.type != 'mousemove' &&\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7647 ('mozMovementX' in event)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7648 Browser.mouseMovementX = Browser.mouseMovementY = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7649 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7650 Browser.mouseMovementX = Browser.getMovementX(event);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7651 Browser.mouseMovementY = Browser.getMovementY(event);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7652 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7653 // check if SDL is available\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7654 if (typeof SDL != \"undefined\") {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7655 Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7656 Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7657 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7658 // just add the mouse delta to the current absolut mouse position\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7659 // FIXME: ideally this should be clamped against the canvas size and zero\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7660 Browser.mouseX += Browser.mouseMovementX;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7661 Browser.mouseY += Browser.mouseMovementY;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7662 } \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7663 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7664 // Otherwise, calculate the movement based on the changes\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7665 // in the coordinates.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7666 var rect = Module[\"canvas\"].getBoundingClientRect();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7667 var x, y;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7668 if (event.type == 'touchstart' ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7669 event.type == 'touchend' ||\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7670 event.type == 'touchmove') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7671 var t = event.touches.item(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7672 if (t) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7673 x = t.pageX - (window.scrollX + rect.left);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7674 y = t.pageY - (window.scrollY + rect.top);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7675 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7676 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7677 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7678 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7679 x = event.pageX - (window.scrollX + rect.left);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7680 y = event.pageY - (window.scrollY + rect.top);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7681 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7682 // the canvas might be CSS-scaled compared to its backbuffer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7683 // SDL-using content will want mouse coordinates in terms\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7684 // of backbuffer units.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7685 var cw = Module[\"canvas\"].width;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7686 var ch = Module[\"canvas\"].height;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7687 x = x * (cw / rect.width);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7688 y = y * (ch / rect.height);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7689 Browser.mouseMovementX = x - Browser.mouseX;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7690 Browser.mouseMovementY = y - Browser.mouseY;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7691 Browser.mouseX = x;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7692 Browser.mouseY = y;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7693 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7694 },xhrLoad:function (url, onload, onerror) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7695 var xhr = new XMLHttpRequest();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7696 xhr.open('GET', url, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7697 xhr.responseType = 'arraybuffer';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7698 xhr.onload = function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7699 if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7700 onload(xhr.response);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7701 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7702 onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7703 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7704 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7705 xhr.onerror = onerror;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7706 xhr.send(null);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7707 },asyncLoad:function (url, onload, onerror, noRunDep) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7708 Browser.xhrLoad(url, function(arrayBuffer) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7709 assert(arrayBuffer, 'Loading data file \"' + url + '\" failed (no arrayBuffer).');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7710 onload(new Uint8Array(arrayBuffer));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7711 if (!noRunDep) removeRunDependency('al ' + url);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7712 }, function(event) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7713 if (onerror) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7714 onerror();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7715 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7716 throw 'Loading data file \"' + url + '\" failed.';\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7717 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7718 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7719 if (!noRunDep) addRunDependency('al ' + url);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7720 },resizeListeners:[],updateResizeListeners:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7721 var canvas = Module['canvas'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7722 Browser.resizeListeners.forEach(function(listener) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7723 listener(canvas.width, canvas.height);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7724 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7725 },setCanvasSize:function (width, height, noUpdates) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7726 var canvas = Module['canvas'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7727 canvas.width = width;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7728 canvas.height = height;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7729 if (!noUpdates) Browser.updateResizeListeners();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7730 },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7731 var canvas = Module['canvas'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7732 this.windowedWidth = canvas.width;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7733 this.windowedHeight = canvas.height;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7734 canvas.width = screen.width;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7735 canvas.height = screen.height;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7736 // check if SDL is available \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7737 if (typeof SDL != \"undefined\") {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7738 var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7739 flags = flags | 0x00800000; // set SDL_FULLSCREEN flag\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7740 HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7741 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7742 Browser.updateResizeListeners();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7743 },setWindowedCanvasSize:function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7744 var canvas = Module['canvas'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7745 canvas.width = this.windowedWidth;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7746 canvas.height = this.windowedHeight;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7747 // check if SDL is available \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7748 if (typeof SDL != \"undefined\") {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7749 var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7750 flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7751 HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7752 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7753 Browser.updateResizeListeners();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7754 }};\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7755 _fputc.ret = allocate([0], \"i8\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7756 FS.staticInit();__ATINIT__.unshift({ func: function() { if (!Module[\"noFSInit\"] && !FS.init.initialized) FS.init() } });__ATMAIN__.push({ func: function() { FS.ignorePermissions = false } });__ATEXIT__.push({ func: function() { FS.quit() } });Module[\"FS_createFolder\"] = FS.createFolder;Module[\"FS_createPath\"] = FS.createPath;Module[\"FS_createDataFile\"] = FS.createDataFile;Module[\"FS_createPreloadedFile\"] = FS.createPreloadedFile;Module[\"FS_createLazyFile\"] = FS.createLazyFile;Module[\"FS_createLink\"] = FS.createLink;Module[\"FS_createDevice\"] = FS.createDevice;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7757 ___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7758 __ATINIT__.unshift({ func: function() { TTY.init() } });__ATEXIT__.push({ func: function() { TTY.shutdown() } });TTY.utf8 = new Runtime.UTF8Processor();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7759 __ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7760 _fgetc.ret = allocate([0], \"i8\", ALLOC_STATIC);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7761 ___buildEnvironment(ENV);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7762 Module[\"requestFullScreen\"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7763 Module[\"requestAnimationFrame\"] = function(func) { Browser.requestAnimationFrame(func) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7764 Module[\"setCanvasSize\"] = function(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7765 Module[\"pauseMainLoop\"] = function() { Browser.mainLoop.pause() };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7766 Module[\"resumeMainLoop\"] = function() { Browser.mainLoop.resume() };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7767 Module[\"getUserMedia\"] = function() { Browser.getUserMedia() }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7768 STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7769 staticSealed = true; // seal the static portion of memory\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7770 STACK_MAX = STACK_BASE + 5242880;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7771 DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7772 assert(DYNAMIC_BASE < TOTAL_MEMORY); // Stack must fit in TOTAL_MEMORY; allocations from here on may enlarge TOTAL_MEMORY\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7773 var Math_min = Math.min;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7774 function invoke_ii(index,a1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7775 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7776 return Module[\"dynCall_ii\"](index,a1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7777 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7778 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7779 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7780 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7781 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7782 function invoke_vi(index,a1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7783 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7784 Module[\"dynCall_vi\"](index,a1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7785 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7786 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7787 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7788 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7789 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7790 function invoke_vii(index,a1,a2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7791 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7792 Module[\"dynCall_vii\"](index,a1,a2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7793 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7794 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7795 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7796 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7797 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7798 function invoke_iiiii(index,a1,a2,a3,a4) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7799 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7800 return Module[\"dynCall_iiiii\"](index,a1,a2,a3,a4);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7801 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7802 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7803 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7804 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7805 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7806 function invoke_iiii(index,a1,a2,a3) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7807 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7808 return Module[\"dynCall_iiii\"](index,a1,a2,a3);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7809 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7810 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7811 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7812 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7813 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7814 function invoke_v(index) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7815 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7816 Module[\"dynCall_v\"](index);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7817 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7818 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7819 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7820 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7821 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7822 function invoke_iii(index,a1,a2) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7823 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7824 return Module[\"dynCall_iii\"](index,a1,a2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7825 } catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7826 if (typeof e !== 'number' && e !== 'longjmp') throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7827 asm[\"setThrew\"](1, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7828 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7829 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7830 function asmPrintInt(x, y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7831 Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7832 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7833 function asmPrintFloat(x, y) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7834 Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7835 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7836 // EMSCRIPTEN_START_ASM\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7837 var asm=(function(global,env,buffer){\"use asm\";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env._stdin|0;var n=env._stderr|0;var o=env._stdout|0;var p=+env.NaN;var q=+env.Infinity;var r=0;var s=0;var t=0;var u=0;var v=0,w=0,x=0,y=0,z=0.0,A=0,B=0,C=0,D=0.0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=0;var N=0;var O=global.Math.floor;var P=global.Math.abs;var Q=global.Math.sqrt;var R=global.Math.pow;var S=global.Math.cos;var T=global.Math.sin;var U=global.Math.tan;var V=global.Math.acos;var W=global.Math.asin;var X=global.Math.atan;var Y=global.Math.atan2;var Z=global.Math.exp;var _=global.Math.log;var $=global.Math.ceil;var aa=global.Math.imul;var ab=env.abort;var ac=env.assert;var ad=env.asmPrintInt;var ae=env.asmPrintFloat;var af=env.min;var ag=env.jsCall;var ah=env.invoke_ii;var ai=env.invoke_vi;var aj=env.invoke_vii;var ak=env.invoke_iiiii;var al=env.invoke_iiii;var am=env.invoke_v;var an=env.invoke_iii;var ao=env._llvm_lifetime_end;var ap=env._lseek;var aq=env.__scanString;var ar=env._fclose;var as=env._strtoul;var at=env.__isFloat;var au=env._fflush;var av=env._fputc;var aw=env._fwrite;var ax=env._strncmp;var ay=env._send;var az=env._fputs;var aA=env._tmpnam;var aB=env._isspace;var aC=env._localtime;var aD=env._read;var aE=env._ceil;var aF=env._strstr;var aG=env._fsync;var aH=env._fscanf;var aI=env._fmod;var aJ=env._remove;var aK=env._modf;var aL=env._strcmp;var aM=env._memchr;var aN=env._llvm_va_end;var aO=env._tmpfile;var aP=env._snprintf;var aQ=env._fgetc;var aR=env._cosh;var aS=env._fgets;var aT=env._close;var aU=env._strchr;var aV=env._asin;var aW=env._clock;var aX=env.___setErrNo;var aY=env._isxdigit;var aZ=env._ftell;var a_=env._exit;var a$=env._sprintf;var a0=env._strrchr;var a1=env._freopen;var a2=env._strcspn;var a3=env.__isLeapYear;var a4=env._ferror;var a5=env._gmtime;var a6=env._localtime_r;var a7=env._sinh;var a8=env._recv;var a9=env._cos;var ba=env._putchar;var bb=env._islower;var bc=env.__exit;var bd=env._isupper;var be=env._strftime;var bf=env._rand;var bg=env._tzset;var bh=env._setlocale;var bi=env._ldexp;var bj=env._toupper;var bk=env._pread;var bl=env._fopen;var bm=env._open;var bn=env._frexp;var bo=env.__arraySum;var bp=env._log;var bq=env._isalnum;var br=env._mktime;var bs=env._system;var bt=env._isalpha;var bu=env._rmdir;var bv=env._log10;var bw=env._fread;var bx=env.__reallyNegative;var by=env.__formatString;var bz=env._getenv;var bA=env._llvm_pow_f64;var bB=env._sbrk;var bC=env._tanh;var bD=env._localeconv;var bE=env.___errno_location;var bF=env._strerror;var bG=env._llvm_lifetime_start;var bH=env.__parseInt;var bI=env._ungetc;var bJ=env._rename;var bK=env._sysconf;var bL=env._srand;var bM=env._abort;var bN=env._fprintf;var bO=env._tan;var bP=env.___buildEnvironment;var bQ=env._feof;var bR=env.__addDays;var bS=env._strncat;var bT=env._gmtime_r;var bU=env._ispunct;var bV=env._clearerr;var bW=env._fabs;var bX=env._floor;var bY=env._fseek;var bZ=env._sqrt;var b_=env._write;var b$=env._sin;var b0=env._longjmp;var b1=env._atan;var b2=env._strpbrk;var b3=env._unlink;var b4=env._acos;var b5=env._pwrite;var b6=env._strerror_r;var b7=env._difftime;var b8=env._iscntrl;var b9=env._atan2;var ca=env._exp;var cb=env._time;var cc=env._setvbuf;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7838 // EMSCRIPTEN_START_FUNCS\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7839 function ck(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+7>>3<<3;return b|0}function cl(){return i|0}function cm(a){a=a|0;i=a}function cn(a,b){a=a|0;b=b|0;if((r|0)==0){r=a;s=b}}function co(b){b=b|0;a[k]=a[b];a[k+1|0]=a[b+1|0];a[k+2|0]=a[b+2|0];a[k+3|0]=a[b+3|0]}function cp(b){b=b|0;a[k]=a[b];a[k+1|0]=a[b+1|0];a[k+2|0]=a[b+2|0];a[k+3|0]=a[b+3|0];a[k+4|0]=a[b+4|0];a[k+5|0]=a[b+5|0];a[k+6|0]=a[b+6|0];a[k+7|0]=a[b+7|0]}function cq(a){a=a|0;E=a}function cr(a){a=a|0;F=a}function cs(a){a=a|0;G=a}function ct(a){a=a|0;H=a}function cu(a){a=a|0;I=a}function cv(a){a=a|0;J=a}function cw(a){a=a|0;K=a}function cx(a){a=a|0;L=a}function cy(a){a=a|0;M=a}function cz(a){a=a|0;N=a}function cA(){}function cB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;d=a+8|0;a=c[d>>2]|0;e=b;f=a;g=c[e+4>>2]|0;c[f>>2]=c[e>>2];c[f+4>>2]=g;c[a+8>>2]=c[b+8>>2];c[d>>2]=(c[d>>2]|0)+16;return}function cC(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if((a|0)==(b|0)){return}e=a+8|0;a=(c[e>>2]|0)+(-d<<4)|0;c[e>>2]=a;if((d|0)<=0){return}f=b+8|0;b=0;g=a;while(1){a=c[f>>2]|0;c[f>>2]=a+16;h=g+(b<<4)|0;i=a;j=c[h+4>>2]|0;c[i>>2]=c[h>>2];c[i+4>>2]=j;c[a+8>>2]=c[g+(b<<4)+8>>2];a=b+1|0;if((a|0)>=(d|0)){break}b=a;g=c[e>>2]|0}return}function cD(a,c){a=a|0;c=c|0;b[c+52>>1]=b[a+52>>1]|0;return}function cE(a,b){a=a|0;b=b|0;var d=0;d=(c[a+16>>2]|0)+88|0;a=c[d>>2]|0;c[d>>2]=b;return a|0}function cF(a){a=a|0;return(c[a+8>>2]|0)-(c[a+12>>2]|0)>>4|0}function cG(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;if((b|0)<=-1){d=a+8|0;c[d>>2]=(c[d>>2]|0)+(b+1<<4);return}d=a+8|0;e=c[d>>2]|0;f=a+12|0;a=(c[f>>2]|0)+(b<<4)|0;if(e>>>0<a>>>0){g=e;while(1){c[d>>2]=g+16;c[g+8>>2]=0;e=c[d>>2]|0;h=(c[f>>2]|0)+(b<<4)|0;if(e>>>0<h>>>0){g=e}else{i=h;break}}}else{i=a}c[d>>2]=i;return}function cH(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=f+16|0;g=a+8|0;a=c[g>>2]|0;if(b>>>0<a>>>0){h=f;i=b}else{j=a;k=j-16|0;c[g>>2]=k;return}while(1){a=i;b=h;f=c[a+4>>2]|0;c[b>>2]=c[a>>2];c[b+4>>2]=f;c[h+8>>2]=c[h+24>>2];f=i+16|0;b=c[g>>2]|0;if(f>>>0<b>>>0){h=i;i=f}else{j=b;break}}k=j-16|0;c[g>>2]=k;return}function cI(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=a+8|0;a=c[b>>2]|0;if(a>>>0>f>>>0){h=a}else{i=a;j=i;k=f;l=j|0;m=c[l>>2]|0;n=j+4|0;o=c[n>>2]|0;p=k|0;c[p>>2]=m;q=k+4|0;c[q>>2]=o;r=i+8|0;s=c[r>>2]|0;t=f+8|0;c[t>>2]=s;return}while(1){a=h-16|0;g=a;e=h;u=c[g+4>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=u;c[h+8>>2]=c[h-16+8>>2];if(a>>>0>f>>>0){h=a}else{break}}i=c[b>>2]|0;j=i;k=f;l=j|0;m=c[l>>2]|0;n=j+4|0;o=c[n>>2]|0;p=k|0;c[p>>2]=m;q=k+4|0;c[q>>2]=o;r=i+8|0;s=c[r>>2]|0;t=f+8|0;c[t>>2]=s;return}function cJ(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=a+8|0;a=c[b>>2]|0;g=f;e=a;h=c[g+4>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=h;c[a+8>>2]=c[f+8>>2];c[b>>2]=(c[b>>2]|0)+16;return}function cK(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){h=-1;return h|0}else{f=e+24+(g-1<<4)|0;break}}}}while(0);if((f|0)==1032){h=-1;return h|0}h=c[f+8>>2]|0;return h|0}function cL(a,b){a=a|0;b=b|0;var d=0;if((b|0)==-1){d=10432}else{d=c[872+(b<<2)>>2]|0}return d|0}function cM(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0;do{if((e|0)>0){f=(c[b+12>>2]|0)+(e-1<<4)|0;g=f>>>0<(c[b+8>>2]|0)>>>0?f:1032}else{if((e|0)>-1e4){g=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-1e4|0)){g=(c[b+16>>2]|0)+96|0;break}else if((e|0)==(-10001|0)){f=b+88|0;c[f>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;g=f;break}else if((e|0)==(-10002|0)){g=b+72|0;break}else{f=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[f+7|0]|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);if((c[g+8>>2]|0)!=6){i=0;return i|0}i=(a[(c[g>>2]|0)+6|0]|0)!=0|0;return i|0}function cN(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;if((b|0)>8e3){d=0;return d|0}e=a+8|0;f=c[e>>2]|0;g=f;if(((g-(c[a+12>>2]|0)>>4)+b|0)>8e3){d=0;return d|0}if((b|0)<=0){d=1;return d|0}if(((c[a+28>>2]|0)-g|0)>(b<<4|0)){h=f}else{eA(a,b);h=c[e>>2]|0}e=(c[a+20>>2]|0)+8|0;a=h+(b<<4)|0;if((c[e>>2]|0)>>>0>=a>>>0){d=1;return d|0}c[e>>2]=a;d=1;return d|0}function cO(a){a=a|0;var b=0,d=0;b=c[a+16>>2]|0;if((c[b+68>>2]|0)>>>0>=(c[b+64>>2]|0)>>>0){e1(a)}b=fT(a)|0;d=a+8|0;a=c[d>>2]|0;c[a>>2]=b;c[a+8>>2]=8;c[d>>2]=(c[d>>2]|0)+16;return b|0}function cP(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;f=i;g=(e|0)==-10001;do{if(g){h=c[b+20>>2]|0;if((h|0)!=(c[b+40>>2]|0)){j=h;k=124;break}es(b,10448,(h=i,i=i+1|0,i=i+7>>3<<3,c[h>>2]=0,h)|0);i=h;k=117}else{k=117}}while(0);do{if((k|0)==117){if((e|0)>0){h=(c[b+12>>2]|0)+(e-1<<4)|0;l=h>>>0<(c[b+8>>2]|0)>>>0?h:1032;break}if((e|0)>-1e4){l=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-1e4|0)){l=(c[b+16>>2]|0)+96|0;break}else if((e|0)==(-10001|0)){j=c[b+20>>2]|0;k=124;break}else if((e|0)==(-10002|0)){l=b+72|0;break}else{h=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;m=-10002-e|0;if((m|0)>(d[h+7|0]|0|0)){l=1032;break}l=h+24+(m-1<<4)|0;break}}}while(0);if((k|0)==124){k=b+88|0;c[k>>2]=c[(c[c[j+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;l=k}do{if(g){k=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;j=b+8|0;c[k+12>>2]=c[(c[j>>2]|0)-16>>2];m=c[j>>2]|0;if((c[m-16+8>>2]|0)<=3){break}j=c[m-16>>2]|0;if((a[j+5|0]&3)==0){break}if((a[k+5|0]&4)==0){break}e7(b,k,j)}else{j=b+8|0;k=c[j>>2]|0;m=k-16|0;h=l;n=c[m+4>>2]|0;c[h>>2]=c[m>>2];c[h+4>>2]=n;c[l+8>>2]=c[k-16+8>>2];if((e|0)>=-10002){break}k=c[j>>2]|0;if((c[k-16+8>>2]|0)<=3){break}j=c[k-16>>2]|0;if((a[j+5|0]&3)==0){break}k=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;if((a[k+5|0]&4)==0){break}e7(b,k,j)}}while(0);e=b+8|0;c[e>>2]=(c[e>>2]|0)-16;i=f;return}function cQ(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032;g=149}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;g=149;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;g=149;break}else if((b|0)==(-10002|0)){f=a+72|0;g=149;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;g=149;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[e+7|0]|0|0)){i=-1;break}f=e+24+(h-1<<4)|0;g=149;break}}}while(0);do{if((g|0)==149){if((f|0)==1032){i=-1;break}b=c[f+8>>2]|0;if((b|0)==4){j=1}else{i=b;break}return j|0}}while(0);j=(i|0)==3|0;return j|0}function cR(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=c[f+8>>2]|0;if((b|0)==7){h=1;return h|0}h=(b|0)==2|0;return h|0}function cS(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0;e=i;i=i+16|0;f=e|0;do{if((b|0)>0){g=(c[a+12>>2]|0)+(b-1<<4)|0;h=g>>>0<(c[a+8>>2]|0)>>>0?g:1032}else{if((b|0)>-1e4){h=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){g=a+88|0;c[g>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;h=g;break}else if((b|0)==(-1e4|0)){h=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){h=a+72|0;break}else{g=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;j=-10002-b|0;if((j|0)>(d[g+7|0]|0|0)){h=1032;break}h=g+24+(j-1<<4)|0;break}}}while(0);if((c[h+8>>2]|0)==3){k=1;i=e;return k|0}k=(gk(h,f)|0)!=0|0;i=e;return k|0}function cT(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;do{if((b|0)>0){f=(c[a+12>>2]|0)+(b-1<<4)|0;g=f>>>0<(c[a+8>>2]|0)>>>0?f:1032}else{if((b|0)>-1e4){g=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10002|0)){g=a+72|0;break}else if((b|0)==(-10001|0)){f=a+88|0;c[f>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;g=f;break}else if((b|0)==(-1e4|0)){g=(c[a+16>>2]|0)+96|0;break}else{f=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);do{if((e|0)>0){b=(c[a+12>>2]|0)+(e-1<<4)|0;i=b>>>0<(c[a+8>>2]|0)>>>0?b:1032}else{if((e|0)>-1e4){i=(c[a+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10001|0)){b=a+88|0;c[b>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;i=b;break}else if((e|0)==(-10002|0)){i=a+72|0;break}else if((e|0)==(-1e4|0)){i=(c[a+16>>2]|0)+96|0;break}else{b=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[b+7|0]|0|0)){j=0;return j|0}else{i=b+24+(h-1<<4)|0;break}}}}while(0);if((g|0)==1032|(i|0)==1032){j=0;return j|0}j=fr(g,i)|0;return j|0}function cU(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;do{if((b|0)>0){f=(c[a+12>>2]|0)+(b-1<<4)|0;g=f>>>0<(c[a+8>>2]|0)>>>0?f:1032}else{if((b|0)>-1e4){g=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10002|0)){g=a+72|0;break}else if((b|0)==(-1e4|0)){g=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){f=a+88|0;c[f>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;g=f;break}else{f=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);do{if((e|0)>0){b=(c[a+12>>2]|0)+(e-1<<4)|0;i=b>>>0<(c[a+8>>2]|0)>>>0?b:1032}else{if((e|0)>-1e4){i=(c[a+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10001|0)){b=a+88|0;c[b>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;i=b;break}else if((e|0)==(-10002|0)){i=a+72|0;break}else if((e|0)==(-1e4|0)){i=(c[a+16>>2]|0)+96|0;break}else{b=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[b+7|0]|0|0)){j=0;return j|0}else{i=b+24+(h-1<<4)|0;break}}}}while(0);if((g|0)==1032|(i|0)==1032){j=0;return j|0}if((c[g+8>>2]|0)!=(c[i+8>>2]|0)){j=0;return j|0}j=(gp(a,g,i)|0)!=0|0;return j|0}function cV(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;do{if((b|0)>0){f=(c[a+12>>2]|0)+(b-1<<4)|0;g=f>>>0<(c[a+8>>2]|0)>>>0?f:1032}else{if((b|0)>-1e4){g=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10002|0)){g=a+72|0;break}else if((b|0)==(-10001|0)){f=a+88|0;c[f>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;g=f;break}else if((b|0)==(-1e4|0)){g=(c[a+16>>2]|0)+96|0;break}else{f=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);do{if((e|0)>0){b=(c[a+12>>2]|0)+(e-1<<4)|0;i=b>>>0<(c[a+8>>2]|0)>>>0?b:1032}else{if((e|0)>-1e4){i=(c[a+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10001|0)){b=a+88|0;c[b>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;i=b;break}else if((e|0)==(-10002|0)){i=a+72|0;break}else if((e|0)==(-1e4|0)){i=(c[a+16>>2]|0)+96|0;break}else{b=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[b+7|0]|0|0)){j=0;return j|0}else{i=b+24+(h-1<<4)|0;break}}}}while(0);if((g|0)==1032|(i|0)==1032){j=0;return j|0}j=go(a,g,i)|0;return j|0}function cW(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,j=0,k=0,l=0,m=0.0;e=i;i=i+16|0;f=e|0;do{if((b|0)>0){g=(c[a+12>>2]|0)+(b-1<<4)|0;j=g>>>0<(c[a+8>>2]|0)>>>0?g:1032}else{if((b|0)>-1e4){j=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){g=a+88|0;c[g>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;j=g;break}else if((b|0)==(-10002|0)){j=a+72|0;break}else if((b|0)==(-1e4|0)){j=(c[a+16>>2]|0)+96|0;break}else{g=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;k=-10002-b|0;if((k|0)>(d[g+7|0]|0|0)){j=1032;break}j=g+24+(k-1<<4)|0;break}}}while(0);do{if((c[j+8>>2]|0)==3){l=j}else{b=gk(j,f)|0;if((b|0)==0){m=0.0}else{l=b;break}i=e;return+m}}while(0);m=+h[l>>3];i=e;return+m}function cX(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=c[f+8>>2]|0;if((b|0)==0){h=0;return h|0}if((b|0)!=1){h=1;return h|0}h=(c[f>>2]|0)!=0|0;return h|0}function cY(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0;do{if((e|0)>0){f=(c[b+12>>2]|0)+(e-1<<4)|0;g=f>>>0<(c[b+8>>2]|0)>>>0?f:1032}else{if((e|0)>-1e4){g=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10001|0)){f=b+88|0;c[f>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;g=f;break}else if((e|0)==(-1e4|0)){g=(c[b+16>>2]|0)+96|0;break}else if((e|0)==(-10002|0)){g=b+72|0;break}else{f=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[f+7|0]|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);if((c[g+8>>2]|0)!=6){i=0;return i|0}e=c[g>>2]|0;if((a[e+6|0]|0)==0){i=0;return i|0}i=c[e+16>>2]|0;return i|0}function cZ(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=c[f+8>>2]|0;if((b|0)==7){h=(c[f>>2]|0)+24|0;return h|0}else if((b|0)==2){h=c[f>>2]|0;return h|0}else{h=0;return h|0}return 0}function c_(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);if((c[f+8>>2]|0)!=8){h=0;return h|0}h=c[f>>2]|0;return h|0}function c$(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,j=0,k=0,l=0,m=0;e=i;i=i+16|0;f=e|0;do{if((b|0)>0){g=(c[a+12>>2]|0)+(b-1<<4)|0;j=g>>>0<(c[a+8>>2]|0)>>>0?g:1032}else{if((b|0)>-1e4){j=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10002|0)){j=a+72|0;break}else if((b|0)==(-1e4|0)){j=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){g=a+88|0;c[g>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;j=g;break}else{g=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;k=-10002-b|0;if((k|0)>(d[g+7|0]|0|0)){j=1032;break}j=g+24+(k-1<<4)|0;break}}}while(0);do{if((c[j+8>>2]|0)==3){l=j}else{b=gk(j,f)|0;if((b|0)==0){m=0}else{l=b;break}i=e;return m|0}}while(0);m=~~+h[l>>3];i=e;return m|0}function c0(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;f=(b|0)>0;do{if(f){g=(c[a+12>>2]|0)+(b-1<<4)|0;h=g>>>0<(c[a+8>>2]|0)>>>0?g:1032}else{if((b|0)>-1e4){h=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){g=a+88|0;c[g>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;h=g;break}else if((b|0)==(-1e4|0)){h=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){h=a+72|0;break}else{g=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;i=-10002-b|0;if((i|0)>(d[g+7|0]|0|0)){h=1032;break}h=g+24+(i-1<<4)|0;break}}}while(0);do{if((c[h+8>>2]|0)==4){j=h}else{if((gl(a,h)|0)==0){if((e|0)==0){k=0;return k|0}c[e>>2]=0;k=0;return k|0}i=a+16|0;g=c[i>>2]|0;if((c[g+68>>2]|0)>>>0>=(c[g+64>>2]|0)>>>0){e1(a)}if(f){g=(c[a+12>>2]|0)+(b-1<<4)|0;j=g>>>0<(c[a+8>>2]|0)>>>0?g:1032;break}if((b|0)>-1e4){j=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){j=(c[i>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){i=a+88|0;c[i>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;j=i;break}else if((b|0)==(-10002|0)){j=a+72|0;break}else{i=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[i+7|0]|0|0)){j=1032;break}j=i+24+(g-1<<4)|0;break}}}while(0);b=j;if((e|0)!=0){c[e>>2]=c[(c[b>>2]|0)+12>>2]}k=(c[b>>2]|0)+16|0;return k|0}function c1(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=c[f+8>>2]|0;if((b|0)==4){h=c[(c[f>>2]|0)+12>>2]|0;return h|0}else if((b|0)==3){if((gl(a,f)|0)==0){h=0;return h|0}h=c[(c[f>>2]|0)+12>>2]|0;return h|0}else if((b|0)==7){h=c[(c[f>>2]|0)+16>>2]|0;return h|0}else if((b|0)==5){h=ga(c[f>>2]|0)|0;return h|0}else{h=0;return h|0}return 0}function c2(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=(b|0)>0;do{if(e){f=(c[a+12>>2]|0)+(b-1<<4)|0;g=f>>>0<(c[a+8>>2]|0)>>>0?f:1032}else{if((b|0)>-1e4){g=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){g=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){g=a+72|0;break}else if((b|0)==(-10001|0)){f=a+88|0;c[f>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;g=f;break}else{f=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);switch(c[g+8>>2]|0){case 5:{i=c[g>>2]|0;return i|0};case 6:{i=c[g>>2]|0;return i|0};case 8:{i=c[g>>2]|0;return i|0};case 7:case 2:{do{if(e){g=(c[a+12>>2]|0)+(b-1<<4)|0;j=g>>>0<(c[a+8>>2]|0)>>>0?g:1032}else{if((b|0)>-1e4){j=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10002|0)){j=a+72|0;break}else if((b|0)==(-10001|0)){g=a+88|0;c[g>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;j=g;break}else if((b|0)==(-1e4|0)){j=(c[a+16>>2]|0)+96|0;break}else{g=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[g+7|0]|0|0)){j=1032;break}j=g+24+(h-1<<4)|0;break}}}while(0);b=c[j+8>>2]|0;if((b|0)==2){i=c[j>>2]|0;return i|0}else if((b|0)==7){i=(c[j>>2]|0)+24|0;return i|0}else{i=0;return i|0}break};default:{i=0;return i|0}}return 0}function c3(a){a=a|0;var b=0;b=a+8|0;c[(c[b>>2]|0)+8>>2]=0;c[b>>2]=(c[b>>2]|0)+16;return}function c4(a,b){a=a|0;b=+b;var d=0;d=a+8|0;a=c[d>>2]|0;h[a>>3]=b;c[a+8>>2]=3;c[d>>2]=(c[d>>2]|0)+16;return}function c5(a,b){a=a|0;b=b|0;var d=0;d=a+8|0;a=c[d>>2]|0;h[a>>3]=+(b|0);c[a+8>>2]=3;c[d>>2]=(c[d>>2]|0)+16;return}function c6(a,b){a=a|0;b=b|0;var d=0;d=a+8|0;a=c[d>>2]|0;c[a>>2]=(b|0)!=0;c[a+8>>2]=1;c[d>>2]=(c[d>>2]|0)+16;return}function c7(a,b){a=a|0;b=b|0;var d=0;d=a+8|0;a=c[d>>2]|0;c[a>>2]=b;c[a+8>>2]=2;c[d>>2]=(c[d>>2]|0)+16;return}function c8(a){a=a|0;var b=0,d=0;b=a+8|0;d=c[b>>2]|0;c[d>>2]=a;c[d+8>>2]=8;c[b>>2]=(c[b>>2]|0)+16;return(c[(c[a+16>>2]|0)+112>>2]|0)==(a|0)|0}function c9(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=c[a+16>>2]|0;if((c[e+68>>2]|0)>>>0>=(c[e+64>>2]|0)>>>0){e1(a)}e=a+8|0;f=c[e>>2]|0;c[f>>2]=f_(a,b,d)|0;c[f+8>>2]=4;c[e>>2]=(c[e>>2]|0)+16;return}function da(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((b|0)==0){d=a+8|0;c[(c[d>>2]|0)+8>>2]=0;c[d>>2]=(c[d>>2]|0)+16;return}d=j_(b|0)|0;e=c[a+16>>2]|0;if((c[e+68>>2]|0)>>>0>=(c[e+64>>2]|0)>>>0){e1(a)}e=a+8|0;f=c[e>>2]|0;c[f>>2]=f_(a,b,d)|0;c[f+8>>2]=4;c[e>>2]=(c[e>>2]|0)+16;return}function db(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=c[a+16>>2]|0;if((c[e+68>>2]|0)>>>0>=(c[e+64>>2]|0)>>>0){e1(a)}return fx(a,b,d)|0}function dc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=i;i=i+16|0;f=e|0;g=c[a+16>>2]|0;if((c[g+68>>2]|0)>>>0>=(c[g+64>>2]|0)>>>0){e1(a)}g=f;c[g>>2]=d;c[g+4>>2]=0;g=fx(a,b,f|0)|0;i=e;return g|0}function dd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;e=c[a+16>>2]|0;if((c[e+68>>2]|0)>>>0>=(c[e+64>>2]|0)>>>0){e1(a)}e=c[a+20>>2]|0;if((e|0)==(c[a+40>>2]|0)){f=c[a+72>>2]|0}else{f=c[(c[c[e+4>>2]>>2]|0)+12>>2]|0}e=eO(a,d,f)|0;c[e+16>>2]=b;b=a+8|0;a=(c[b>>2]|0)+(-d<<4)|0;c[b>>2]=a;if((d|0)==0){g=a;h=e;i=g;c[i>>2]=h;j=g+8|0;c[j>>2]=6;k=c[b>>2]|0;l=k+16|0;c[b>>2]=l;return}else{m=d;n=a}while(1){a=m-1|0;d=n+(a<<4)|0;f=e+24+(a<<4)|0;o=c[d+4>>2]|0;c[f>>2]=c[d>>2];c[f+4>>2]=o;c[e+24+(a<<4)+8>>2]=c[n+(a<<4)+8>>2];o=c[b>>2]|0;if((a|0)==0){g=o;break}else{m=a;n=o}}h=e;i=g;c[i>>2]=h;j=g+8|0;c[j>>2]=6;k=c[b>>2]|0;l=k+16|0;c[b>>2]=l;return}function de(a,b){a=a|0;b=b|0;var e=0,f=0,g=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=(c[a+8>>2]|0)-16|0;gm(a,f,b,b);return}function df(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;f=i;i=i+16|0;g=f|0;do{if((b|0)>0){h=(c[a+12>>2]|0)+(b-1<<4)|0;j=h>>>0<(c[a+8>>2]|0)>>>0?h:1032}else{if((b|0)>-1e4){j=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){j=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){h=a+88|0;c[h>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;j=h;break}else if((b|0)==(-10002|0)){j=a+72|0;break}else{h=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;k=-10002-b|0;if((k|0)>(d[h+7|0]|0|0)){j=1032;break}j=h+24+(k-1<<4)|0;break}}}while(0);c[g>>2]=f_(a,e,j_(e|0)|0)|0;c[g+8>>2]=4;e=a+8|0;gm(a,j,g,c[e>>2]|0);c[e>>2]=(c[e>>2]|0)+16;i=f;return}function dg(a,b){a=a|0;b=b|0;var e=0,f=0,g=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=a+8|0;a=f8(c[f>>2]|0,(c[b>>2]|0)-16|0)|0;f=c[b>>2]|0;b=a;g=f-16|0;e=c[b+4>>2]|0;c[g>>2]=c[b>>2];c[g+4>>2]=e;c[f-16+8>>2]=c[a+8>>2];return}function dh(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0;do{if((b|0)>0){f=(c[a+12>>2]|0)+(b-1<<4)|0;g=f>>>0<(c[a+8>>2]|0)>>>0?f:1032}else{if((b|0)>-1e4){g=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){g=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){f=a+88|0;c[f>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;g=f;break}else if((b|0)==(-10002|0)){g=a+72|0;break}else{f=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;h=-10002-b|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);b=f3(c[g>>2]|0,e)|0;e=a+8|0;a=c[e>>2]|0;g=b;h=a;f=c[g+4>>2]|0;c[h>>2]=c[g>>2];c[h+4>>2]=f;c[a+8>>2]=c[b+8>>2];c[e>>2]=(c[e>>2]|0)+16;return}function di(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=c[a+16>>2]|0;if((c[e+68>>2]|0)>>>0>=(c[e+64>>2]|0)>>>0){e1(a)}e=a+8|0;f=c[e>>2]|0;c[f>>2]=f5(a,b,d)|0;c[f+8>>2]=5;c[e>>2]=(c[e>>2]|0)+16;return}function dj(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=c[f+8>>2]|0;if((b|0)==5){h=c[(c[f>>2]|0)+8>>2]|0}else if((b|0)==7){h=c[(c[f>>2]|0)+8>>2]|0}else{h=c[(c[a+16>>2]|0)+152+(b<<2)>>2]|0}if((h|0)==0){i=0;return i|0}b=a+8|0;a=c[b>>2]|0;c[a>>2]=h;c[a+8>>2]=5;c[b>>2]=(c[b>>2]|0)+16;i=1;return i|0}function dk(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=c[f+8>>2]|0;if((b|0)==6){g=c[a+8>>2]|0;c[g>>2]=c[(c[f>>2]|0)+12>>2];c[g+8>>2]=5;h=a+8|0;i=c[h>>2]|0;j=i+16|0;c[h>>2]=j;return}else if((b|0)==7){g=c[a+8>>2]|0;c[g>>2]=c[(c[f>>2]|0)+12>>2];c[g+8>>2]=5;h=a+8|0;i=c[h>>2]|0;j=i+16|0;c[h>>2]=j;return}else if((b|0)==8){b=c[f>>2]|0;f=c[a+8>>2]|0;g=b+72|0;e=f;k=c[g+4>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=k;c[f+8>>2]=c[b+80>>2];h=a+8|0;i=c[h>>2]|0;j=i+16|0;c[h>>2]=j;return}else{c[(c[a+8>>2]|0)+8>>2]=0;h=a+8|0;i=c[h>>2]|0;j=i+16|0;c[h>>2]=j;return}}function dl(a,b){a=a|0;b=b|0;var e=0,f=0,g=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else if((b|0)==(-10002|0)){f=a+72|0;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=a+8|0;g=c[b>>2]|0;gn(a,f,g-32|0,g-16|0);c[b>>2]=(c[b>>2]|0)-32;return}function dm(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;f=i;i=i+16|0;g=f|0;do{if((b|0)>0){h=(c[a+12>>2]|0)+(b-1<<4)|0;j=h>>>0<(c[a+8>>2]|0)>>>0?h:1032}else{if((b|0)>-1e4){j=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10001|0)){h=a+88|0;c[h>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;j=h;break}else if((b|0)==(-1e4|0)){j=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10002|0)){j=a+72|0;break}else{h=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;k=-10002-b|0;if((k|0)>(d[h+7|0]|0|0)){j=1032;break}j=h+24+(k-1<<4)|0;break}}}while(0);c[g>>2]=f_(a,e,j_(e|0)|0)|0;c[g+8>>2]=4;e=a+8|0;gn(a,j,g,(c[e>>2]|0)-16|0);c[e>>2]=(c[e>>2]|0)-16;i=f;return}function dn(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;do{if((e|0)>0){f=(c[b+12>>2]|0)+(e-1<<4)|0;g=f>>>0<(c[b+8>>2]|0)>>>0?f:1032}else{if((e|0)>-1e4){g=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-1e4|0)){g=(c[b+16>>2]|0)+96|0;break}else if((e|0)==(-10001|0)){f=b+88|0;c[f>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;g=f;break}else if((e|0)==(-10002|0)){g=b+72|0;break}else{f=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);e=b+8|0;h=c[e>>2]|0;f=g;g=f9(b,c[f>>2]|0,h-32|0)|0;i=h-16|0;j=g;k=c[i+4>>2]|0;c[j>>2]=c[i>>2];c[j+4>>2]=k;c[g+8>>2]=c[h-16+8>>2];h=c[e>>2]|0;if((c[h-16+8>>2]|0)<=3){l=h;m=l-32|0;c[e>>2]=m;return}if((a[(c[h-16>>2]|0)+5|0]&3)==0){l=h;m=l-32|0;c[e>>2]=m;return}g=c[f>>2]|0;if((a[g+5|0]&4)==0){l=h;m=l-32|0;c[e>>2]=m;return}e2(b,g);l=c[e>>2]|0;m=l-32|0;c[e>>2]=m;return}function dp(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;do{if((e|0)>0){g=(c[b+12>>2]|0)+(e-1<<4)|0;h=g>>>0<(c[b+8>>2]|0)>>>0?g:1032}else{if((e|0)>-1e4){h=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10001|0)){g=b+88|0;c[g>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;h=g;break}else if((e|0)==(-10002|0)){h=b+72|0;break}else if((e|0)==(-1e4|0)){h=(c[b+16>>2]|0)+96|0;break}else{g=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;i=-10002-e|0;if((i|0)>(d[g+7|0]|0|0)){h=1032;break}h=g+24+(i-1<<4)|0;break}}}while(0);e=b+8|0;i=c[e>>2]|0;g=h;h=gc(b,c[g>>2]|0,f)|0;f=i-16|0;j=h;k=c[f+4>>2]|0;c[j>>2]=c[f>>2];c[j+4>>2]=k;c[h+8>>2]=c[i-16+8>>2];i=c[e>>2]|0;if((c[i-16+8>>2]|0)<=3){l=i;m=l-16|0;c[e>>2]=m;return}if((a[(c[i-16>>2]|0)+5|0]&3)==0){l=i;m=l-16|0;c[e>>2]=m;return}h=c[g>>2]|0;if((a[h+5|0]&4)==0){l=i;m=l-16|0;c[e>>2]=m;return}e2(b,h);l=c[e>>2]|0;m=l-16|0;c[e>>2]=m;return}function dq(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;do{if((e|0)>0){f=(c[b+12>>2]|0)+(e-1<<4)|0;g=f>>>0<(c[b+8>>2]|0)>>>0?f:1032}else{if((e|0)>-1e4){g=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10001|0)){f=b+88|0;c[f>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;g=f;break}else if((e|0)==(-1e4|0)){g=(c[b+16>>2]|0)+96|0;break}else if((e|0)==(-10002|0)){g=b+72|0;break}else{f=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);e=b+8|0;h=c[e>>2]|0;if((c[h-16+8>>2]|0)==0){i=0}else{i=c[h-16>>2]|0}h=c[g+8>>2]|0;do{if((h|0)==5){f=g;c[(c[f>>2]|0)+8>>2]=i;if((i|0)==0){break}if((a[i+5|0]&3)==0){break}j=c[f>>2]|0;if((a[j+5|0]&4)==0){break}e2(b,j)}else if((h|0)==7){j=g;c[(c[j>>2]|0)+8>>2]=i;if((i|0)==0){break}if((a[i+5|0]&3)==0){break}f=c[j>>2]|0;if((a[f+5|0]&4)==0){break}e7(b,f,i)}else{c[(c[b+16>>2]|0)+152+(h<<2)>>2]=i}}while(0);c[e>>2]=(c[e>>2]|0)-16;return 1}function dr(a){a=a|0;return d[a+6|0]|0|0}function ds(a,b){a=a|0;b=b|0;var d=0;d=a+16|0;if((b|0)!=0){c[b>>2]=c[(c[d>>2]|0)+16>>2]}return c[(c[d>>2]|0)+12>>2]|0}function dt(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=a+16|0;c[(c[e>>2]|0)+16>>2]=d;c[(c[e>>2]|0)+12>>2]=b;return}function du(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0;do{if((e|0)>0){g=(c[b+12>>2]|0)+(e-1<<4)|0;h=g>>>0<(c[b+8>>2]|0)>>>0?g:1032}else{if((e|0)>-1e4){h=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10002|0)){h=b+72|0;break}else if((e|0)==(-10001|0)){g=b+88|0;c[g>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;h=g;break}else if((e|0)==(-1e4|0)){h=(c[b+16>>2]|0)+96|0;break}else{g=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;i=-10002-e|0;if((i|0)>(d[g+7|0]|0)){h=1032;break}h=g+24+(i-1<<4)|0;break}}}while(0);if((c[h+8>>2]|0)!=6){j=0;return j|0}e=c[h>>2]|0;h=e;do{if((a[e+6|0]|0)==0){i=c[e+16>>2]|0;if((f|0)<=0){j=0;return j|0}if((c[i+36>>2]|0)<(f|0)){j=0;return j|0}g=f-1|0;k=(c[(c[i+28>>2]|0)+(g<<2)>>2]|0)+16|0;if((k|0)==0){j=0;return j|0}else{l=c[(c[e+20+(g<<2)>>2]|0)+8>>2]|0;m=k;break}}else{if((f|0)<=0){j=0;return j|0}if((d[h+7|0]|0)<(f|0)){j=0;return j|0}else{l=e+24+(f-1<<4)|0;m=10544;break}}}while(0);f=b+8|0;b=c[f>>2]|0;e=l;h=b;k=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=k;c[b+8>>2]=c[l+8>>2];c[f>>2]=(c[f>>2]|0)+16;j=m;return j|0}function dv(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0;do{if((e|0)>0){f=(c[b+12>>2]|0)+(e-1<<4)|0;g=f>>>0<(c[b+8>>2]|0)>>>0?f:1032}else{if((e|0)>-1e4){g=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10002|0)){g=b+72|0;break}else if((e|0)==(-10001|0)){f=b+88|0;c[f>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;g=f;break}else if((e|0)==(-1e4|0)){g=(c[b+16>>2]|0)+96|0;break}else{f=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;h=-10002-e|0;if((h|0)>(d[f+7|0]|0|0)){g=1032;break}g=f+24+(h-1<<4)|0;break}}}while(0);e=c[g+8>>2]|0;if((e|0)==7){c[(c[g>>2]|0)+12>>2]=c[(c[b+8>>2]|0)-16>>2]}else if((e|0)==6){c[(c[g>>2]|0)+12>>2]=c[(c[b+8>>2]|0)-16>>2]}else if((e|0)==8){e=c[g>>2]|0;c[e+72>>2]=c[(c[b+8>>2]|0)-16>>2];c[e+80>>2]=5}else{i=0;j=b+8|0;k=c[j>>2]|0;l=k-16|0;c[j>>2]=l;return i|0}e=b+8|0;h=c[(c[e>>2]|0)-16>>2]|0;if((a[h+5|0]&3)==0){i=1;j=e;k=c[j>>2]|0;l=k-16|0;c[j>>2]=l;return i|0}f=c[g>>2]|0;if((a[f+5|0]&4)==0){i=1;j=e;k=c[j>>2]|0;l=k-16|0;c[j>>2]=l;return i|0}e7(b,f,h);i=1;j=e;k=c[j>>2]|0;l=k-16|0;c[j>>2]=l;return i|0}function dw(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=a+8|0;eG(a,(c[e>>2]|0)+(~b<<4)|0,d);if((d|0)!=-1){return}d=c[e>>2]|0;e=(c[a+20>>2]|0)+8|0;if(d>>>0<(c[e>>2]|0)>>>0){return}c[e>>2]=d;return}function dx(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0;g=i;i=i+8|0;h=g|0;if((f|0)==0){j=0;k=c[a+32>>2]|0}else{do{if((f|0)>0){l=(c[a+12>>2]|0)+(f-1<<4)|0;m=l>>>0<(c[a+8>>2]|0)>>>0?l:1032}else{if((f|0)>-1e4){m=(c[a+8>>2]|0)+(f<<4)|0;break}if((f|0)==(-1e4|0)){m=(c[a+16>>2]|0)+96|0;break}else if((f|0)==(-10002|0)){m=a+72|0;break}else if((f|0)==(-10001|0)){l=a+88|0;c[l>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;m=l;break}else{l=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;n=-10002-f|0;if((n|0)>(d[l+7|0]|0|0)){m=1032;break}m=l+24+(n-1<<4)|0;break}}}while(0);f=c[a+32>>2]|0;j=m-f|0;k=f}f=a+8|0;m=(c[f>>2]|0)+(~b<<4)|0;c[h>>2]=m;c[h+4>>2]=e;b=eJ(a,252,h,m-k|0,j)|0;if((e|0)!=-1){i=g;return b|0}e=c[f>>2]|0;f=(c[a+20>>2]|0)+8|0;if(e>>>0<(c[f>>2]|0)>>>0){i=g;return b|0}c[f>>2]=e;i=g;return b|0}function dy(a,b){a=a|0;b=b|0;eG(a,c[b>>2]|0,c[b+4>>2]|0);return}function dz(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=i;i=i+8|0;f=e|0;c[f>>2]=b;c[f+4>>2]=d;d=eJ(a,264,f,(c[a+8>>2]|0)-(c[a+32>>2]|0)|0,0)|0;i=e;return d|0}function dA(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=c[a+20>>2]|0;if((d|0)==(c[a+40>>2]|0)){e=c[a+72>>2]|0}else{e=c[(c[c[d+4>>2]>>2]|0)+12>>2]|0}d=eO(a,0,e)|0;c[d+16>>2]=c[b>>2];e=a+8|0;f=c[e>>2]|0;c[f>>2]=d;c[f+8>>2]=6;f=c[e>>2]|0;d=f+16|0;c[e>>2]=d;c[d>>2]=c[b+4>>2];c[f+24>>2]=2;f=c[e>>2]|0;c[e>>2]=f+16;eG(a,f-16|0,0);return}function dB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0,f=0;e=i;i=i+24|0;f=e|0;gs(a,f,b,c);c=eK(a,f,(d|0)==0?8488:d)|0;i=e;return c|0}function dC(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=c[b+8>>2]|0;if((c[f-16+8>>2]|0)!=6){g=1;return g|0}h=c[f-16>>2]|0;if((a[h+6|0]|0)!=0){g=1;return g|0}g=eM(b,c[h+16>>2]|0,d,e,0)|0;return g|0}function dD(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=c[b+16>>2]|0;L931:do{switch(d|0){case 0:{c[f+64>>2]=-3;g=0;break};case 1:{c[f+64>>2]=c[f+68>>2];g=0;break};case 5:{h=e<<10;i=f+68|0;j=c[i>>2]|0;if(h>>>0>j>>>0){c[f+64>>2]=0;k=0}else{l=j-h|0;c[f+64>>2]=l;k=l}l=f+64|0;h=f+21|0;m=k;n=j;while(1){if(m>>>0>n>>>0){g=0;break L931}e1(b);if((a[h]|0)==0){g=1;break L931}m=c[l>>2]|0;n=c[i>>2]|0}break};case 2:{e5(b);g=0;break};case 6:{i=f+80|0;n=c[i>>2]|0;c[i>>2]=e;g=n;break};case 7:{n=f+84|0;i=c[n>>2]|0;c[n>>2]=e;g=i;break};case 4:{g=c[f+68>>2]&1023;break};case 3:{g=(c[f+68>>2]|0)>>>10;break};default:{g=-1}}}while(0);return g|0}function dE(a){a=a|0;ew(a);return 0}function dF(a,b){a=a|0;b=b|0;var e=0,f=0,g=0;do{if((b|0)>0){e=(c[a+12>>2]|0)+(b-1<<4)|0;f=e>>>0<(c[a+8>>2]|0)>>>0?e:1032}else{if((b|0)>-1e4){f=(c[a+8>>2]|0)+(b<<4)|0;break}if((b|0)==(-10002|0)){f=a+72|0;break}else if((b|0)==(-1e4|0)){f=(c[a+16>>2]|0)+96|0;break}else if((b|0)==(-10001|0)){e=a+88|0;c[e>>2]=c[(c[c[(c[a+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[a+96>>2]=5;f=e;break}else{e=c[c[(c[a+20>>2]|0)+4>>2]>>2]|0;g=-10002-b|0;if((g|0)>(d[e+7|0]|0|0)){f=1032;break}f=e+24+(g-1<<4)|0;break}}}while(0);b=a+8|0;g=f0(a,c[f>>2]|0,(c[b>>2]|0)-16|0)|0;f=c[b>>2]|0;c[b>>2]=(g|0)==0?f-16|0:f+16|0;return g|0}function dG(a,b){a=a|0;b=b|0;var d=0;if((b|0)>1){d=c[a+16>>2]|0;if((c[d+68>>2]|0)>>>0>=(c[d+64>>2]|0)>>>0){e1(a)}d=a+8|0;gq(a,b,((c[d>>2]|0)-(c[a+12>>2]|0)>>4)-1|0);c[d>>2]=(c[d>>2]|0)+(1-b<<4);return}else{if((b|0)!=0){return}b=a+8|0;d=c[b>>2]|0;c[d>>2]=f_(a,10544,0)|0;c[d+8>>2]=4;c[b>>2]=(c[b>>2]|0)+16;return}}function dH(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+16>>2]|0;if((c[d+68>>2]|0)>>>0>=(c[d+64>>2]|0)>>>0){e1(a)}d=c[a+20>>2]|0;if((d|0)==(c[a+40>>2]|0)){e=c[a+72>>2]|0}else{e=c[(c[c[d+4>>2]>>2]|0)+12>>2]|0}d=f$(a,b,e)|0;e=a+8|0;a=c[e>>2]|0;c[a>>2]=d;c[a+8>>2]=7;c[e>>2]=(c[e>>2]|0)+16;return d+24|0}function dI(a){a=a|0;var b=0;b=c[a+24>>2]|0;c[a+28>>2]=b;return b|0}function dJ(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;do{if((e|0)>0){g=(c[b+12>>2]|0)+(e-1<<4)|0;h=g>>>0<(c[b+8>>2]|0)>>>0?g:1032}else{if((e|0)>-1e4){h=(c[b+8>>2]|0)+(e<<4)|0;break}if((e|0)==(-10002|0)){h=b+72|0;break}else if((e|0)==(-10001|0)){g=b+88|0;c[g>>2]=c[(c[c[(c[b+20>>2]|0)+4>>2]>>2]|0)+12>>2];c[b+96>>2]=5;h=g;break}else if((e|0)==(-1e4|0)){h=(c[b+16>>2]|0)+96|0;break}else{g=c[c[(c[b+20>>2]|0)+4>>2]>>2]|0;i=-10002-e|0;if((i|0)>(d[g+7|0]|0)){h=1032;break}h=g+24+(i-1<<4)|0;break}}}while(0);if((c[h+8>>2]|0)!=6){j=0;return j|0}e=h;h=c[e>>2]|0;i=h;do{if((a[h+6|0]|0)==0){g=c[h+16>>2]|0;if((f|0)<=0){j=0;return j|0}if((c[g+36>>2]|0)<(f|0)){j=0;return j|0}k=f-1|0;l=(c[(c[g+28>>2]|0)+(k<<2)>>2]|0)+16|0;if((l|0)==0){j=0;return j|0}else{m=c[(c[h+20+(k<<2)>>2]|0)+8>>2]|0;n=l;break}}else{if((f|0)<=0){j=0;return j|0}if((d[i+7|0]|0)<(f|0)){j=0;return j|0}else{m=h+24+(f-1<<4)|0;n=10544;break}}}while(0);f=b+8|0;h=c[f>>2]|0;i=h-16|0;c[f>>2]=i;l=i;i=m;k=c[l+4>>2]|0;c[i>>2]=c[l>>2];c[i+4>>2]=k;c[m+8>>2]=c[h-16+8>>2];h=c[f>>2]|0;if((c[h+8>>2]|0)<=3){j=n;return j|0}f=c[h>>2]|0;if((a[f+5|0]&3)==0){j=n;return j|0}h=c[e>>2]|0;if((a[h+5|0]&4)==0){j=n;return j|0}e7(b,h,f);j=n;return j|0}function dK(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;f=c[a+24>>2]|0;do{if((f|0)>(c[a+28>>2]|0)){if((f|0)==0){if((d[a+50|0]|0|0)>(b|0)){break}return}g=(c[(c[a>>2]|0)+12>>2]|0)+(f-1<<2)|0;h=c[g>>2]|0;if((h&63|0)!=3){break}i=h>>>23;if((h>>>6&255|0)>(b|0)){break}if((i+1|0)<(b|0)){break}j=b-1+e|0;if((j|0)<=(i|0)){return}c[g>>2]=h&8388607|j<<23;return}}while(0);ec(a,b<<6|(e+b<<23)-8388608|3,c[(c[a+12>>2]|0)+8>>2]|0)|0;return}function dL(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;return ec(a,d<<6|b|e<<23|f<<14,c[(c[a+12>>2]|0)+8>>2]|0)|0}function dM(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;b=a+32|0;d=c[b>>2]|0;c[b>>2]=-1;b=a+12|0;e=ec(a,2147450902,c[(c[b>>2]|0)+8>>2]|0)|0;if((d|0)==-1){f=e;return f|0}if((e|0)==-1){f=d;return f|0}g=c[(c[a>>2]|0)+12>>2]|0;a=e;while(1){h=g+(a<<2)|0;i=c[h>>2]|0;j=(i>>>14)-131071|0;if((j|0)==-1){break}k=a+1+j|0;if((k|0)==-1){break}else{a=k}}g=d+~a|0;if((((g|0)>-1?g:-g|0)|0)>131071){ff(c[b>>2]|0,5464);l=c[h>>2]|0}else{l=i}c[h>>2]=l&16383|(g<<14)+2147467264;f=e;return f|0}function dN(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;return ec(a,d<<6|b|e<<14,c[(c[a+12>>2]|0)+8>>2]|0)|0}function dO(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if((d|0)==-1){return}e=c[b>>2]|0;if((e|0)==-1){c[b>>2]=d;return}b=c[(c[a>>2]|0)+12>>2]|0;f=e;while(1){g=b+(f<<2)|0;h=c[g>>2]|0;e=(h>>>14)-131071|0;if((e|0)==-1){break}i=f+1+e|0;if((i|0)==-1){break}else{f=i}}b=~f+d|0;if((((b|0)>-1?b:-b|0)|0)>131071){ff(c[a+12>>2]|0,5464);j=c[g>>2]|0}else{j=h}c[g>>2]=j&16383|(b<<14)+2147467264;return}function dP(a,b,d){a=a|0;b=b|0;d=d|0;ec(a,b<<6|(d<<23)+8388608|30,c[(c[a+12>>2]|0)+8>>2]|0)|0;return}function dQ(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;if((c[b+24>>2]|0)==(e|0)){c[b+28>>2]=e;f=b+32|0;if((d|0)==-1){return}g=c[f>>2]|0;if((g|0)==-1){c[f>>2]=d;return}f=c[(c[b>>2]|0)+12>>2]|0;h=g;while(1){i=f+(h<<2)|0;j=c[i>>2]|0;g=(j>>>14)-131071|0;if((g|0)==-1){break}k=h+1+g|0;if((k|0)==-1){break}else{h=k}}f=~h+d|0;if((((f|0)>-1?f:-f|0)|0)>131071){ff(c[b+12>>2]|0,5464);l=c[i>>2]|0}else{l=j}c[i>>2]=l&16383|(f<<14)+2147467264;return}if((d|0)==-1){return}f=b|0;l=b+12|0;b=d;while(1){d=c[(c[f>>2]|0)+12>>2]|0;i=d+(b<<2)|0;j=c[i>>2]|0;h=(j>>>14)-131071|0;if((h|0)==-1){m=-1}else{m=b+1+h|0}if((b|0)>0){h=d+(b-1<<2)|0;d=c[h>>2]|0;if((a[992+(d&63)|0]|0)<0){n=h;o=d}else{p=890}}else{p=890}if((p|0)==890){p=0;n=i;o=j}if((o&63|0)==27){c[n>>2]=o&8372224|o>>>23<<6|26;d=(c[(c[f>>2]|0)+12>>2]|0)+(b<<2)|0;h=~b+e|0;if((((h|0)>-1?h:-h|0)|0)>131071){ff(c[l>>2]|0,5464)}c[d>>2]=c[d>>2]&16383|(h<<14)+2147467264}else{h=~b+e|0;if((((h|0)>-1?h:-h|0)|0)>131071){ff(c[l>>2]|0,5464);q=c[i>>2]|0}else{q=j}c[i>>2]=q&16383|(h<<14)+2147467264}if((m|0)==-1){break}else{b=m}}return}function dR(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0;c[a+28>>2]=c[a+24>>2];d=a+32|0;if((b|0)==-1){return}e=c[d>>2]|0;if((e|0)==-1){c[d>>2]=b;return}d=c[(c[a>>2]|0)+12>>2]|0;f=e;while(1){g=d+(f<<2)|0;h=c[g>>2]|0;e=(h>>>14)-131071|0;if((e|0)==-1){break}i=f+1+e|0;if((i|0)==-1){break}else{f=i}}d=~f+b|0;if((((d|0)>-1?d:-d|0)|0)>131071){ff(c[a+12>>2]|0,5464);j=c[g>>2]|0}else{j=h}c[g>>2]=j&16383|(d<<14)+2147467264;return}function dS(b,e){b=b|0;e=e|0;var f=0,g=0,h=0;f=(c[b+36>>2]|0)+e|0;e=b|0;g=c[e>>2]|0;if((f|0)<=(d[g+75|0]|0|0)){return}if((f|0)>249){ff(c[b+12>>2]|0,5128);h=c[e>>2]|0}else{h=g}a[h+75|0]=f&255;return}function dT(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;f=b+36|0;g=c[f>>2]|0;h=g+e|0;i=b|0;j=c[i>>2]|0;if((h|0)<=(d[j+75|0]|0|0)){k=g;l=k+e|0;c[f>>2]=l;return}if((h|0)>249){ff(c[b+12>>2]|0,5128);m=c[i>>2]|0}else{m=j}a[m+75|0]=h&255;k=c[f>>2]|0;l=k+e|0;c[f>>2]=l;return}function dU(a,b){a=a|0;b=b|0;var d=0,e=0;d=i;i=i+16|0;e=d|0;c[e>>2]=b;c[e+8>>2]=4;b=dV(a,e,e)|0;i=d;return b|0}function dV(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0;f=c[b+16>>2]|0;g=f9(f,c[b+4>>2]|0,d)|0;d=c[b>>2]|0;i=d+40|0;j=c[i>>2]|0;k=g+8|0;if((c[k>>2]|0)==3){l=~~+h[g>>3];return l|0}m=b+40|0;h[g>>3]=+(c[m>>2]|0);c[k>>2]=3;k=c[i>>2]|0;if(((c[m>>2]|0)+1|0)>(k|0)){g=d+8|0;c[g>>2]=ft(f,c[g>>2]|0,i,16,262143,7128)|0;n=c[i>>2]|0}else{n=k}k=d+8|0;if((j|0)<(n|0)){n=j;while(1){j=n+1|0;c[(c[k>>2]|0)+(n<<4)+8>>2]=0;if((j|0)<(c[i>>2]|0)){n=j}else{break}}}n=c[m>>2]|0;i=c[k>>2]|0;k=e;j=i+(n<<4)|0;g=c[k+4>>2]|0;c[j>>2]=c[k>>2];c[j+4>>2]=g;g=e+8|0;c[i+(n<<4)+8>>2]=c[g>>2];do{if((c[g>>2]|0)>3){n=c[e>>2]|0;if((a[n+5|0]&3)==0){break}if((a[d+5|0]&4)==0){break}e7(f,d,n)}}while(0);d=c[m>>2]|0;c[m>>2]=d+1;l=d;return l|0}function dW(a,b){a=a|0;b=+b;var d=0,e=0,f=0;d=i;i=i+16|0;e=d|0;h[e>>3]=b;c[e+8>>2]=3;f=dV(a,e,e)|0;i=d;return f|0}function dX(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0;g=c[e>>2]|0;if((g|0)==13){h=(c[(c[b>>2]|0)+12>>2]|0)+(c[e+8>>2]<<2)|0;c[h>>2]=c[h>>2]&-8372225|(f<<14)+16384&8372224;return}else if((g|0)==14){g=e+8|0;e=b|0;h=(c[(c[e>>2]|0)+12>>2]|0)+(c[g>>2]<<2)|0;c[h>>2]=c[h>>2]&8388607|(f<<23)+8388608;f=(c[(c[e>>2]|0)+12>>2]|0)+(c[g>>2]<<2)|0;g=b+36|0;c[f>>2]=c[g>>2]<<6&16320|c[f>>2]&-16321;f=c[g>>2]|0;h=f+1|0;i=c[e>>2]|0;if((h|0)>(d[i+75|0]|0|0)){if((h|0)>249){ff(c[b+12>>2]|0,5128);j=c[e>>2]|0}else{j=i}a[j+75|0]=h&255;k=c[g>>2]|0}else{k=f}c[g>>2]=k+1;return}else{return}}function dY(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=b|0;e=c[d>>2]|0;if((e|0)==13){c[d>>2]=12;f=b+8|0;c[f>>2]=(c[(c[(c[a>>2]|0)+12>>2]|0)+(c[f>>2]<<2)>>2]|0)>>>6&255;return}else if((e|0)==14){e=(c[(c[a>>2]|0)+12>>2]|0)+(c[b+8>>2]<<2)|0;c[e>>2]=c[e>>2]&8388607|16777216;c[d>>2]=11;return}else{return}}function dZ(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=b|0;switch(c[e>>2]|0){case 6:{c[e>>2]=12;return};case 8:{f=b+8|0;c[f>>2]=ec(a,c[f>>2]<<14|5,c[(c[a+12>>2]|0)+8>>2]|0)|0;c[e>>2]=11;return};case 14:{f=(c[(c[a>>2]|0)+12>>2]|0)+(c[b+8>>2]<<2)|0;c[f>>2]=c[f>>2]&8388607|16777216;c[e>>2]=11;return};case 7:{f=b+8|0;c[f>>2]=ec(a,c[f>>2]<<23|4,c[(c[a+12>>2]|0)+8>>2]|0)|0;c[e>>2]=11;return};case 9:{f=b+8|0;g=f+4|0;h=c[g>>2]|0;do{if((h&256|0)==0){if((d[a+50|0]|0|0)>(h|0)){break}i=a+36|0;c[i>>2]=(c[i>>2]|0)-1}}while(0);h=f;f=c[h>>2]|0;do{if((f&256|0)==0){if((d[a+50|0]|0|0)>(f|0)){j=f;break}i=a+36|0;c[i>>2]=(c[i>>2]|0)-1;j=c[h>>2]|0}else{j=f}}while(0);c[h>>2]=ec(a,j<<23|c[g>>2]<<14|6,c[(c[a+12>>2]|0)+8>>2]|0)|0;c[e>>2]=11;return};case 13:{c[e>>2]=12;e=b+8|0;c[e>>2]=(c[(c[(c[a>>2]|0)+12>>2]|0)+(c[e>>2]<<2)>>2]|0)>>>6&255;return};default:{return}}}function d_(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;dZ(b,e);do{if((c[e>>2]|0)==12){f=c[e+8>>2]|0;if((f&256|0)!=0){break}if((d[b+50|0]|0|0)>(f|0)){break}f=b+36|0;c[f>>2]=(c[f>>2]|0)-1}}while(0);f=b+36|0;g=c[f>>2]|0;h=g+1|0;i=b|0;j=c[i>>2]|0;if((h|0)<=(d[j+75|0]|0|0)){k=g;l=k+1|0;c[f>>2]=l;d$(b,e,k);return}if((h|0)>249){ff(c[b+12>>2]|0,5128);m=c[i>>2]|0}else{m=j}a[m+75|0]=h&255;k=c[f>>2]|0;l=k+1|0;c[f>>2]=l;d$(b,e,k);return}function d$(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0;ek(b,d,e);f=d|0;g=d+16|0;do{if((c[f>>2]|0)==10){h=c[d+8>>2]|0;if((h|0)==-1){break}i=c[g>>2]|0;if((i|0)==-1){c[g>>2]=h;break}j=c[(c[b>>2]|0)+12>>2]|0;k=i;while(1){l=j+(k<<2)|0;m=c[l>>2]|0;i=(m>>>14)-131071|0;if((i|0)==-1){break}n=k+1+i|0;if((n|0)==-1){break}else{k=n}}j=h+~k|0;if((((j|0)>-1?j:-j|0)|0)>131071){ff(c[b+12>>2]|0,5464);o=c[l>>2]|0}else{o=m}c[l>>2]=o&16383|(j<<14)+2147467264}}while(0);o=c[g>>2]|0;l=d+20|0;m=c[l>>2]|0;if((o|0)==(m|0)){c[g>>2]=-1;c[l>>2]=-1;p=d+8|0;q=p;c[q>>2]=e;c[f>>2]=12;return}L1250:do{if((o|0)==-1){r=1017}else{j=c[(c[b>>2]|0)+12>>2]|0;n=o;while(1){i=j+(n<<2)|0;if((n|0)>0){s=c[j+(n-1<<2)>>2]|0;if((a[992+(s&63)|0]|0)<0){t=s}else{r=1013}}else{r=1013}if((r|0)==1013){r=0;t=c[i>>2]|0}if((t&63|0)!=27){r=1025;break L1250}s=((c[i>>2]|0)>>>14)-131071|0;if((s|0)==-1){r=1017;break L1250}i=n+1+s|0;if((i|0)==-1){r=1017;break}else{n=i}}}}while(0);L1261:do{if((r|0)==1017){if((m|0)==-1){u=-1;v=-1;break}t=c[(c[b>>2]|0)+12>>2]|0;o=m;while(1){n=t+(o<<2)|0;if((o|0)>0){j=c[t+(o-1<<2)>>2]|0;if((a[992+(j&63)|0]|0)<0){w=j}else{r=1021}}else{r=1021}if((r|0)==1021){r=0;w=c[n>>2]|0}if((w&63|0)!=27){r=1025;break L1261}j=((c[n>>2]|0)>>>14)-131071|0;if((j|0)==-1){u=-1;v=-1;break L1261}n=o+1+j|0;if((n|0)==-1){u=-1;v=-1;break}else{o=n}}}}while(0);do{if((r|0)==1025){do{if((c[f>>2]|0)==10){x=-1;y=b+12|0;z=b+32|0}else{w=b+32|0;m=c[w>>2]|0;c[w>>2]=-1;o=b+12|0;t=ec(b,2147450902,c[(c[o>>2]|0)+8>>2]|0)|0;if((m|0)==-1){x=t;y=o;z=w;break}if((t|0)==-1){x=m;y=o;z=w;break}n=c[(c[b>>2]|0)+12>>2]|0;j=t;while(1){A=n+(j<<2)|0;B=c[A>>2]|0;k=(B>>>14)-131071|0;if((k|0)==-1){break}h=j+1+k|0;if((h|0)==-1){break}else{j=h}}n=m+~j|0;if((((n|0)>-1?n:-n|0)|0)>131071){ff(c[o>>2]|0,5464);C=c[A>>2]|0}else{C=B}c[A>>2]=C&16383|(n<<14)+2147467264;x=t;y=o;z=w}}while(0);n=b+24|0;h=b+28|0;c[h>>2]=c[n>>2];k=e<<6;i=ec(b,k|16386,c[(c[y>>2]|0)+8>>2]|0)|0;c[h>>2]=c[n>>2];s=ec(b,k|8388610,c[(c[y>>2]|0)+8>>2]|0)|0;c[h>>2]=c[n>>2];if((x|0)==-1){u=i;v=s;break}n=c[z>>2]|0;if((n|0)==-1){c[z>>2]=x;u=i;v=s;break}h=c[(c[b>>2]|0)+12>>2]|0;k=n;while(1){D=h+(k<<2)|0;E=c[D>>2]|0;n=(E>>>14)-131071|0;if((n|0)==-1){break}F=k+1+n|0;if((F|0)==-1){break}else{k=F}}h=x+~k|0;if((((h|0)>-1?h:-h|0)|0)>131071){ff(c[y>>2]|0,5464);G=c[D>>2]|0}else{G=E}c[D>>2]=G&16383|(h<<14)+2147467264;u=i;v=s}}while(0);G=c[b+24>>2]|0;c[b+28>>2]=G;D=c[l>>2]|0;if((D|0)!=-1){E=b|0;y=(e|0)==255;x=b+12|0;z=e<<6&16320;C=D;while(1){D=c[(c[E>>2]|0)+12>>2]|0;A=D+(C<<2)|0;B=c[A>>2]|0;h=(B>>>14)-131071|0;if((h|0)==-1){H=-1}else{H=C+1+h|0}if((C|0)>0){h=D+(C-1<<2)|0;D=c[h>>2]|0;if((a[992+(D&63)|0]|0)<0){I=h;J=D}else{r=1050}}else{r=1050}if((r|0)==1050){r=0;I=A;J=B}if((J&63|0)==27){D=J>>>23;if(y|(D|0)==(e|0)){K=J&8372224|D<<6|26}else{K=J&-16321|z}c[I>>2]=K;D=(c[(c[E>>2]|0)+12>>2]|0)+(C<<2)|0;h=G+~C|0;if((((h|0)>-1?h:-h|0)|0)>131071){ff(c[x>>2]|0,5464)}c[D>>2]=c[D>>2]&16383|(h<<14)+2147467264}else{h=u+~C|0;if((((h|0)>-1?h:-h|0)|0)>131071){ff(c[x>>2]|0,5464);L=c[A>>2]|0}else{L=B}c[A>>2]=L&16383|(h<<14)+2147467264}if((H|0)==-1){break}else{C=H}}}H=c[g>>2]|0;if((H|0)==-1){c[g>>2]=-1;c[l>>2]=-1;p=d+8|0;q=p;c[q>>2]=e;c[f>>2]=12;return}C=b|0;L=b+12|0;b=e<<6;x=b&16320;if((e|0)==255){u=H;while(1){E=c[(c[C>>2]|0)+12>>2]|0;K=E+(u<<2)|0;I=c[K>>2]|0;z=(I>>>14)-131071|0;if((z|0)==-1){M=-1}else{M=u+1+z|0}if((u|0)>0){z=E+(u-1<<2)|0;E=c[z>>2]|0;if((a[992+(E&63)|0]|0)<0){N=z;O=E}else{r=1068}}else{r=1068}if((r|0)==1068){r=0;N=K;O=I}if((O&63|0)==27){c[N>>2]=O&8372224|O>>>23<<6|26;E=(c[(c[C>>2]|0)+12>>2]|0)+(u<<2)|0;z=G+~u|0;if((((z|0)>-1?z:-z|0)|0)>131071){ff(c[L>>2]|0,5464)}c[E>>2]=c[E>>2]&16383|(z<<14)+2147467264}else{z=v+~u|0;if((((z|0)>-1?z:-z|0)|0)>131071){ff(c[L>>2]|0,5464);P=c[K>>2]|0}else{P=I}c[K>>2]=P&16383|(z<<14)+2147467264}if((M|0)==-1){break}else{u=M}}c[g>>2]=-1;c[l>>2]=-1;p=d+8|0;q=p;c[q>>2]=e;c[f>>2]=12;return}else{Q=H}while(1){H=c[(c[C>>2]|0)+12>>2]|0;M=H+(Q<<2)|0;u=c[M>>2]|0;P=(u>>>14)-131071|0;if((P|0)==-1){R=-1}else{R=Q+1+P|0}if((Q|0)>0){P=H+(Q-1<<2)|0;H=c[P>>2]|0;if((a[992+(H&63)|0]|0)<0){S=P;T=H}else{r=1081}}else{r=1081}if((r|0)==1081){r=0;S=M;T=u}if((T&63|0)==27){if((T>>>23|0)==(e|0)){U=T&8372224|b|26}else{U=T&-16321|x}c[S>>2]=U;H=(c[(c[C>>2]|0)+12>>2]|0)+(Q<<2)|0;P=G+~Q|0;if((((P|0)>-1?P:-P|0)|0)>131071){ff(c[L>>2]|0,5464)}c[H>>2]=c[H>>2]&16383|(P<<14)+2147467264}else{P=v+~Q|0;if((((P|0)>-1?P:-P|0)|0)>131071){ff(c[L>>2]|0,5464);V=c[M>>2]|0}else{V=u}c[M>>2]=V&16383|(P<<14)+2147467264}if((R|0)==-1){break}else{Q=R}}c[g>>2]=-1;c[l>>2]=-1;p=d+8|0;q=p;c[q>>2]=e;c[f>>2]=12;return}function d0(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,h=0;dZ(a,b);do{if((c[b>>2]|0)==12){e=b+8|0;f=c[e>>2]|0;if((c[b+16>>2]|0)==(c[b+20>>2]|0)){g=f;return g|0}if((f|0)<(d[a+50|0]|0|0)){h=e;break}d$(a,b,f);g=c[e>>2]|0;return g|0}else{h=b+8|0}}while(0);d_(a,b);g=c[h>>2]|0;return g|0}function d1(a,b){a=a|0;b=b|0;var e=0,f=0,g=0;e=b+16|0;f=b+20|0;if((c[e>>2]|0)==(c[f>>2]|0)){dZ(a,b);return}dZ(a,b);do{if((c[b>>2]|0)==12){g=c[b+8>>2]|0;if((c[e>>2]|0)==(c[f>>2]|0)){return}if((g|0)<(d[a+50|0]|0|0)){break}d$(a,b,g);return}}while(0);d_(a,b);return}function d2(a,b){a=a|0;b=b|0;var e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;e=i;i=i+64|0;f=e|0;g=e+16|0;j=e+32|0;k=e+48|0;l=b+16|0;m=b+20|0;n=(c[l>>2]|0)==(c[m>>2]|0);dZ(a,b);o=b|0;L1403:do{if(!n){do{if((c[o>>2]|0)==12){p=c[b+8>>2]|0;if((c[l>>2]|0)==(c[m>>2]|0)){break L1403}if((p|0)<(d[a+50|0]|0|0)){break}d$(a,b,p);break L1403}}while(0);d_(a,b)}}while(0);n=c[o>>2]|0;L1411:do{switch(n|0){case 5:case 2:case 3:case 1:{if((c[a+40>>2]|0)>=256){break L1411}if((n|0)==5){h[g>>3]=+h[b+8>>3];c[g+8>>2]=3;q=dV(a,g,g)|0}else if((n|0)==1){c[k+8>>2]=0;c[j>>2]=c[a+4>>2];c[j+8>>2]=5;q=dV(a,j,k)|0}else{c[f>>2]=(n|0)==2;c[f+8>>2]=1;q=dV(a,f,f)|0}c[b+8>>2]=q;c[o>>2]=4;r=q|256;i=e;return r|0};case 4:{p=c[b+8>>2]|0;if((p|0)>=256){break L1411}r=p|256;i=e;return r|0};default:{}}}while(0);dZ(a,b);do{if((c[o>>2]|0)==12){q=b+8|0;f=c[q>>2]|0;if((c[l>>2]|0)==(c[m>>2]|0)){r=f;i=e;return r|0}if((f|0)<(d[a+50|0]|0|0)){s=q;break}d$(a,b,f);r=c[q>>2]|0;i=e;return r|0}else{s=b+8|0}}while(0);d_(a,b);r=c[s>>2]|0;i=e;return r|0}function d3(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;f=c[b>>2]|0;if((f|0)==6){do{if((c[e>>2]|0)==12){g=c[e+8>>2]|0;if((g&256|0)!=0){break}if((d[a+50|0]|0|0)>(g|0)){break}g=a+36|0;c[g>>2]=(c[g>>2]|0)-1}}while(0);d$(a,e,c[b+8>>2]|0);return}else if((f|0)==7){dZ(a,e);do{if((c[e>>2]|0)==12){g=e+8|0;h=c[g>>2]|0;if((c[e+16>>2]|0)==(c[e+20>>2]|0)){i=h;break}if((h|0)<(d[a+50|0]|0|0)){j=g;k=1158;break}d$(a,e,h);i=c[g>>2]|0}else{j=e+8|0;k=1158}}while(0);if((k|0)==1158){d_(a,e);i=c[j>>2]|0}ec(a,i<<6|c[b+8>>2]<<23|8,c[(c[a+12>>2]|0)+8>>2]|0)|0}else if((f|0)==9){i=d2(a,e)|0;j=b+8|0;ec(a,i<<14|c[j>>2]<<6|c[j+4>>2]<<23|9,c[(c[a+12>>2]|0)+8>>2]|0)|0}else if((f|0)==8){dZ(a,e);do{if((c[e>>2]|0)==12){f=e+8|0;j=c[f>>2]|0;if((c[e+16>>2]|0)==(c[e+20>>2]|0)){l=j;break}if((j|0)<(d[a+50|0]|0|0)){m=f;k=1165;break}d$(a,e,j);l=c[f>>2]|0}else{m=e+8|0;k=1165}}while(0);if((k|0)==1165){d_(a,e);l=c[m>>2]|0}ec(a,l<<6|c[b+8>>2]<<14|7,c[(c[a+12>>2]|0)+8>>2]|0)|0}if((c[e>>2]|0)!=12){return}b=c[e+8>>2]|0;if((b&256|0)!=0){return}if((d[a+50|0]|0|0)>(b|0)){return}b=a+36|0;c[b>>2]=(c[b>>2]|0)-1;return}function d4(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;dZ(b,e);g=e|0;do{if((c[g>>2]|0)==12){h=c[e+8>>2]|0;if((c[e+16>>2]|0)==(c[e+20>>2]|0)){break}if((h|0)<(d[b+50|0]|0|0)){i=1182;break}d$(b,e,h)}else{i=1182}}while(0);if((i|0)==1182){d_(b,e)}do{if((c[g>>2]|0)==12){i=c[e+8>>2]|0;if((i&256|0)!=0){break}if((d[b+50|0]|0|0)>(i|0)){break}i=b+36|0;c[i>>2]=(c[i>>2]|0)-1}}while(0);i=b+36|0;h=c[i>>2]|0;j=h+2|0;k=b|0;l=c[k>>2]|0;if((j|0)>(d[l+75|0]|0|0)){if((j|0)>249){ff(c[b+12>>2]|0,5128);m=c[k>>2]|0}else{m=l}a[m+75|0]=j&255;n=c[i>>2]|0}else{n=h}c[i>>2]=n+2;n=e+8|0;e=c[n>>2]|0;j=h<<6|e<<23|(d2(b,f)|0)<<14|11;ec(b,j,c[(c[b+12>>2]|0)+8>>2]|0)|0;if((c[f>>2]|0)!=12){c[n>>2]=h;c[g>>2]=12;return}j=c[f+8>>2]|0;if((j&256|0)!=0){c[n>>2]=h;c[g>>2]=12;return}if((d[b+50|0]|0|0)>(j|0)){c[n>>2]=h;c[g>>2]=12;return}c[i>>2]=(c[i>>2]|0)-1;c[n>>2]=h;c[g>>2]=12;return}function d5(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;dZ(b,e);f=e|0;g=c[f>>2]|0;L1503:do{if((g|0)==10){h=c[(c[b>>2]|0)+12>>2]|0;i=e+8|0;j=c[i>>2]|0;k=h+(j<<2)|0;if((j|0)>0){l=h+(j-1<<2)|0;j=c[l>>2]|0;if((a[992+(j&63)|0]|0)<0){m=l;n=j}else{o=1203}}else{o=1203}if((o|0)==1203){m=k;n=c[k>>2]|0}c[m>>2]=((n&16320|0)==0)<<6|n&-16321;p=c[i>>2]|0;o=1217}else if(!((g|0)==4|(g|0)==5|(g|0)==2)){i=e+8|0;do{if((g|0)==11){k=c[(c[(c[b>>2]|0)+12>>2]|0)+(c[i>>2]<<2)>>2]|0;if((k&63|0)!=19){o=1208;break}j=b+24|0;c[j>>2]=(c[j>>2]|0)-1;p=ee(b,26,k>>>23,0,1)|0;o=1217;break L1503}else if((g|0)==12){o=1213}else{o=1208}}while(0);if((o|0)==1208){k=b+36|0;j=c[k>>2]|0;l=j+1|0;h=b|0;q=c[h>>2]|0;if((l|0)>(d[q+75|0]|0)){if((l|0)>249){ff(c[b+12>>2]|0,5128);r=c[h>>2]|0}else{r=q}a[r+75|0]=l&255;s=c[k>>2]|0}else{s=j}c[k>>2]=s+1;ek(b,e,s);if((c[f>>2]|0)==12){o=1213}}do{if((o|0)==1213){k=c[i>>2]|0;if((k&256|0)!=0){break}if((d[b+50|0]|0)>(k|0)){break}k=b+36|0;c[k>>2]=(c[k>>2]|0)-1}}while(0);p=ee(b,27,255,c[i>>2]|0,0)|0;o=1217}}while(0);do{if((o|0)==1217){f=e+20|0;if((p|0)==-1){break}s=c[f>>2]|0;if((s|0)==-1){c[f>>2]=p;break}f=c[(c[b>>2]|0)+12>>2]|0;r=s;while(1){t=f+(r<<2)|0;u=c[t>>2]|0;s=(u>>>14)-131071|0;if((s|0)==-1){break}g=r+1+s|0;if((g|0)==-1){break}else{r=g}}f=p+~r|0;if((((f|0)>-1?f:-f|0)|0)>131071){ff(c[b+12>>2]|0,5464);v=c[t>>2]|0}else{v=u}c[t>>2]=v&16383|(f<<14)+2147467264}}while(0);v=e+16|0;e=c[v>>2]|0;c[b+28>>2]=c[b+24>>2];t=b+32|0;if((e|0)==-1){c[v>>2]=-1;return}u=c[t>>2]|0;if((u|0)==-1){c[t>>2]=e;c[v>>2]=-1;return}t=c[(c[b>>2]|0)+12>>2]|0;p=u;while(1){w=t+(p<<2)|0;x=c[w>>2]|0;u=(x>>>14)-131071|0;if((u|0)==-1){break}o=p+1+u|0;if((o|0)==-1){break}else{p=o}}t=e+~p|0;if((((t|0)>-1?t:-t|0)|0)>131071){ff(c[b+12>>2]|0,5464);y=c[w>>2]|0}else{y=x}c[w>>2]=y&16383|(t<<14)+2147467264;c[v>>2]=-1;return}function d6(a,b,d){a=a|0;b=b|0;d=d|0;c[b+12>>2]=d2(a,d)|0;c[b>>2]=9;return}function d7(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;g=i;i=i+24|0;j=g|0;c[j+20>>2]=-1;c[j+16>>2]=-1;c[j>>2]=5;h[j+8>>3]=0.0;if((e|0)==0){k=f|0;do{if((c[k>>2]|0)==5){if((c[f+16>>2]|0)!=-1){l=1244;break}if((c[f+20>>2]|0)!=-1){l=1244}}else{l=1244}}while(0);L1563:do{if((l|0)==1244){dZ(b,f);do{if((c[k>>2]|0)==12){m=c[f+8>>2]|0;if((c[f+16>>2]|0)==(c[f+20>>2]|0)){break L1563}if((m|0)<(d[b+50|0]|0)){break}d$(b,f,m);break L1563}}while(0);d_(b,f)}}while(0);d8(b,18,f,j);i=g;return}else if((e|0)==2){dZ(b,f);do{if((c[f>>2]|0)==12){k=c[f+8>>2]|0;if((c[f+16>>2]|0)==(c[f+20>>2]|0)){break}if((k|0)<(d[b+50|0]|0)){l=1290;break}d$(b,f,k)}else{l=1290}}while(0);if((l|0)==1290){d_(b,f)}d8(b,20,f,j);i=g;return}else if((e|0)==1){dZ(b,f);e=f|0;L1583:do{switch(c[e>>2]|0){case 1:case 3:{c[e>>2]=2;break};case 4:case 5:case 2:{c[e>>2]=3;break};case 10:{j=c[(c[b>>2]|0)+12>>2]|0;k=c[f+8>>2]|0;m=j+(k<<2)|0;if((k|0)>0){n=j+(k-1<<2)|0;k=c[n>>2]|0;if((a[992+(k&63)|0]|0)<0){o=n;p=k}else{l=1255}}else{l=1255}if((l|0)==1255){o=m;p=c[m>>2]|0}c[o>>2]=((p&16320|0)==0)<<6|p&-16321;break};case 11:{m=b+36|0;k=c[m>>2]|0;n=k+1|0;j=b|0;q=c[j>>2]|0;if((n|0)>(d[q+75|0]|0)){if((n|0)>249){ff(c[b+12>>2]|0,5128);r=c[j>>2]|0}else{r=q}a[r+75|0]=n&255;s=c[m>>2]|0}else{s=k}c[m>>2]=s+1;ek(b,f,s);if((c[e>>2]|0)==12){l=1263;break L1583}t=f+8|0;l=1266;break};case 12:{l=1263;break};default:{}}}while(0);do{if((l|0)==1263){s=f+8|0;r=c[s>>2]|0;if((r&256|0)!=0){t=s;l=1266;break}if((d[b+50|0]|0)>(r|0)){t=s;l=1266;break}r=b+36|0;c[r>>2]=(c[r>>2]|0)-1;t=s;l=1266}}while(0);if((l|0)==1266){c[t>>2]=ec(b,c[t>>2]<<23|19,c[(c[b+12>>2]|0)+8>>2]|0)|0;c[e>>2]=11}e=f+20|0;t=c[e>>2]|0;s=f+16|0;f=c[s>>2]|0;c[e>>2]=f;c[s>>2]=t;if((f|0)==-1){u=t}else{t=b|0;e=f;f=c[(c[t>>2]|0)+12>>2]|0;while(1){r=f+(e<<2)|0;if((e|0)>0){p=f+(e-1<<2)|0;o=c[p>>2]|0;if((a[992+(o&63)|0]|0)<0){v=p;w=o}else{l=1271}}else{l=1271}if((l|0)==1271){l=0;v=r;w=c[r>>2]|0}if((w&63|0)==27){c[v>>2]=w&8372224|w>>>23<<6|26;x=c[(c[t>>2]|0)+12>>2]|0}else{x=f}r=((c[x+(e<<2)>>2]|0)>>>14)-131071|0;if((r|0)==-1){break}o=e+1+r|0;if((o|0)==-1){break}else{e=o;f=x}}u=c[s>>2]|0}if((u|0)==-1){i=g;return}s=b|0;b=u;u=c[(c[s>>2]|0)+12>>2]|0;while(1){x=u+(b<<2)|0;if((b|0)>0){f=u+(b-1<<2)|0;e=c[f>>2]|0;if((a[992+(e&63)|0]|0)<0){y=f;z=e}else{l=1281}}else{l=1281}if((l|0)==1281){l=0;y=x;z=c[x>>2]|0}if((z&63|0)==27){c[y>>2]=z&8372224|z>>>23<<6|26;A=c[(c[s>>2]|0)+12>>2]|0}else{A=u}x=((c[A+(b<<2)>>2]|0)>>>14)-131071|0;if((x|0)==-1){l=1297;break}e=b+1+x|0;if((e|0)==-1){l=1298;break}else{b=e;u=A}}if((l|0)==1297){i=g;return}else if((l|0)==1298){i=g;return}}else{i=g;return}}function d8(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var g=0,i=0,j=0,k=0.0,l=0.0,m=0.0,n=0,o=0.0;g=e|0;L1640:do{if((c[g>>2]|0)==5){if((c[e+16>>2]|0)!=-1){i=1317;break}if((c[e+20>>2]|0)!=-1){i=1317;break}if((c[f>>2]|0)!=5){i=1317;break}if((c[f+16>>2]|0)!=-1){i=1317;break}if((c[f+20>>2]|0)!=-1){i=1317;break}j=e+8|0;k=+h[j>>3];l=+h[f+8>>3];switch(b|0){case 12:{m=k+l;i=1315;break};case 16:{if(l==0.0){i=1318;break L1640}m=k-l*+O(+(k/l));i=1315;break};case 18:{m=-0.0-k;i=1315;break};case 13:{m=k-l;i=1315;break};case 15:{if(l==0.0){i=1318;break L1640}m=k/l;i=1315;break};case 14:{m=k*l;i=1315;break};case 20:{n=0;break L1640;break};case 17:{m=+R(+k,+l);i=1315;break};default:{o=0.0}}if((i|0)==1315){if(m==m&!(D=0.0,D!=D)){o=m}else{i=1317;break}}h[j>>3]=o;return}else{i=1317}}while(0);if((i|0)==1317){if((b|0)==20|(b|0)==18){n=0}else{i=1318}}if((i|0)==1318){n=d2(a,f)|0}i=d2(a,e)|0;do{if((i|0)>(n|0)){do{if((c[g>>2]|0)==12){j=c[e+8>>2]|0;if((j&256|0)!=0){break}if((d[a+50|0]|0|0)>(j|0)){break}j=a+36|0;c[j>>2]=(c[j>>2]|0)-1}}while(0);if((c[f>>2]|0)!=12){break}j=c[f+8>>2]|0;if((j&256|0)!=0){break}if((d[a+50|0]|0|0)>(j|0)){break}j=a+36|0;c[j>>2]=(c[j>>2]|0)-1}else{do{if((c[f>>2]|0)==12){j=c[f+8>>2]|0;if((j&256|0)!=0){break}if((d[a+50|0]|0|0)>(j|0)){break}j=a+36|0;c[j>>2]=(c[j>>2]|0)-1}}while(0);if((c[g>>2]|0)!=12){break}j=c[e+8>>2]|0;if((j&256|0)!=0){break}if((d[a+50|0]|0|0)>(j|0)){break}j=a+36|0;c[j>>2]=(c[j>>2]|0)-1}}while(0);c[e+8>>2]=ec(a,n<<14|b|i<<23,c[(c[a+12>>2]|0)+8>>2]|0)|0;c[g>>2]=11;return}function d9(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;switch(e|0){case 13:{d5(b,f);return};case 14:{dZ(b,f);e=f|0;g=c[e>>2]|0;L1692:do{if((g|0)==10){h=c[f+8>>2]|0;i=1357}else if(!((g|0)==1|(g|0)==3)){j=f+8|0;do{if((g|0)==11){k=c[b>>2]|0;l=c[(c[k+12>>2]|0)+(c[j>>2]<<2)>>2]|0;if((l&63|0)!=19){m=k;i=1348;break}k=b+24|0;c[k>>2]=(c[k>>2]|0)-1;h=ee(b,26,l>>>23,0,0)|0;i=1357;break L1692}else if((g|0)==12){i=1353}else{m=c[b>>2]|0;i=1348}}while(0);if((i|0)==1348){l=b+36|0;k=c[l>>2]|0;n=k+1|0;o=b|0;if((n|0)>(d[m+75|0]|0|0)){if((n|0)>249){ff(c[b+12>>2]|0,5128);p=c[o>>2]|0}else{p=m}a[p+75|0]=n&255;q=c[l>>2]|0}else{q=k}c[l>>2]=q+1;ek(b,f,q);if((c[e>>2]|0)==12){i=1353}}do{if((i|0)==1353){l=c[j>>2]|0;if((l&256|0)!=0){break}if((d[b+50|0]|0|0)>(l|0)){break}l=b+36|0;c[l>>2]=(c[l>>2]|0)-1}}while(0);h=ee(b,27,255,c[j>>2]|0,1)|0;i=1357}}while(0);do{if((i|0)==1357){e=f+16|0;if((h|0)==-1){break}q=c[e>>2]|0;if((q|0)==-1){c[e>>2]=h;break}e=c[(c[b>>2]|0)+12>>2]|0;p=q;while(1){r=e+(p<<2)|0;s=c[r>>2]|0;q=(s>>>14)-131071|0;if((q|0)==-1){break}m=p+1+q|0;if((m|0)==-1){break}else{p=m}}e=h+~p|0;if((((e|0)>-1?e:-e|0)|0)>131071){ff(c[b+12>>2]|0,5464);t=c[r>>2]|0}else{t=s}c[r>>2]=t&16383|(e<<14)+2147467264}}while(0);t=f+20|0;r=c[t>>2]|0;c[b+28>>2]=c[b+24>>2];s=b+32|0;do{if((r|0)!=-1){h=c[s>>2]|0;if((h|0)==-1){c[s>>2]=r;break}i=c[(c[b>>2]|0)+12>>2]|0;e=h;while(1){u=i+(e<<2)|0;v=c[u>>2]|0;h=(v>>>14)-131071|0;if((h|0)==-1){break}j=e+1+h|0;if((j|0)==-1){break}else{e=j}}i=r+~e|0;if((((i|0)>-1?i:-i|0)|0)>131071){ff(c[b+12>>2]|0,5464);w=c[u>>2]|0}else{w=v}c[u>>2]=w&16383|(i<<14)+2147467264}}while(0);c[t>>2]=-1;return};case 6:{d_(b,f);return};case 0:case 1:case 2:case 3:case 4:case 5:{do{if((c[f>>2]|0)==5){if((c[f+16>>2]|0)!=-1){break}if((c[f+20>>2]|0)!=-1){break}return}}while(0);d2(b,f)|0;return};default:{d2(b,f)|0;return}}}function ea(a,b){a=a|0;b=b|0;c[(c[(c[a>>2]|0)+20>>2]|0)+((c[a+24>>2]|0)-1<<2)>>2]=b;return}function eb(a,b,e,f){a=a|0;b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;switch(b|0){case 13:{dZ(a,f);b=f+20|0;g=c[e+20>>2]|0;do{if((g|0)!=-1){h=c[b>>2]|0;if((h|0)==-1){c[b>>2]=g;break}i=c[(c[a>>2]|0)+12>>2]|0;j=h;while(1){k=i+(j<<2)|0;l=c[k>>2]|0;h=(l>>>14)-131071|0;if((h|0)==-1){break}m=j+1+h|0;if((m|0)==-1){break}else{j=m}}i=g+~j|0;if((((i|0)>-1?i:-i|0)|0)>131071){ff(c[a+12>>2]|0,5464);n=c[k>>2]|0}else{n=l}c[k>>2]=n&16383|(i<<14)+2147467264}}while(0);n=e;k=f;c[n>>2]=c[k>>2];c[n+4>>2]=c[k+4>>2];c[n+8>>2]=c[k+8>>2];c[n+12>>2]=c[k+12>>2];c[n+16>>2]=c[k+16>>2];c[n+20>>2]=c[k+20>>2];return};case 10:{k=d2(a,e)|0;n=d2(a,f)|0;do{if((c[f>>2]|0)==12){l=c[f+8>>2]|0;if((l&256|0)!=0){break}if((d[a+50|0]|0|0)>(l|0)){break}l=a+36|0;c[l>>2]=(c[l>>2]|0)-1}}while(0);l=e|0;g=e+8|0;do{if((c[l>>2]|0)==12){b=c[g>>2]|0;if((b&256|0)!=0){break}if((d[a+50|0]|0|0)>(b|0)){break}b=a+36|0;c[b>>2]=(c[b>>2]|0)-1}}while(0);c[g>>2]=ee(a,25,1,k,n)|0;c[l>>2]=10;return};case 9:{l=d2(a,e)|0;n=d2(a,f)|0;do{if((c[f>>2]|0)==12){k=c[f+8>>2]|0;if((k&256|0)!=0){break}if((d[a+50|0]|0|0)>(k|0)){break}k=a+36|0;c[k>>2]=(c[k>>2]|0)-1}}while(0);k=e|0;g=e+8|0;do{if((c[k>>2]|0)==12){b=c[g>>2]|0;if((b&256|0)!=0){break}if((d[a+50|0]|0|0)>(b|0)){break}b=a+36|0;c[b>>2]=(c[b>>2]|0)-1}}while(0);c[g>>2]=ee(a,24,1,l,n)|0;c[k>>2]=10;return};case 11:{k=d2(a,e)|0;n=d2(a,f)|0;do{if((c[f>>2]|0)==12){l=c[f+8>>2]|0;if((l&256|0)!=0){break}if((d[a+50|0]|0|0)>(l|0)){break}l=a+36|0;c[l>>2]=(c[l>>2]|0)-1}}while(0);l=e|0;g=e+8|0;do{if((c[l>>2]|0)==12){b=c[g>>2]|0;if((b&256|0)!=0){break}if((d[a+50|0]|0|0)>(b|0)){break}b=a+36|0;c[b>>2]=(c[b>>2]|0)-1}}while(0);c[g>>2]=ee(a,24,1,n,k)|0;c[l>>2]=10;return};case 14:{dZ(a,f);l=f+16|0;k=c[e+16>>2]|0;do{if((k|0)!=-1){n=c[l>>2]|0;if((n|0)==-1){c[l>>2]=k;break}g=c[(c[a>>2]|0)+12>>2]|0;b=n;while(1){o=g+(b<<2)|0;p=c[o>>2]|0;n=(p>>>14)-131071|0;if((n|0)==-1){break}i=b+1+n|0;if((i|0)==-1){break}else{b=i}}g=k+~b|0;if((((g|0)>-1?g:-g|0)|0)>131071){ff(c[a+12>>2]|0,5464);q=c[o>>2]|0}else{q=p}c[o>>2]=q&16383|(g<<14)+2147467264}}while(0);q=e;o=f;c[q>>2]=c[o>>2];c[q+4>>2]=c[o+4>>2];c[q+8>>2]=c[o+8>>2];c[q+12>>2]=c[o+12>>2];c[q+16>>2]=c[o+16>>2];c[q+20>>2]=c[o+20>>2];return};case 6:{o=f+16|0;q=f+20|0;p=(c[o>>2]|0)==(c[q>>2]|0);dZ(a,f);k=f|0;L1821:do{if(!p){do{if((c[k>>2]|0)==12){l=c[f+8>>2]|0;if((c[o>>2]|0)==(c[q>>2]|0)){break L1821}if((l|0)<(d[a+50|0]|0|0)){break}d$(a,f,l);break L1821}}while(0);d_(a,f)}}while(0);do{if((c[k>>2]|0)==11){q=f+8|0;o=c[q>>2]|0;p=(c[a>>2]|0)+12|0;b=c[p>>2]|0;l=c[b+(o<<2)>>2]|0;if((l&63|0)!=21){break}g=e|0;j=e+8|0;do{if((c[g>>2]|0)==12){i=c[j>>2]|0;if((i&256|0)!=0){r=o;s=b;t=l;break}if((d[a+50|0]|0|0)>(i|0)){r=o;s=b;t=l;break}i=a+36|0;c[i>>2]=(c[i>>2]|0)-1;i=c[q>>2]|0;n=c[p>>2]|0;r=i;s=n;t=c[n+(i<<2)>>2]|0}else{r=o;s=b;t=l}}while(0);c[s+(r<<2)>>2]=c[j>>2]<<23|t&8388607;c[g>>2]=11;c[j>>2]=c[q>>2];return}}while(0);d_(a,f);d8(a,21,e,f);return};case 0:{d8(a,12,e,f);return};case 1:{d8(a,13,e,f);return};case 2:{d8(a,14,e,f);return};case 3:{d8(a,15,e,f);return};case 4:{d8(a,16,e,f);return};case 5:{d8(a,17,e,f);return};case 8:{t=d2(a,e)|0;r=d2(a,f)|0;do{if((c[f>>2]|0)==12){s=c[f+8>>2]|0;if((s&256|0)!=0){break}if((d[a+50|0]|0|0)>(s|0)){break}s=a+36|0;c[s>>2]=(c[s>>2]|0)-1}}while(0);s=e|0;k=e+8|0;do{if((c[s>>2]|0)==12){l=c[k>>2]|0;if((l&256|0)!=0){break}if((d[a+50|0]|0|0)>(l|0)){break}l=a+36|0;c[l>>2]=(c[l>>2]|0)-1}}while(0);c[k>>2]=ee(a,23,1,t,r)|0;c[s>>2]=10;return};case 7:{s=d2(a,e)|0;r=d2(a,f)|0;do{if((c[f>>2]|0)==12){t=c[f+8>>2]|0;if((t&256|0)!=0){break}if((d[a+50|0]|0|0)>(t|0)){break}t=a+36|0;c[t>>2]=(c[t>>2]|0)-1}}while(0);t=e|0;k=e+8|0;do{if((c[t>>2]|0)==12){l=c[k>>2]|0;if((l&256|0)!=0){break}if((d[a+50|0]|0|0)>(l|0)){break}l=a+36|0;c[l>>2]=(c[l>>2]|0)-1}}while(0);c[k>>2]=ee(a,23,0,s,r)|0;c[t>>2]=10;return};case 12:{t=d2(a,e)|0;r=d2(a,f)|0;do{if((c[f>>2]|0)==12){s=c[f+8>>2]|0;if((s&256|0)!=0){break}if((d[a+50|0]|0|0)>(s|0)){break}s=a+36|0;c[s>>2]=(c[s>>2]|0)-1}}while(0);f=e|0;s=e+8|0;do{if((c[f>>2]|0)==12){e=c[s>>2]|0;if((e&256|0)!=0){break}if((d[a+50|0]|0|0)>(e|0)){break}e=a+36|0;c[e>>2]=(c[e>>2]|0)-1}}while(0);c[s>>2]=ee(a,25,1,r,t)|0;c[f>>2]=10;return};default:{return}}}function ec(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;f=b|0;g=c[f>>2]|0;h=b+32|0;i=c[h>>2]|0;j=b+24|0;k=c[j>>2]|0;if((i|0)==-1){l=k}else{m=b+12|0;n=i;i=g;while(1){o=c[i+12>>2]|0;p=o+(n<<2)|0;q=c[p>>2]|0;r=(q>>>14)-131071|0;if((r|0)==-1){s=-1}else{s=n+1+r|0}if((n|0)>0){r=o+(n-1<<2)|0;o=c[r>>2]|0;if((a[992+(o&63)|0]|0)<0){t=r;u=o}else{v=1509}}else{v=1509}if((v|0)==1509){v=0;t=p;u=q}if((u&63|0)==27){c[t>>2]=u&8372224|u>>>23<<6|26;o=(c[(c[f>>2]|0)+12>>2]|0)+(n<<2)|0;r=k+~n|0;if((((r|0)>-1?r:-r|0)|0)>131071){ff(c[m>>2]|0,5464)}c[o>>2]=c[o>>2]&16383|(r<<14)+2147467264}else{r=k+~n|0;if((((r|0)>-1?r:-r|0)|0)>131071){ff(c[m>>2]|0,5464);w=c[p>>2]|0}else{w=q}c[p>>2]=w&16383|(r<<14)+2147467264}if((s|0)==-1){break}n=s;i=c[f>>2]|0}l=c[j>>2]|0}c[h>>2]=-1;h=g+44|0;if((l+1|0)>(c[h>>2]|0)){f=g+12|0;i=ft(c[b+16>>2]|0,c[f>>2]|0,h,4,2147483645,9304)|0;c[f>>2]=i;x=c[j>>2]|0;y=i}else{x=l;y=c[g+12>>2]|0}c[y+(x<<2)>>2]=d;d=c[j>>2]|0;x=g+48|0;if((d+1|0)>(c[x>>2]|0)){y=g+20|0;l=ft(c[b+16>>2]|0,c[y>>2]|0,x,4,2147483645,9304)|0;c[y>>2]=l;z=c[j>>2]|0;A=l;B=A+(z<<2)|0;c[B>>2]=e;C=c[j>>2]|0;D=C+1|0;c[j>>2]=D;return C|0}else{z=d;A=c[g+20>>2]|0;B=A+(z<<2)|0;c[B>>2]=e;C=c[j>>2]|0;D=C+1|0;c[j>>2]=D;return C|0}return 0}function ed(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=((d-1|0)/50|0)+1|0;d=b<<6|((e|0)==-1?0:e<<23)|34;if((f|0)<512){e=f<<14|d;g=c[(c[a+12>>2]|0)+8>>2]|0;ec(a,e,g)|0;h=b+1|0;i=a+36|0;c[i>>2]=h;return}else{g=a+12|0;e=c[(c[g>>2]|0)+8>>2]|0;ec(a,d,e)|0;e=c[(c[g>>2]|0)+8>>2]|0;ec(a,f,e)|0;h=b+1|0;i=a+36|0;c[i>>2]=h;return}}function ee(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0;g=a+12|0;ec(a,d<<6|b|e<<23|f<<14,c[(c[g>>2]|0)+8>>2]|0)|0;f=a+32|0;e=c[f>>2]|0;c[f>>2]=-1;f=ec(a,2147450902,c[(c[g>>2]|0)+8>>2]|0)|0;if((e|0)==-1){h=f;return h|0}if((f|0)==-1){h=e;return h|0}b=c[(c[a>>2]|0)+12>>2]|0;a=f;while(1){i=b+(a<<2)|0;j=c[i>>2]|0;d=(j>>>14)-131071|0;if((d|0)==-1){break}k=a+1+d|0;if((k|0)==-1){break}else{a=k}}b=e+~a|0;if((((b|0)>-1?b:-b|0)|0)>131071){ff(c[g>>2]|0,5464);l=c[i>>2]|0}else{l=j}c[i>>2]=l&16383|(b<<14)+2147467264;h=f;return h|0}function ef(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0;if((d|0)==0){g=1549}else{if((e|0)==0){g=1549}else{h=d;i=e&255}}if((g|0)==1549){h=0;i=0}c[b+68>>2]=h;c[b+60>>2]=f;c[b+64>>2]=f;a[b+56|0]=i;return 1}function eg(a){a=a|0;return c[a+68>>2]|0}function eh(a){a=a|0;return d[a+56|0]|0|0}function ei(a){a=a|0;return c[a+60>>2]|0}function ej(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=c[b+20>>2]|0;L1955:do{if((d|0)>0){g=c[b+40>>2]|0;h=d;i=f;while(1){if(i>>>0<=g>>>0){j=0;break}k=h-1|0;if((a[(c[c[i+4>>2]>>2]|0)+6|0]|0)==0){l=k-(c[i+20>>2]|0)|0}else{l=k}k=i-24|0;if((l|0)>0){h=l;i=k}else{m=l;n=k;break L1955}}return j|0}else{m=d;n=f}}while(0);if((m|0)!=0){c[e+96>>2]=0;j=1;return j|0}m=c[b+40>>2]|0;if(n>>>0<=m>>>0){j=0;return j|0}c[e+96>>2]=(n-m|0)/24|0;j=1;return j|0}function ek(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0;f=i;i=i+16|0;g=f|0;dZ(a,b);j=b|0;k=c[j>>2]|0;L1974:do{switch(k|0){case 1:{l=c[a+24>>2]|0;do{if((l|0)>(c[a+28>>2]|0)){if((l|0)==0){if((d[a+50|0]|0|0)>(e|0)){break}else{break L1974}}m=(c[(c[a>>2]|0)+12>>2]|0)+(l-1<<2)|0;n=c[m>>2]|0;if((n&63|0)!=3){break}o=n>>>23;if((n>>>6&255|0)>(e|0)){break}if((o+1|0)<(e|0)){break}if((o|0)>=(e|0)){break L1974}c[m>>2]=n&8388607|e<<23;break L1974}}while(0);ec(a,e<<23|e<<6|3,c[(c[a+12>>2]|0)+8>>2]|0)|0;break};case 5:{h[g>>3]=+h[b+8>>3];c[g+8>>2]=3;ec(a,e<<6|(dV(a,g,g)|0)<<14|1,c[(c[a+12>>2]|0)+8>>2]|0)|0;break};case 4:{ec(a,e<<6|c[b+8>>2]<<14|1,c[(c[a+12>>2]|0)+8>>2]|0)|0;break};case 11:{l=(c[(c[a>>2]|0)+12>>2]|0)+(c[b+8>>2]<<2)|0;c[l>>2]=c[l>>2]&-16321|e<<6&16320;break};case 12:{l=c[b+8>>2]|0;if((l|0)==(e|0)){break L1974}ec(a,l<<23|e<<6,c[(c[a+12>>2]|0)+8>>2]|0)|0;break};case 3:case 2:{ec(a,e<<6|((k|0)==2)<<23|2,c[(c[a+12>>2]|0)+8>>2]|0)|0;break};default:{i=f;return}}}while(0);c[b+8>>2]=e;c[j>>2]=12;i=f;return}function el(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;f=c[b+40>>2]|0;g=c[d+96>>2]|0;d=f+(g*24|0)|0;h=c[f+(g*24|0)+4>>2]|0;do{if((c[h+8>>2]|0)==6){i=h;j=c[i>>2]|0;if((a[j+6|0]|0)!=0){k=1597;break}l=c[j+16>>2]|0;if((l|0)==0){k=1597;break}if((c[b+20>>2]|0)==(d|0)){j=c[b+24>>2]|0;c[f+(g*24|0)+12>>2]=j;m=j;n=c[(c[i>>2]|0)+16>>2]|0}else{m=c[f+(g*24|0)+12>>2]|0;n=l}i=eT(l,e,(m-(c[n+12>>2]|0)>>2)-1|0)|0;if((i|0)==0){k=1597;break}o=i;p=c[d>>2]|0}else{k=1597}}while(0);do{if((k|0)==1597){n=c[d>>2]|0;m=((c[((c[b+20>>2]|0)==(d|0)?b+8|0:f+((g+1|0)*24|0)+4|0)>>2]|0)-n>>4|0)>=(e|0)&(e|0)>0;if(m){o=m?8472:0;p=n;break}else{q=0}return q|0}}while(0);cB(b,p+(e-1<<4)|0);q=o;return q|0}function em(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;f=c[b+40>>2]|0;g=c[d+96>>2]|0;d=f+(g*24|0)|0;h=c[f+(g*24|0)+4>>2]|0;do{if((c[h+8>>2]|0)==6){i=h;j=c[i>>2]|0;if((a[j+6|0]|0)!=0){k=1610;break}l=c[j+16>>2]|0;if((l|0)==0){k=1610;break}if((c[b+20>>2]|0)==(d|0)){j=c[b+24>>2]|0;c[f+(g*24|0)+12>>2]=j;m=j;n=c[(c[i>>2]|0)+16>>2]|0}else{m=c[f+(g*24|0)+12>>2]|0;n=l}i=eT(l,e,(m-(c[n+12>>2]|0)>>2)-1|0)|0;if((i|0)==0){k=1610;break}o=i;p=c[d>>2]|0;q=b+8|0}else{k=1610}}while(0);do{if((k|0)==1610){n=b+8|0;m=c[d>>2]|0;h=((c[((c[b+20>>2]|0)==(d|0)?n:f+((g+1|0)*24|0)+4|0)>>2]|0)-m>>4|0)>=(e|0)&(e|0)>0;if(h){o=h?8472:0;p=m;q=n;break}else{r=0}s=b+8|0;t=c[s>>2]|0;u=t-16|0;c[s>>2]=u;return r|0}}while(0);g=c[q>>2]|0;q=e-1|0;e=g-16|0;f=p+(q<<4)|0;d=c[e+4>>2]|0;c[f>>2]=c[e>>2];c[f+4>>2]=d;c[p+(q<<4)+8>>2]=c[g-16+8>>2];r=o;s=b+8|0;t=c[s>>2]|0;u=t-16|0;c[s>>2]=u;return r|0}function en(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0;do{if((a[e]|0)==62){g=b+8|0;h=(c[g>>2]|0)-16|0;i=c[h>>2]|0;c[g>>2]=h;j=e+1|0;k=i;l=0;m=1619}else{i=c[f+96>>2]|0;if((i|0)==0){n=e;m=1622;break}h=c[b+40>>2]|0;j=e;k=c[c[h+(i*24|0)+4>>2]>>2]|0;l=h+(i*24|0)|0;m=1619}}while(0);L2030:do{if((m|0)==1619){e=k;if((k|0)==0){n=j;m=1622;break}i=a[j]|0;if(i<<24>>24==0){o=1;p=e;q=j;r=0;break}h=k+6|0;g=k+16|0;s=f+16|0;t=f+28|0;u=f+32|0;v=f+12|0;w=f+36|0;x=(l|0)==0;y=f+20|0;z=l+4|0;A=b+20|0;B=b+24|0;C=l+12|0;D=e+7|0;E=f+24|0;F=f+8|0;G=f+4|0;H=l+20|0;I=l-24|0;J=l-24+4|0;K=l-24+12|0;L=j;M=1;N=i;while(1){L2036:do{switch(N<<24>>24|0){case 110:{L2038:do{if(x){m=1649}else{i=c[z>>2]|0;do{if((c[i+8>>2]|0)==6){if((a[(c[i>>2]|0)+6|0]|0)!=0){break}if((c[H>>2]|0)>0){m=1649;break L2038}}}while(0);i=c[J>>2]|0;if((c[i+8>>2]|0)!=6){m=1649;break}O=i;i=c[O>>2]|0;if((a[i+6|0]|0)!=0){m=1649;break}if((c[A>>2]|0)==(I|0)){P=c[B>>2]|0;c[K>>2]=P;Q=c[O>>2]|0;R=P}else{Q=i;R=c[K>>2]|0}i=c[(c[Q+16>>2]|0)+12>>2]|0;P=c[i+((R-i>>2)-1<<2)>>2]|0;i=P&63;if(!((i|0)==28|(i|0)==29|(i|0)==33)){m=1649;break}i=er(b,I,P>>>6&255,G)|0;c[F>>2]=i;if((i|0)!=0){S=M;break L2036}}}while(0);if((m|0)==1649){m=0;c[F>>2]=0}c[F>>2]=10576;c[G>>2]=0;S=M;break};case 117:{c[E>>2]=d[D]|0;S=M;break};case 108:{do{if(x){T=-1}else{i=c[z>>2]|0;if((c[i+8>>2]|0)!=6){T=-1;break}P=i;i=c[P>>2]|0;if((a[i+6|0]|0)!=0){T=-1;break}if((c[A>>2]|0)==(l|0)){O=c[B>>2]|0;c[C>>2]=O;U=c[P>>2]|0;V=O}else{U=i;V=c[C>>2]|0}i=c[U+16>>2]|0;O=(V-(c[i+12>>2]|0)>>2)-1|0;if((O|0)<0){T=-1;break}P=c[i+20>>2]|0;if((P|0)==0){T=0;break}T=c[P+(O<<2)>>2]|0}}while(0);c[y>>2]=T;S=M;break};case 83:{if((a[h]|0)==0){O=(c[(c[g>>2]|0)+32>>2]|0)+16|0;c[s>>2]=O;P=c[(c[g>>2]|0)+60>>2]|0;c[t>>2]=P;c[u>>2]=c[(c[g>>2]|0)+64>>2];W=O;X=(P|0)==0?9144:9024}else{c[s>>2]=9536;c[t>>2]=-1;c[u>>2]=-1;W=9536;X=9288}c[v>>2]=X;fz(w,W,60);S=M;break};case 76:case 102:{S=M;break};default:{S=0}}}while(0);P=L+1|0;O=a[P]|0;if(O<<24>>24==0){o=S;p=e;q=j;r=0;break L2030}else{L=P;M=S;N=O}}}}while(0);if((m|0)==1622){c[f+8>>2]=10576;c[f+4>>2]=10576;c[f+12>>2]=8864;c[f+20>>2]=-1;c[f+28>>2]=-1;c[f+32>>2]=-1;c[f+16>>2]=8648;fz(f+36|0,8648,60);c[f+24>>2]=0;o=1;p=0;q=n;r=1}if((aU(q|0,102)|0)!=0){n=b+8|0;f=c[n>>2]|0;if(r){c[f+8>>2]=0}else{c[f>>2]=p;c[f+8>>2]=6}f=c[n>>2]|0;if(((c[b+28>>2]|0)-f|0)<17){eA(b,1);Y=c[n>>2]|0}else{Y=f}c[n>>2]=Y+16}if((aU(q|0,76)|0)==0){return o|0}do{if(r){m=1664}else{if((a[p+6|0]|0)!=0){m=1664;break}q=f5(b,0,0)|0;Y=p+16|0;n=c[Y>>2]|0;f=c[n+20>>2]|0;if((c[n+48>>2]|0)>0){n=0;do{S=gc(b,q,c[f+(n<<2)>>2]|0)|0;c[S>>2]=1;c[S+8>>2]=1;n=n+1|0;}while((n|0)<(c[(c[Y>>2]|0)+48>>2]|0))}Y=c[b+8>>2]|0;c[Y>>2]=q;c[Y+8>>2]=5}}while(0);if((m|0)==1664){c[(c[b+8>>2]|0)+8>>2]=0}m=b+8|0;p=c[m>>2]|0;if(((c[b+28>>2]|0)-p|0)<17){eA(b,1);Z=c[m>>2]|0}else{Z=p}c[m>>2]=Z+16;return o|0}function eo(a){a=a|0;return(ep(a,c[a+44>>2]|0,255)|0)!=0|0}function ep(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;g=c[b+44>>2]|0;h=a[b+75|0]|0;if((h&255)>=251){i=0;return i|0}j=h&255;k=a[b+74|0]|0;l=k&255;if(((l&1)+(d[b+73|0]|0)|0)>(j|0)|(l&5|0)==4){i=0;return i|0}l=d[b+72|0]|0;if((c[b+36>>2]|0)>(l|0)){i=0;return i|0}m=c[b+48>>2]|0;if(!(((m|0)==(g|0)|(m|0)==0)&(g|0)>0)){i=0;return i|0}m=g-1|0;n=c[b+12>>2]|0;o=c[n+(m<<2)>>2]|0;if((o&63|0)!=30){i=0;return i|0}if((e|0)<=0){i=o;return i|0}o=b+8|0;p=(f|0)==255;q=b+52|0;r=b+16|0;s=b+40|0;b=m;m=0;L2124:while(1){t=c[n+(m<<2)>>2]|0;u=t&63;v=t>>>6&255;if(u>>>0>=38){i=0;w=1754;break}x=h&255;if(v>>>0>=x>>>0){i=0;w=1755;break}y=a[992+u|0]|0;z=y&255;A=z&3;do{if((A|0)==0){B=t>>>23;C=t>>>14;D=C&511;E=z>>>4&3;do{if((E|0)==0){if((B|0)!=0){i=0;w=1763;break L2124}}else if((E|0)==2){if(x>>>0<=B>>>0){i=0;w=1764;break L2124}}else if((E|0)==3){if((B&256|0)==0){if(x>>>0>B>>>0){break}else{i=0;w=1766;break L2124}}else{if((B&255|0)<(c[s>>2]|0)){break}else{i=0;w=1765;break L2124}}}}while(0);E=z>>>2&3;if((E|0)==0){if((D|0)==0){F=B;G=0;break}else{i=0;w=1767;break L2124}}else if((E|0)==2){if(j>>>0>D>>>0){F=B;G=D;break}else{i=0;w=1768;break L2124}}else if((E|0)==3){if((C&256|0)==0){if(j>>>0>D>>>0){F=B;G=D;break}else{i=0;w=1770;break L2124}}else{if((C&255|0)<(c[s>>2]|0)){F=B;G=D;break}else{i=0;w=1769;break L2124}}}else{F=B;G=D;break}}else if((A|0)==1){E=t>>>14;if((z&48|0)!=48){F=E;G=0;break}if((E|0)<(c[s>>2]|0)){F=E;G=0}else{i=0;w=1771;break L2124}}else if((A|0)==2){E=(t>>>14)-131071|0;if((z&48|0)!=32){F=E;G=0;break}H=m+1+E|0;if(!((H|0)>-1&(H|0)<(g|0))){i=0;w=1772;break L2124}if((H|0)<=0){F=E;G=0;break}I=E+m|0;J=0;while(1){if((J|0)>=(H|0)){break}if((c[n+(I-J<<2)>>2]&8372287|0)==34){J=J+1|0}else{break}}if((J&1|0)==0){F=E;G=0}else{i=0;w=1773;break L2124}}else{F=0;G=0}}while(0);z=(y&64)!=0&(v|0)==(f|0)?m:b;if(y<<24>>24<0){if((m+2|0)>=(g|0)){i=0;w=1774;break}if((c[n+(m+1<<2)>>2]&63|0)!=22){i=0;w=1775;break}}L2160:do{switch(u|0){case 2:{if((G|0)!=1){K=m;L=z;break L2160}if((m+2|0)>=(g|0)){i=0;w=1776;break L2124}if((c[n+(m+1<<2)>>2]&8372287|0)==34){i=0;w=1777;break L2124}else{K=m;L=z}break};case 3:{K=m;L=(v|0)>(f|0)|(F|0)<(f|0)?z:m;break};case 4:case 8:{if((F|0)<(l|0)){K=m;L=z}else{i=0;w=1778;break L2124}break};case 5:case 7:{if((c[(c[o>>2]|0)+(F<<4)+8>>2]|0)==4){K=m;L=z}else{i=0;w=1779;break L2124}break};case 11:{t=v+1|0;if(t>>>0>=(h&255)>>>0){i=0;w=1780;break L2124}K=m;L=(t|0)==(f|0)?m:z;break};case 21:{if((F|0)<(G|0)){K=m;L=z}else{i=0;w=1781;break L2124}break};case 33:{if((G|0)==0){i=0;w=1782;break L2124}t=v+2|0;if((G+t|0)>=(h&255|0)){i=0;w=1783;break L2124}K=m;L=(t|0)>(f|0)?z:m;break};case 31:case 32:{if((v+3|0)>>>0<(h&255)>>>0){w=1723}else{i=0;w=1784;break L2124}break};case 22:{w=1723;break};case 28:case 29:{if((F|0)!=0){if((v-1+F|0)>=(h&255|0)){i=0;w=1785;break L2124}}t=G-1|0;do{if((G|0)==0){A=c[n+(m+1<<2)>>2]|0;x=A&63;if(!((x|0)==28|(x|0)==29|(x|0)==30|(x|0)==34)){i=0;w=1786;break L2124}if(A>>>0>=8388608){i=0;w=1787;break L2124}}else{if((t|0)==0){break}if((v-1+t|0)>=(h&255|0)){i=0;w=1788;break L2124}}}while(0);K=m;L=(v|0)>(f|0)?z:m;break};case 30:{t=F-1|0;if((t|0)<=0){K=m;L=z;break L2160}if((v-1+t|0)<(h&255|0)){K=m;L=z}else{i=0;w=1789;break L2124}break};case 34:{if((F|0)>0){if((F+v|0)>=(h&255|0)){i=0;w=1790;break L2124}}if((G|0)!=0){K=m;L=z;break L2160}t=m+1|0;if((t|0)<(g-1|0)){K=t;L=z}else{i=0;w=1791;break L2124}break};case 36:{if((F|0)>=(c[q>>2]|0)){i=0;w=1792;break L2124}t=a[(c[(c[r>>2]|0)+(F<<2)>>2]|0)+72|0]|0;E=t&255;J=E+m|0;if((J|0)>=(g|0)){i=0;w=1793;break L2124}if(t<<24>>24!=0){t=1;do{A=c[n+(t+m<<2)>>2]&63;if(!((A|0)==4|(A|0)==0)){i=0;w=1794;break L2124}t=t+1|0;}while((t|0)<=(E|0))}K=p?m:J;L=z;break};case 37:{if((k&6)!=2){i=0;w=1795;break L2124}if((F|0)==0){E=c[n+(m+1<<2)>>2]|0;t=E&63;if(!((t|0)==28|(t|0)==29|(t|0)==30|(t|0)==34)){i=0;w=1796;break L2124}if(E>>>0>=8388608){i=0;w=1760;break L2124}}if((v-2+F|0)<(h&255|0)){K=m;L=z}else{i=0;w=1761;break L2124}break};default:{K=m;L=z}}}while(0);if((w|0)==1723){w=0;v=m+1+F|0;K=((m|0)>=(v|0)|p|(v|0)>(e|0)?0:F)+m|0;L=z}v=K+1|0;if((v|0)<(e|0)){b=L;m=v}else{w=1750;break}}if((w|0)==1750){i=c[n+(L<<2)>>2]|0;return i|0}else if((w|0)==1754){return i|0}else if((w|0)==1755){return i|0}else if((w|0)==1760){return i|0}else if((w|0)==1761){return i|0}else if((w|0)==1763){return i|0}else if((w|0)==1764){return i|0}else if((w|0)==1765){return i|0}else if((w|0)==1766){return i|0}else if((w|0)==1767){return i|0}else if((w|0)==1768){return i|0}else if((w|0)==1769){return i|0}else if((w|0)==1770){return i|0}else if((w|0)==1771){return i|0}else if((w|0)==1772){return i|0}else if((w|0)==1773){return i|0}else if((w|0)==1774){return i|0}else if((w|0)==1775){return i|0}else if((w|0)==1776){return i|0}else if((w|0)==1777){return i|0}else if((w|0)==1778){return i|0}else if((w|0)==1779){return i|0}else if((w|0)==1780){return i|0}else if((w|0)==1781){return i|0}else if((w|0)==1782){return i|0}else if((w|0)==1783){return i|0}else if((w|0)==1784){return i|0}else if((w|0)==1785){return i|0}else if((w|0)==1786){return i|0}else if((w|0)==1787){return i|0}else if((w|0)==1788){return i|0}else if((w|0)==1789){return i|0}else if((w|0)==1790){return i|0}else if((w|0)==1791){return i|0}else if((w|0)==1792){return i|0}else if((w|0)==1793){return i|0}else if((w|0)==1794){return i|0}else if((w|0)==1795){return i|0}else if((w|0)==1796){return i|0}return 0}function eq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;e=i;i=i+8|0;f=e|0;c[f>>2]=0;g=c[872+(c[b+8>>2]<<2)>>2]|0;h=c[a+20>>2]|0;j=c[h+8>>2]|0;k=c[h>>2]|0;while(1){if(k>>>0>=j>>>0){break}if((k|0)==(b|0)){l=1800;break}else{k=k+16|0}}do{if((l|0)==1800){k=er(a,h,b-(c[a+12>>2]|0)>>4,f)|0;if((k|0)==0){break}j=c[f>>2]|0;es(a,2592,(m=i,i=i+32|0,c[m>>2]=d,c[m+8>>2]=k,c[m+16>>2]=j,c[m+24>>2]=g,m)|0);i=m;i=e;return}}while(0);es(a,8664,(m=i,i=i+16|0,c[m>>2]=d,c[m+8>>2]=g,m)|0);i=m;i=e;return}function er(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;g=d+4|0;h=b+20|0;i=b+24|0;b=d+12|0;j=e;L2260:while(1){e=c[g>>2]|0;if((c[e+8>>2]|0)!=6){k=0;l=1828;break}m=e;e=c[m>>2]|0;if((a[e+6|0]|0)!=0){k=0;l=1831;break}n=c[e+16>>2]|0;e=n;if((c[h>>2]|0)==(d|0)){o=c[i>>2]|0;c[b>>2]=o;p=o;q=c[(c[m>>2]|0)+16>>2]|0}else{p=c[b>>2]|0;q=n}m=(p-(c[q+12>>2]|0)>>2)-1|0;o=eT(e,j+1|0,m)|0;c[f>>2]=o;if((o|0)!=0){k=2944;l=1829;break}r=ep(e,m,j)|0;switch(r&63|0){case 4:{l=1820;break L2260;break};case 0:{break};case 5:{l=1814;break L2260;break};case 11:{l=1823;break L2260;break};case 6:{l=1816;break L2260;break};default:{k=0;l=1830;break L2260}}m=r>>>23;if(m>>>0<(r>>>6&255)>>>0){j=m}else{k=0;l=1832;break}}if((l|0)==1828){return k|0}else if((l|0)==1820){j=c[n+28>>2]|0;if((j|0)==0){s=10424}else{s=(c[j+(r>>>23<<2)>>2]|0)+16|0}c[f>>2]=s;k=10256;return k|0}else if((l|0)==1831){return k|0}else if((l|0)==1814){c[f>>2]=(c[(c[n+8>>2]|0)+(r>>>14<<4)>>2]|0)+16;k=2584;return k|0}else if((l|0)==1823){s=r>>>14;do{if((s&256|0)==0){t=10424}else{j=s&255;q=c[n+8>>2]|0;if((c[q+(j<<4)+8>>2]|0)!=4){t=10424;break}t=(c[q+(j<<4)>>2]|0)+16|0}}while(0);c[f>>2]=t;k=10008;return k|0}else if((l|0)==1830){return k|0}else if((l|0)==1832){return k|0}else if((l|0)==1829){return k|0}else if((l|0)==1816){l=r>>>14;do{if((l&256|0)==0){u=10424}else{r=l&255;t=c[n+8>>2]|0;if((c[t+(r<<4)+8>>2]|0)!=4){u=10424;break}u=(c[t+(r<<4)>>2]|0)+16|0}}while(0);c[f>>2]=u;k=2280;return k|0}return 0}function es(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;f=i;i=i+80|0;g=f+64|0;h=g;c[h>>2]=e;c[h+4>>2]=0;h=fx(b,d,g|0)|0;g=f|0;d=c[b+20>>2]|0;e=c[d+4>>2]|0;if((c[e+8>>2]|0)!=6){ew(b);i=f;return}j=e;if((a[(c[j>>2]|0)+6|0]|0)!=0){ew(b);i=f;return}e=c[b+24>>2]|0;c[d+12>>2]=e;d=c[(c[j>>2]|0)+16>>2]|0;j=(e-(c[d+12>>2]|0)>>2)-1|0;do{if((j|0)<0){k=-1}else{e=c[d+20>>2]|0;if((e|0)==0){k=0;break}k=c[e+(j<<2)>>2]|0}}while(0);fz(g,(c[d+32>>2]|0)+16|0,60);fy(b,3576,(d=i,i=i+24|0,c[d>>2]=g,c[d+8>>2]=k,c[d+16>>2]=h,d)|0)|0;i=d;ew(b);i=f;return}function et(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;i=i+8|0;f=e|0;g=((c[b+8>>2]|0)-3|0)>>>0<2?d:b;c[f>>2]=0;b=c[872+(c[g+8>>2]<<2)>>2]|0;d=c[a+20>>2]|0;h=c[d+8>>2]|0;j=c[d>>2]|0;while(1){if(j>>>0>=h>>>0){break}if((j|0)==(g|0)){k=1850;break}else{j=j+16|0}}do{if((k|0)==1850){j=er(a,d,g-(c[a+12>>2]|0)>>4,f)|0;if((j|0)==0){break}h=c[f>>2]|0;es(a,2592,(l=i,i=i+32|0,c[l>>2]=8264,c[l+8>>2]=j,c[l+16>>2]=h,c[l+24>>2]=b,l)|0);i=l;i=e;return}}while(0);es(a,8664,(l=i,i=i+16|0,c[l>>2]=8264,c[l+8>>2]=b,l)|0);i=l;i=e;return}function eu(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;i=i+24|0;f=e|0;g=(gk(b,e+8|0)|0)==0?b:d;c[f>>2]=0;d=c[872+(c[g+8>>2]<<2)>>2]|0;b=c[a+20>>2]|0;h=c[b+8>>2]|0;j=c[b>>2]|0;while(1){if(j>>>0>=h>>>0){break}if((j|0)==(g|0)){k=1859;break}else{j=j+16|0}}do{if((k|0)==1859){j=er(a,b,g-(c[a+12>>2]|0)>>4,f)|0;if((j|0)==0){break}h=c[f>>2]|0;es(a,2592,(l=i,i=i+32|0,c[l>>2]=6392,c[l+8>>2]=j,c[l+16>>2]=h,c[l+24>>2]=d,l)|0);i=l;i=e;return}}while(0);es(a,8664,(l=i,i=i+16|0,c[l>>2]=6392,c[l+8>>2]=d,l)|0);i=l;i=e;return}function ev(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=i;g=c[872+(c[d+8>>2]<<2)>>2]|0;d=c[872+(c[e+8>>2]<<2)>>2]|0;if((a[g+2|0]|0)==(a[d+2|0]|0)){es(b,4944,(h=i,i=i+8|0,c[h>>2]=g,h)|0);i=h;i=f;return 0}else{es(b,4104,(h=i,i=i+16|0,c[h>>2]=g,c[h+8>>2]=d,h)|0);i=h;i=f;return 0}return 0}function ew(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;b=c[a+116>>2]|0;if((b|0)==0){eC(a,2);return}d=c[a+32>>2]|0;e=d+(b+8)|0;if((c[e>>2]|0)!=6){eC(a,5)}f=a+8|0;g=c[f>>2]|0;h=g-16|0;i=g;j=c[h+4>>2]|0;c[i>>2]=c[h>>2];c[i+4>>2]=j;c[g+8>>2]=c[g-16+8>>2];g=c[f>>2]|0;j=d+b|0;b=g-16|0;d=c[j+4>>2]|0;c[b>>2]=c[j>>2];c[b+4>>2]=d;c[g-16+8>>2]=c[e>>2];e=c[f>>2]|0;if(((c[a+28>>2]|0)-e|0)<17){eA(a,1);k=c[f>>2]|0}else{k=e}c[f>>2]=k+16;eG(a,k-16|0,1);eC(a,2);return}function ex(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;e=i;i=i+48|0;f=1;g=0;h=i;i=i+168|0;c[h>>2]=0;while(1)switch(f|0){case 1:j=e|0;k=j+44|0;c[k>>2]=0;l=a+112|0;m=j|0;c[m>>2]=c[l>>2];c[l>>2]=j;n=j0(j+4|0,f,h)|0;f=4;break;case 4:if((n|0)==0){f=2;break}else{f=3;break};case 2:aj(b|0,a|0,d|0);if((r|0)!=0&(s|0)!=0){g=j1(c[r>>2]|0,h)|0;if((g|0)>0){f=-1;break}else return 0}r=s=0;f=3;break;case 3:c[l>>2]=c[m>>2];i=e;return c[k>>2]|0;case-1:if((g|0)==1){n=s;f=4}r=s=0;break}return 0}function ey(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=a+32|0;e=c[d>>2]|0;f=b+6|0;if((b+7|0)>>>0<268435456){g=a+44|0;h=fu(a,e,c[g>>2]<<4,f<<4)|0;i=g}else{h=fv(a)|0;i=a+44|0}g=h;c[d>>2]=g;c[i>>2]=f;c[a+28>>2]=g+(b<<4);b=a+8|0;f=e;c[b>>2]=g+((c[b>>2]|0)-f>>4<<4);b=c[a+104>>2]|0;do{if((b|0)!=0){e=b+8|0;c[e>>2]=g+((c[e>>2]|0)-f>>4<<4);e=c[b>>2]|0;if((e|0)==0){break}else{j=e}do{e=j+8|0;c[e>>2]=(c[d>>2]|0)+((c[e>>2]|0)-f>>4<<4);j=c[j>>2]|0;}while((j|0)!=0)}}while(0);j=c[a+40>>2]|0;b=a+20|0;if(j>>>0>(c[b>>2]|0)>>>0){k=a+12|0;l=c[k>>2]|0;m=l;n=m-f|0;o=n>>4;p=c[d>>2]|0;q=p+(o<<4)|0;c[k>>2]=q;return}else{r=j}do{j=r+8|0;c[j>>2]=(c[d>>2]|0)+((c[j>>2]|0)-f>>4<<4);j=r|0;c[j>>2]=(c[d>>2]|0)+((c[j>>2]|0)-f>>4<<4);j=r+4|0;c[j>>2]=(c[d>>2]|0)+((c[j>>2]|0)-f>>4<<4);r=r+24|0;}while(r>>>0<=(c[b>>2]|0)>>>0);k=a+12|0;l=c[k>>2]|0;m=l;n=m-f|0;o=n>>4;p=c[d>>2]|0;q=p+(o<<4)|0;c[k>>2]=q;return}function ez(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=a+40|0;e=c[d>>2]|0;if((b+1|0)>>>0<178956971){f=a+48|0;g=fu(a,e,(c[f>>2]|0)*24|0,b*24|0)|0;h=f}else{g=fv(a)|0;h=a+48|0}f=g;c[d>>2]=f;c[h>>2]=b;h=a+20|0;c[h>>2]=f+((((c[h>>2]|0)-e|0)/24|0)*24|0);c[a+36>>2]=f+((b-1|0)*24|0);return}function eA(a,b){a=a|0;b=b|0;var d=0;d=c[a+44>>2]|0;if((d|0)<(b|0)){ey(a,d+b|0);return}else{ey(a,d<<1);return}}function eB(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f=i;i=i+104|0;g=f|0;h=c[b+68>>2]|0;if((h|0)==0){i=f;return}j=b+57|0;if((a[j]|0)==0){i=f;return}k=b+8|0;l=b+32|0;m=c[k>>2]|0;n=c[l>>2]|0;o=m-n|0;p=b+20|0;q=c[p>>2]|0;r=(c[q+8>>2]|0)-n|0;c[g>>2]=d;c[g+20>>2]=e;if((d|0)==4){c[g+96>>2]=0}else{c[g+96>>2]=(q-(c[b+40>>2]|0)|0)/24|0}do{if(((c[b+28>>2]|0)-m|0)<321){q=c[b+44>>2]|0;if((q|0)<20){ey(b,q+20|0);break}else{ey(b,q<<1);break}}}while(0);c[(c[p>>2]|0)+8>>2]=(c[k>>2]|0)+320;a[j]=0;cf[h&511](b,g);a[j]=1;c[(c[p>>2]|0)+8>>2]=(c[l>>2]|0)+r;c[k>>2]=(c[l>>2]|0)+o;i=f;return}function eC(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;f=d+112|0;g=c[f>>2]|0;if((g|0)!=0){c[g+44>>2]=e;b0((c[f>>2]|0)+4|0,1)}a[d+6|0]=e&255;g=d+16|0;if((c[(c[g>>2]|0)+88>>2]|0)==0){a_(1)}h=d+40|0;i=c[h>>2]|0;j=d+20|0;c[j>>2]=i;k=c[i>>2]|0;i=d+12|0;c[i>>2]=k;eU(d,k);k=c[i>>2]|0;if((e|0)==4){c[k>>2]=f_(d,8280,17)|0;c[k+8>>2]=4}else if((e|0)==3|(e|0)==2){i=c[d+8>>2]|0;l=i-16|0;m=k;n=c[l+4>>2]|0;c[m>>2]=c[l>>2];c[m+4>>2]=n;c[k+8>>2]=c[i-16+8>>2]}else if((e|0)==5){c[k>>2]=f_(d,9920,23)|0;c[k+8>>2]=4}c[d+8>>2]=k+16;b[d+52>>1]=b[d+54>>1]|0;a[d+57|0]=1;k=d+48|0;e=c[k>>2]|0;do{if((e|0)>2e4){i=c[h>>2]|0;n=i;if(((((c[j>>2]|0)-n|0)/24|0)+1|0)>=2e4){break}m=fu(d,i,e*24|0,48e4)|0;i=m;c[h>>2]=i;c[k>>2]=2e4;c[j>>2]=i+((((c[j>>2]|0)-n|0)/24|0)*24|0);c[d+36>>2]=m+479976}}while(0);c[d+116>>2]=0;c[f>>2]=0;cd[c[(c[g>>2]|0)+88>>2]&1023](d)|0;a_(1)}function eD(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=b+56|0;if((a[e]&2)==0){f=d;g=b+20|0}else{h=b+32|0;i=d-(c[h>>2]|0)|0;eB(b,1,-1);d=b+20|0;j=c[d>>2]|0;L2409:do{if((a[(c[c[j+4>>2]>>2]|0)+6|0]|0)==0){if((a[e]&2)==0){break}k=j+20|0;l=c[k>>2]|0;c[k>>2]=l-1;if((l|0)==0){break}do{eB(b,4,-1);if((a[e]&2)==0){break L2409}l=(c[d>>2]|0)+20|0;k=c[l>>2]|0;c[l>>2]=k-1;}while((k|0)!=0)}}while(0);f=(c[h>>2]|0)+i|0;g=d}d=c[g>>2]|0;i=d-24|0;c[g>>2]=i;g=c[d+4>>2]|0;h=c[d+16>>2]|0;c[b+12>>2]=c[i>>2];c[b+24>>2]=c[d-24+12>>2];d=b+8|0;if((h|0)==0){m=g;c[d>>2]=m;n=h+1|0;return n|0}else{o=h;p=g;q=f}while(1){if(q>>>0>=(c[d>>2]|0)>>>0){break}f=p+16|0;g=q;b=p;i=c[g+4>>2]|0;c[b>>2]=c[g>>2];c[b+4>>2]=i;c[p+8>>2]=c[q+8>>2];i=o-1|0;if((i|0)==0){m=f;r=1946;break}else{o=i;p=f;q=q+16|0}}if((r|0)==1946){c[d>>2]=m;n=h+1|0;return n|0}if((o|0)>0){s=o;t=p}else{m=p;c[d>>2]=m;n=h+1|0;return n|0}while(1){r=s-1|0;c[t+8>>2]=0;if((r|0)>0){s=r;t=t+16|0}else{break}}m=p+(o<<4)|0;c[d>>2]=m;n=h+1|0;return n|0}function eE(e,f){e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;g=e+6|0;h=a[g]|0;if((h<<24>>24|0)==0){i=c[e+20>>2]|0;if((i|0)!=(c[e+40>>2]|0)){j=i;k=1951}}else if((h<<24>>24|0)!=1){j=c[e+20>>2]|0;k=1951}if((k|0)==1951){k=c[j>>2]|0;j=e+8|0;c[j>>2]=k;c[k>>2]=f_(e,6152,37)|0;c[k+8>>2]=4;do{if(((c[e+28>>2]|0)-(c[j>>2]|0)|0)<17){k=c[e+44>>2]|0;if((k|0)<1){ey(e,k+1|0);break}else{ey(e,k<<1);break}}}while(0);c[j>>2]=(c[j>>2]|0)+16;l=2;return l|0}j=e+52|0;k=b[j>>1]|0;if((k&65535)>199){h=c[c[e+20>>2]>>2]|0;i=e+8|0;c[i>>2]=h;c[h>>2]=f_(e,7968,16)|0;c[h+8>>2]=4;do{if(((c[e+28>>2]|0)-(c[i>>2]|0)|0)<17){h=c[e+44>>2]|0;if((h|0)<1){ey(e,h+1|0);break}else{ey(e,h<<1);break}}}while(0);c[i>>2]=(c[i>>2]|0)+16;l=2;return l|0}i=k+1&65535;b[j>>1]=i;b[e+54>>1]=i;i=e+8|0;k=ex(e,260,(c[i>>2]|0)+(-f<<4)|0)|0;if((k|0)==0){m=d[g]|0}else{a[g]=k&255;g=c[i>>2]|0;if((k|0)==4){c[g>>2]=f_(e,8280,17)|0;c[g+8>>2]=4}else if((k|0)==5){c[g>>2]=f_(e,9920,23)|0;c[g+8>>2]=4}else if((k|0)==3|(k|0)==2){f=g-16|0;h=g;n=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=n;c[g+8>>2]=c[g-16+8>>2]}n=g+16|0;c[i>>2]=n;c[(c[e+20>>2]|0)+8>>2]=n;m=k}b[j>>1]=(b[j>>1]|0)-1&65535;l=m;return l|0}function eF(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;g=i;if((c[e+8>>2]|0)==6){j=e;k=b+32|0}else{l=gg(b,e,16)|0;m=b+32|0;n=e-(c[m>>2]|0)|0;o=l+8|0;if((c[o>>2]|0)!=6){eq(b,e,2472)}p=b+8|0;q=c[p>>2]|0;if(q>>>0>e>>>0){r=q;while(1){s=r-16|0;t=s;u=r;v=c[t+4>>2]|0;c[u>>2]=c[t>>2];c[u+4>>2]=v;c[r+8>>2]=c[r-16+8>>2];if(s>>>0>e>>>0){r=s}else{break}}w=c[p>>2]|0}else{w=q}do{if(((c[b+28>>2]|0)-w|0)<17){q=c[b+44>>2]|0;if((q|0)<1){ey(b,q+1|0);break}else{ey(b,q<<1);break}}}while(0);c[p>>2]=(c[p>>2]|0)+16;p=c[m>>2]|0;w=p+n|0;q=l;l=w;r=c[q+4>>2]|0;c[l>>2]=c[q>>2];c[l+4>>2]=r;c[p+(n+8)>>2]=c[o>>2];j=w;k=m}m=j-(c[k>>2]|0)|0;w=c[j>>2]|0;j=b+24|0;o=b+20|0;c[(c[o>>2]|0)+12>>2]=c[j>>2];if((a[w+6|0]|0)!=0){n=b+8|0;do{if(((c[b+28>>2]|0)-(c[n>>2]|0)|0)<321){p=c[b+44>>2]|0;if((p|0)<20){ey(b,p+20|0);break}else{ey(b,p<<1);break}}}while(0);p=c[o>>2]|0;r=b+36|0;do{if((p|0)==(c[r>>2]|0)){l=b+48|0;q=c[l>>2]|0;if((q|0)>2e4){eC(b,5);return 0}e=q<<1;s=b+40|0;v=c[s>>2]|0;if((e|1)>>>0<178956971){x=fu(b,v,q*24|0,q*48|0)|0}else{x=fv(b)|0}q=x;c[s>>2]=q;c[l>>2]=e;l=q+((((c[o>>2]|0)-v|0)/24|0)*24|0)|0;c[o>>2]=l;c[r>>2]=q+((e-1|0)*24|0);if((e|0)<=2e4){y=l;break}es(b,3400,(z=i,i=i+1|0,i=i+7>>3<<3,c[z>>2]=0,z)|0);i=z;y=c[o>>2]|0}else{y=p}}while(0);p=y+24|0;c[o>>2]=p;r=c[k>>2]|0;c[y+28>>2]=r+m;x=r+(m+16)|0;c[p>>2]=x;c[b+12>>2]=x;c[y+32>>2]=(c[n>>2]|0)+320;c[y+40>>2]=f;if((a[b+56|0]&1)!=0){eB(b,0,-1)}y=cd[c[(c[c[(c[o>>2]|0)+4>>2]>>2]|0)+16>>2]&1023](b)|0;if((y|0)<0){A=2;i=g;return A|0}x=(c[n>>2]|0)+(-y<<4)|0;eD(b,x)|0;A=1;i=g;return A|0}x=c[w+16>>2]|0;w=x;y=b+28|0;n=b+8|0;p=w+75|0;r=d[p]|0;do{if(((c[y>>2]|0)-(c[n>>2]|0)|0)<=(r<<4|0)){l=c[b+44>>2]|0;if((l|0)<(r|0)){ey(b,l+r|0);break}else{ey(b,l<<1);break}}}while(0);r=c[k>>2]|0;l=r+m|0;e=l;q=w+74|0;v=a[q]|0;do{if(v<<24>>24==0){s=r+(m+16)|0;u=s+(d[w+73|0]<<4)|0;if((c[n>>2]|0)>>>0<=u>>>0){B=e;C=s;break}c[n>>2]=u;B=e;C=s}else{s=c[n>>2]|0;u=(s-l>>4)-1|0;t=a[w+73|0]|0;D=t&255;if((D|0)>(u|0)){E=u;F=s;while(1){c[n>>2]=F+16;c[F+8>>2]=0;s=E+1|0;if((s|0)>=(D|0)){break}E=s;F=c[n>>2]|0}G=D;H=a[q]|0}else{G=u;H=v}if((H&4)==0){I=0}else{F=G-D|0;E=c[b+16>>2]|0;if((c[E+68>>2]|0)>>>0>=(c[E+64>>2]|0)>>>0){e1(b)}E=d[p]|0;do{if(((c[y>>2]|0)-(c[n>>2]|0)|0)<=(E<<4|0)){s=c[b+44>>2]|0;if((s|0)<(E|0)){ey(b,s+E|0);break}else{ey(b,s<<1);break}}}while(0);E=f5(b,F,1)|0;if((F|0)>0){u=0;do{s=c[n>>2]|0;J=u-F|0;u=u+1|0;K=gc(b,E,u)|0;L=s+(J<<4)|0;M=K;N=c[L+4>>2]|0;c[M>>2]=c[L>>2];c[M+4>>2]=N;c[K+8>>2]=c[s+(J<<4)+8>>2];}while((u|0)<(F|0))}u=gd(b,E,f_(b,2864,1)|0)|0;h[u>>3]=+(F|0);c[u+8>>2]=3;I=E}u=c[n>>2]|0;do{if(t<<24>>24!=0){J=-G|0;c[n>>2]=u+16;s=u+(J<<4)|0;K=u;N=c[s+4>>2]|0;c[K>>2]=c[s>>2];c[K+4>>2]=N;N=u+(J<<4)+8|0;c[u+8>>2]=c[N>>2];c[N>>2]=0;if((t&255)>1){O=1}else{break}do{N=c[n>>2]|0;J=O-G|0;c[n>>2]=N+16;K=u+(J<<4)|0;s=N;M=c[K+4>>2]|0;c[s>>2]=c[K>>2];c[s+4>>2]=M;M=u+(J<<4)+8|0;c[N+8>>2]=c[M>>2];c[M>>2]=0;O=O+1|0;}while((O|0)<(D|0))}}while(0);if((I|0)!=0){D=c[n>>2]|0;c[n>>2]=D+16;c[D>>2]=I;c[D+8>>2]=5}B=(c[k>>2]|0)+m|0;C=u}}while(0);m=c[o>>2]|0;k=b+36|0;do{if((m|0)==(c[k>>2]|0)){I=b+48|0;O=c[I>>2]|0;if((O|0)>2e4){eC(b,5);return 0}G=O<<1;y=b+40|0;H=c[y>>2]|0;if((G|1)>>>0<178956971){P=fu(b,H,O*24|0,O*48|0)|0}else{P=fv(b)|0}O=P;c[y>>2]=O;c[I>>2]=G;I=O+((((c[o>>2]|0)-H|0)/24|0)*24|0)|0;c[o>>2]=I;c[k>>2]=O+((G-1|0)*24|0);if((G|0)<=2e4){Q=I;break}es(b,3400,(z=i,i=i+1|0,i=i+7>>3<<3,c[z>>2]=0,z)|0);i=z;Q=c[o>>2]|0}else{Q=m}}while(0);m=Q+24|0;c[o>>2]=m;c[Q+28>>2]=B;c[m>>2]=C;c[b+12>>2]=C;m=Q+32|0;c[m>>2]=C+(d[p]<<4);c[j>>2]=c[x+12>>2];c[Q+44>>2]=0;c[Q+40>>2]=f;f=c[n>>2]|0;Q=c[m>>2]|0;if(f>>>0<Q>>>0){x=f;while(1){c[x+8>>2]=0;f=x+16|0;p=c[m>>2]|0;if(f>>>0<p>>>0){x=f}else{R=p;break}}}else{R=Q}c[n>>2]=R;if((a[b+56|0]&1)==0){A=0;i=g;return A|0}c[j>>2]=(c[j>>2]|0)+4;eB(b,0,-1);c[j>>2]=(c[j>>2]|0)-4;A=0;i=g;return A|0}function eG(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0;f=i;g=a+52|0;h=(b[g>>1]|0)+1&65535;b[g>>1]=h;do{if((h&65535)>199){if(h<<16>>16==200){es(a,7968,(j=i,i=i+1|0,i=i+7>>3<<3,c[j>>2]=0,j)|0);i=j;break}if((h&65535)<=224){break}eC(a,5)}}while(0);if((eF(a,d,e)|0)==0){gr(a,1)}b[g>>1]=(b[g>>1]|0)-1&65535;g=c[a+16>>2]|0;if((c[g+68>>2]|0)>>>0<(c[g+64>>2]|0)>>>0){i=f;return}e1(a);i=f;return}function eH(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=d;f=b+20|0;g=b+6|0;do{if((a[g]|0)==0){if((eF(b,d-16|0,-1)|0)==0){break}return}else{h=c[f>>2]|0;a[g]=0;if((a[(c[c[h+4>>2]>>2]|0)+6|0]|0)==0){c[b+12>>2]=c[h>>2];break}if((eD(b,e)|0)==0){break}c[b+8>>2]=c[(c[f>>2]|0)+8>>2]}}while(0);gr(b,((c[f>>2]|0)-(c[b+40>>2]|0)|0)/24|0);return}function eI(b,d){b=b|0;d=d|0;var f=0,g=0;f=i;if((e[b+52>>1]|0)>(e[b+54>>1]|0)){es(b,4752,(g=i,i=i+1|0,i=i+7>>3<<3,c[g>>2]=0,g)|0);i=g}c[b+12>>2]=(c[b+8>>2]|0)+(-d<<4);a[b+6|0]=1;i=f;return-1|0}function eJ(d,e,f,g,h){d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;i=d+52|0;j=b[i>>1]|0;k=d+20|0;l=c[k>>2]|0;m=d+40|0;n=c[m>>2]|0;o=d+57|0;p=a[o]|0;q=d+116|0;r=c[q>>2]|0;c[q>>2]=h;h=ex(d,e,f)|0;if((h|0)==0){c[q>>2]=r;return h|0}f=l-n|0;n=c[d+32>>2]|0;l=n+g|0;eU(d,l);if((h|0)==4){c[l>>2]=f_(d,8280,17)|0;c[n+(g+8)>>2]=4}else if((h|0)==3|(h|0)==2){e=c[d+8>>2]|0;s=e-16|0;t=l;u=c[s+4>>2]|0;c[t>>2]=c[s>>2];c[t+4>>2]=u;c[n+(g+8)>>2]=c[e-16+8>>2]}else if((h|0)==5){c[l>>2]=f_(d,9920,23)|0;c[n+(g+8)>>2]=4}c[d+8>>2]=n+(g+16);b[i>>1]=j;j=c[m>>2]|0;i=j;g=i+f|0;c[k>>2]=g;c[d+12>>2]=c[g>>2];c[d+24>>2]=c[i+(f+12)>>2];a[o]=p;p=d+48|0;o=c[p>>2]|0;if((o|0)<=2e4){c[q>>2]=r;return h|0}f=j;if((((g-f|0)/24|0)+1|0)>=2e4){c[q>>2]=r;return h|0}g=fu(d,i,o*24|0,48e4)|0;o=g;c[m>>2]=o;c[p>>2]=2e4;c[k>>2]=o+((((c[k>>2]|0)-f|0)/24|0)*24|0);c[d+36>>2]=g+479976;c[q>>2]=r;return h|0}function eK(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=i;i=i+24|0;f=e|0;c[f>>2]=b;c[f+16>>2]=d;d=f+4|0;c[d>>2]=0;b=f+12|0;c[b>>2]=0;g=eJ(a,258,f,(c[a+8>>2]|0)-(c[a+32>>2]|0)|0,c[a+116>>2]|0)|0;fu(a,c[d>>2]|0,c[b>>2]|0,0)|0;i=e;return g|0}function eL(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;f=e;g=gv(c[f>>2]|0)|0;h=c[b+16>>2]|0;if((c[h+68>>2]|0)>>>0>=(c[h+64>>2]|0)>>>0){e1(b)}h=cg[((g|0)==27?256:258)&511](b,c[f>>2]|0,e+4|0,c[e+16>>2]|0)|0;e=h+72|0;f=eP(b,d[e]|0,c[b+72>>2]|0)|0;g=f;c[f+16>>2]=h;if((a[e]|0)!=0){h=0;do{c[g+20+(h<<2)>>2]=eQ(b)|0;h=h+1|0;}while((h|0)<(d[e]|0))}e=b+8|0;h=c[e>>2]|0;c[h>>2]=f;c[h+8>>2]=6;if(((c[b+28>>2]|0)-(c[e>>2]|0)|0)>=17){i=c[e>>2]|0;j=i+16|0;c[e>>2]=j;return}h=c[b+44>>2]|0;if((h|0)<1){ey(b,h+1|0);i=c[e>>2]|0;j=i+16|0;c[e>>2]=j;return}else{ey(b,h<<1);i=c[e>>2]|0;j=i+16|0;c[e>>2]=j;return}}function eM(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0;g=i;i=i+40|0;h=g+16|0;c[h>>2]=a;c[h+4>>2]=d;c[h+8>>2]=e;c[h+12>>2]=f;f=h+16|0;j=g|0;gj(j);c[f>>2]=cg[d&511](a,j,12,e)|0;eN(b,0,h);i=g;return c[f>>2]|0}function eN(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0;f=i;i=i+200|0;g=f|0;j=f+8|0;k=f+16|0;l=f+24|0;m=f+32|0;n=f+40|0;o=f+48|0;p=f+56|0;q=f+64|0;r=f+72|0;s=f+80|0;t=f+88|0;u=f+96|0;v=f+104|0;w=f+112|0;x=f+120|0;y=f+128|0;z=f+136|0;A=f+144|0;B=f+152|0;C=f+160|0;D=f+168|0;E=f+176|0;F=f+184|0;G=f+192|0;H=b+32|0;I=c[H>>2]|0;do{if((I|0)==(d|0)){J=w;K=x;L=2103}else{M=(c[e+12>>2]|0)==0?I:0;N=w;O=x;if((M|0)==0){J=N;K=O;L=2103;break}P=M+16|0;if((P|0)==0){J=N;K=O;L=2103;break}c[x>>2]=(c[M+12>>2]|0)+1;M=e+16|0;if((c[M>>2]|0)!=0){Q=N;R=O;break}S=e+4|0;T=e|0;U=e+8|0;V=cg[c[S>>2]&511](c[T>>2]|0,O,4,c[U>>2]|0)|0;c[M>>2]=V;if((V|0)!=0){Q=N;R=O;break}c[M>>2]=cg[c[S>>2]&511](c[T>>2]|0,P,c[x>>2]|0,c[U>>2]|0)|0;Q=N;R=O}}while(0);do{if((L|0)==2103){c[w>>2]=0;x=e+16|0;if((c[x>>2]|0)!=0){Q=J;R=K;break}c[x>>2]=cg[c[e+4>>2]&511](c[e>>2]|0,J,4,c[e+8>>2]|0)|0;Q=J;R=K}}while(0);c[v>>2]=c[b+60>>2];K=e+16|0;R=c[K>>2]|0;if((R|0)==0){J=cg[c[e+4>>2]&511](c[e>>2]|0,v,4,c[e+8>>2]|0)|0;c[K>>2]=J;W=J}else{W=R}c[u>>2]=c[b+64>>2];if((W|0)==0){R=cg[c[e+4>>2]&511](c[e>>2]|0,u,4,c[e+8>>2]|0)|0;c[K>>2]=R;X=R}else{X=W}a[t]=a[b+72|0]|0;if((X|0)==0){W=cg[c[e+4>>2]&511](c[e>>2]|0,t,1,c[e+8>>2]|0)|0;c[K>>2]=W;Y=W}else{Y=X}a[s]=a[b+73|0]|0;if((Y|0)==0){X=cg[c[e+4>>2]&511](c[e>>2]|0,s,1,c[e+8>>2]|0)|0;c[K>>2]=X;Z=X}else{Z=Y}a[r]=a[b+74|0]|0;if((Z|0)==0){Y=cg[c[e+4>>2]&511](c[e>>2]|0,r,1,c[e+8>>2]|0)|0;c[K>>2]=Y;_=Y}else{_=Z}a[q]=a[b+75|0]|0;if((_|0)==0){Z=cg[c[e+4>>2]&511](c[e>>2]|0,q,1,c[e+8>>2]|0)|0;c[K>>2]=Z;$=Z}else{$=_}_=c[b+12>>2]|0;Z=c[b+44>>2]|0;c[p>>2]=Z;do{if(($|0)==0){q=e+4|0;Y=e|0;r=e+8|0;X=cg[c[q>>2]&511](c[Y>>2]|0,p,4,c[r>>2]|0)|0;c[K>>2]=X;if((X|0)!=0){aa=X;L=2122;break}X=cg[c[q>>2]&511](c[Y>>2]|0,_,Z<<2,c[r>>2]|0)|0;c[K>>2]=X;r=c[b+40>>2]|0;c[o>>2]=r;if((X|0)!=0){ab=X;ac=r;break}X=cg[c[e+4>>2]&511](c[e>>2]|0,o,4,c[e+8>>2]|0)|0;c[K>>2]=X;ab=X;ac=r}else{aa=$;L=2122}}while(0);if((L|0)==2122){$=c[b+40>>2]|0;c[o>>2]=$;ab=aa;ac=$}if((ac|0)>0){$=b+8|0;aa=e+4|0;o=e|0;Z=e+8|0;_=j;p=k;r=l;X=0;Y=ab;while(1){q=c[$>>2]|0;s=q+(X<<4)|0;W=q+(X<<4)+8|0;q=c[W>>2]|0;a[n]=q&255;if((Y|0)==0){t=cg[c[aa>>2]&511](c[o>>2]|0,n,1,c[Z>>2]|0)|0;c[K>>2]=t;ad=t;ae=c[W>>2]|0}else{ad=Y;ae=q}L2679:do{if((ae|0)==3){h[l>>3]=+h[s>>3];if((ad|0)!=0){af=ad;break}q=cg[c[aa>>2]&511](c[o>>2]|0,r,8,c[Z>>2]|0)|0;c[K>>2]=q;af=q}else if((ae|0)==1){a[m]=c[s>>2]&255;if((ad|0)!=0){af=ad;break}q=cg[c[aa>>2]&511](c[o>>2]|0,m,1,c[Z>>2]|0)|0;c[K>>2]=q;af=q}else if((ae|0)==4){q=c[s>>2]|0;do{if((q|0)!=0){W=q+16|0;if((W|0)==0){break}c[k>>2]=(c[q+12>>2]|0)+1;if((ad|0)!=0){af=ad;break L2679}t=cg[c[aa>>2]&511](c[o>>2]|0,p,4,c[Z>>2]|0)|0;c[K>>2]=t;if((t|0)!=0){af=t;break L2679}t=cg[c[aa>>2]&511](c[o>>2]|0,W,c[k>>2]|0,c[Z>>2]|0)|0;c[K>>2]=t;af=t;break L2679}}while(0);c[j>>2]=0;if((ad|0)!=0){af=ad;break}q=cg[c[aa>>2]&511](c[o>>2]|0,_,4,c[Z>>2]|0)|0;c[K>>2]=q;af=q}else{af=ad}}while(0);s=X+1|0;if((s|0)<(ac|0)){X=s;Y=af}else{ag=af;break}}}else{ag=ab}ab=c[b+52>>2]|0;c[g>>2]=ab;if((ag|0)==0){c[K>>2]=cg[c[e+4>>2]&511](c[e>>2]|0,g,4,c[e+8>>2]|0)|0}if((ab|0)>0){g=b+16|0;ag=0;do{eN(c[(c[g>>2]|0)+(ag<<2)>>2]|0,c[H>>2]|0,e);ag=ag+1|0;}while((ag|0)<(ab|0))}ab=e+12|0;if((c[ab>>2]|0)==0){ah=c[b+48>>2]|0}else{ah=0}ag=c[b+20>>2]|0;c[G>>2]=ah;H=c[K>>2]|0;do{if((H|0)==0){g=e+4|0;af=e|0;Y=e+8|0;X=cg[c[g>>2]&511](c[af>>2]|0,G,4,c[Y>>2]|0)|0;c[K>>2]=X;if((X|0)!=0){ai=X;break}X=cg[c[g>>2]&511](c[af>>2]|0,ag,ah<<2,c[Y>>2]|0)|0;c[K>>2]=X;ai=X}else{ai=H}}while(0);if((c[ab>>2]|0)==0){aj=c[b+56>>2]|0}else{aj=0}c[F>>2]=aj;if((ai|0)==0){H=cg[c[e+4>>2]&511](c[e>>2]|0,F,4,c[e+8>>2]|0)|0;c[K>>2]=H;ak=H}else{ak=ai}if((aj|0)>0){ai=b+24|0;H=D;F=E;ah=e+4|0;ag=e|0;G=e+8|0;X=C;Y=B;af=0;g=ak;while(1){ac=c[(c[ai>>2]|0)+(af*12|0)>>2]|0;do{if((ac|0)==0){L=2160}else{ad=ac+16|0;if((ad|0)==0){L=2160;break}c[E>>2]=(c[ac+12>>2]|0)+1;if((g|0)!=0){al=g;break}Z=cg[c[ah>>2]&511](c[ag>>2]|0,F,4,c[G>>2]|0)|0;c[K>>2]=Z;if((Z|0)!=0){al=Z;break}Z=cg[c[ah>>2]&511](c[ag>>2]|0,ad,c[E>>2]|0,c[G>>2]|0)|0;c[K>>2]=Z;al=Z}}while(0);do{if((L|0)==2160){L=0;c[D>>2]=0;if((g|0)!=0){al=g;break}ac=cg[c[ah>>2]&511](c[ag>>2]|0,H,4,c[G>>2]|0)|0;c[K>>2]=ac;al=ac}}while(0);ac=c[ai>>2]|0;c[C>>2]=c[ac+(af*12|0)+4>>2];if((al|0)==0){Z=cg[c[ah>>2]&511](c[ag>>2]|0,X,4,c[G>>2]|0)|0;c[K>>2]=Z;am=c[ai>>2]|0;an=Z}else{am=ac;an=al}c[B>>2]=c[am+(af*12|0)+8>>2];if((an|0)==0){ac=cg[c[ah>>2]&511](c[ag>>2]|0,Y,4,c[G>>2]|0)|0;c[K>>2]=ac;ao=ac}else{ao=an}ac=af+1|0;if((ac|0)<(aj|0)){af=ac;g=ao}else{ap=ao;break}}}else{ap=ak}if((c[ab>>2]|0)==0){aq=c[b+36>>2]|0}else{aq=0}c[A>>2]=aq;if((ap|0)==0){ab=cg[c[e+4>>2]&511](c[e>>2]|0,A,4,c[e+8>>2]|0)|0;c[K>>2]=ab;ar=ab}else{ar=ap}if((aq|0)<=0){i=f;return}ap=b+28|0;b=y;ab=z;A=e+4|0;ak=e|0;ao=e+8|0;e=0;g=ar;while(1){ar=c[(c[ap>>2]|0)+(e<<2)>>2]|0;do{if((ar|0)==0){L=2178}else{af=ar+16|0;if((af|0)==0){L=2178;break}c[z>>2]=(c[ar+12>>2]|0)+1;if((g|0)!=0){as=g;break}aj=cg[c[A>>2]&511](c[ak>>2]|0,ab,4,c[ao>>2]|0)|0;c[K>>2]=aj;if((aj|0)!=0){as=aj;break}aj=cg[c[A>>2]&511](c[ak>>2]|0,af,c[z>>2]|0,c[ao>>2]|0)|0;c[K>>2]=aj;as=aj}}while(0);do{if((L|0)==2178){L=0;c[y>>2]=0;if((g|0)!=0){as=g;break}ar=cg[c[A>>2]&511](c[ak>>2]|0,b,4,c[ao>>2]|0)|0;c[K>>2]=ar;as=ar}}while(0);ar=e+1|0;if((ar|0)<(aq|0)){e=ar;g=as}else{break}}i=f;return}function eO(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=fu(b,0,0,(d<<4)+24|0)|0;e3(b,f,6);a[f+6|0]=1;c[f+12>>2]=e;a[f+7|0]=d&255;return f|0}function eP(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;f=fu(b,0,0,(d<<2)+20|0)|0;g=f;e3(b,f,6);a[f+6|0]=0;c[f+12>>2]=e;a[f+7|0]=d&255;if((d|0)==0){return g|0}e=f+20|0;f=d;do{f=f-1|0;c[e+(f<<2)>>2]=0;}while((f|0)!=0);return g|0}function eQ(a){a=a|0;var b=0;b=fu(a,0,0,32)|0;e3(a,b,10);c[b+8>>2]=b+16;c[b+24>>2]=0;return b|0}function eR(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0;f=c[b+16>>2]|0;g=b+104|0;while(1){h=c[g>>2]|0;if((h|0)==0){i=2201;break}j=c[h+8>>2]|0;if(j>>>0<e>>>0){i=2201;break}k=h;if((j|0)==(e|0)){break}else{g=h|0}}if((i|0)==2201){i=fu(b,0,0,32)|0;b=i;a[i+4|0]=10;a[i+5|0]=a[f+20|0]&3;c[i+8>>2]=e;c[i>>2]=c[g>>2];c[g>>2]=i;c[i+16>>2]=f+120;g=f+140|0;e=c[g>>2]|0;c[i+20>>2]=e;c[e+16>>2]=b;c[g>>2]=b;l=b;return l|0}b=h+5|0;h=a[b]|0;if((h&3&((d[f+20|0]|0)^3)|0)==0){l=k;return l|0}a[b]=h^3;l=k;return l|0}function eS(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;if((c[b+8>>2]|0)==(b+16|0)){d=b;e=fu(a,d,32,0)|0;return}f=b+16|0;g=f;h=f+4|0;c[(c[h>>2]|0)+16>>2]=c[g>>2];c[(c[g>>2]|0)+20>>2]=c[h>>2];d=b;e=fu(a,d,32,0)|0;return}function eT(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=c[a+56>>2]|0;if((e|0)<=0){f=0;return f|0}g=c[a+24>>2]|0;a=b;b=0;while(1){if((c[g+(b*12|0)+4>>2]|0)>(d|0)){f=0;h=2220;break}if((c[g+(b*12|0)+8>>2]|0)>(d|0)){i=a-1|0;if((i|0)==0){h=2216;break}else{j=i}}else{j=a}i=b+1|0;if((i|0)<(e|0)){a=j;b=i}else{f=0;h=2219;break}}if((h|0)==2216){f=(c[g+(b*12|0)>>2]|0)+16|0;return f|0}else if((h|0)==2220){return f|0}else if((h|0)==2219){return f|0}return 0}function eU(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;f=b+104|0;g=c[f>>2]|0;if((g|0)==0){return}h=(c[b+16>>2]|0)+20|0;i=g;while(1){g=i+8|0;if((c[g>>2]|0)>>>0<e>>>0){j=2234;break}c[f>>2]=c[i>>2];if((a[i+5|0]&3&((d[h]|0)^3)|0)==0){k=i+16|0;l=k+4|0;c[(c[l>>2]|0)+16>>2]=c[k>>2];c[(c[k>>2]|0)+20>>2]=c[l>>2];l=c[g>>2]|0;m=l;n=k;o=c[m+4>>2]|0;c[n>>2]=c[m>>2];c[n+4>>2]=o;c[k+8>>2]=c[l+8>>2];c[g>>2]=k;e9(b,i)}else{k=i+16|0;if((c[g>>2]|0)!=(k|0)){g=k+4|0;c[(c[g>>2]|0)+16>>2]=c[k>>2];c[(c[k>>2]|0)+20>>2]=c[g>>2]}g=i;fu(b,g,32,0)|0}g=c[f>>2]|0;if((g|0)==0){j=2235;break}else{i=g}}if((j|0)==2235){return}else if((j|0)==2234){return}}function eV(b){b=b|0;var c=0;c=fu(b,0,0,76)|0;e3(b,c,9);j2(c+8|0,0,60);b=c+72|0;w=0;a[b]=w&255;w=w>>8;a[b+1|0]=w&255;w=w>>8;a[b+2|0]=w&255;w=w>>8;a[b+3|0]=w&255;return c|0}function eW(a,b){a=a|0;b=b|0;fu(a,c[b+12>>2]|0,c[b+44>>2]<<2,0)|0;fu(a,c[b+16>>2]|0,c[b+52>>2]<<2,0)|0;fu(a,c[b+8>>2]|0,c[b+40>>2]<<4,0)|0;fu(a,c[b+20>>2]|0,c[b+48>>2]<<2,0)|0;fu(a,c[b+24>>2]|0,(c[b+56>>2]|0)*12|0,0)|0;fu(a,c[b+28>>2]|0,c[b+36>>2]<<2,0)|0;fu(a,b,76,0)|0;return}function eX(b,c){b=b|0;c=c|0;var e=0,f=0;e=d[c+7|0]|0;if((a[c+6|0]|0)==0){f=(e<<2)+20|0}else{f=(e<<4)+24|0}fu(b,c,f,0)|0;return}function eY(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=b+16|0;b=c[e>>2]|0;f=c[b+112>>2]|0;g=c[f>>2]|0;if((g|0)==0){h=0;return h|0}i=(d|0)==0;d=b+48|0;b=f;f=0;j=g;L2826:while(1){L2828:do{if(i){g=f;k=j;while(1){l=k+5|0;m=a[l]|0;if(!((m&3)!=0&(m&8)==0)){n=g;o=k;break L2828}m=c[k+8>>2]|0;p=m;if((m|0)==0){q=g;r=k;s=l;t=2258;break L2828}if((a[p+6|0]&4)!=0){q=g;r=k;s=l;t=2258;break L2828}if((gf(p,2,c[(c[e>>2]|0)+196>>2]|0)|0)==0){q=g;r=k;s=l;t=2258;break L2828}p=g+24+(c[k+16>>2]|0)|0;a[l]=a[l]|8;l=k|0;c[b>>2]=c[l>>2];m=c[d>>2]|0;if((m|0)==0){c[l>>2]=k}else{c[l>>2]=c[m>>2];c[c[d>>2]>>2]=k}c[d>>2]=k;m=c[b>>2]|0;if((m|0)==0){h=p;t=2265;break L2826}else{g=p;k=m}}}else{k=f;g=j;while(1){m=g+5|0;if((a[m]&8)!=0){n=k;o=g;break L2828}p=c[g+8>>2]|0;l=p;if((p|0)==0){q=k;r=g;s=m;t=2258;break L2828}if((a[l+6|0]&4)!=0){q=k;r=g;s=m;t=2258;break L2828}if((gf(l,2,c[(c[e>>2]|0)+196>>2]|0)|0)==0){q=k;r=g;s=m;t=2258;break L2828}l=k+24+(c[g+16>>2]|0)|0;a[m]=a[m]|8;m=g|0;c[b>>2]=c[m>>2];p=c[d>>2]|0;if((p|0)==0){c[m>>2]=g}else{c[m>>2]=c[p>>2];c[c[d>>2]>>2]=g}c[d>>2]=g;p=c[b>>2]|0;if((p|0)==0){h=l;t=2266;break L2826}else{k=l;g=p}}}}while(0);if((t|0)==2258){t=0;a[s]=a[s]|8;n=q;o=r}g=o|0;k=c[g>>2]|0;if((k|0)==0){h=n;t=2267;break}else{b=g;f=n;j=k}}if((t|0)==2266){return h|0}else if((t|0)==2267){return h|0}else if((t|0)==2265){return h|0}return 0}function eZ(a){a=a|0;var b=0;b=a+16|0;if((c[(c[b>>2]|0)+48>>2]|0)==0){return}do{e_(a);}while((c[(c[b>>2]|0)+48>>2]|0)!=0);return}function e_(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;d=b+16|0;e=c[d>>2]|0;f=e+48|0;g=c[f>>2]|0;h=g|0;i=c[h>>2]|0;if((i|0)==(g|0)){c[f>>2]=0;j=i|0}else{f=i|0;c[h>>2]=c[f>>2];j=f}f=e+112|0;c[j>>2]=c[c[f>>2]>>2];c[c[f>>2]>>2]=i;f=i+5|0;a[f]=a[e+20|0]&3|a[f]&-8;f=c[i+8>>2]|0;j=f;if((f|0)==0){return}if((a[j+6|0]&4)!=0){return}f=gf(j,2,c[(c[d>>2]|0)+196>>2]|0)|0;if((f|0)==0){return}d=b+57|0;j=a[d]|0;h=e+64|0;g=c[h>>2]|0;a[d]=0;c[h>>2]=c[e+68>>2]<<1;e=b+8|0;k=c[e>>2]|0;l=f;m=k;n=c[l+4>>2]|0;c[m>>2]=c[l>>2];c[m+4>>2]=n;c[k+8>>2]=c[f+8>>2];f=c[e>>2]|0;c[f+16>>2]=i;c[f+24>>2]=7;f=c[e>>2]|0;c[e>>2]=f+32;eG(b,f,0);a[d]=j;c[h>>2]=g;return}function e$(b){b=b|0;var d=0,e=0,f=0;d=c[b+16>>2]|0;a[d+20|0]=67;e0(b,d+28|0,-3)|0;e=d+8|0;if((c[e>>2]|0)<=0){return}f=d|0;d=0;do{e0(b,(c[f>>2]|0)+(d<<2)|0,-3)|0;d=d+1|0;}while((d|0)<(c[e>>2]|0));return}function e0(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;g=b+16|0;h=c[g>>2]|0;i=h+20|0;j=d[i]^3;k=c[e>>2]|0;if((k|0)==0){l=e;return l|0}m=h+28|0;h=f;f=e;e=k;while(1){k=h-1|0;if((h|0)==0){l=f;n=2310;break}o=e+4|0;if((a[o]|0)==8){p=e+104|0;e0(b,p,-3)|0}p=e+5|0;q=a[p]|0;L2894:do{if(((q&255^3)&j|0)==0){r=e|0;c[f>>2]=c[r>>2];if((e|0)==(c[m>>2]|0)){c[m>>2]=c[r>>2]}switch(d[o]|0){case 5:{f7(b,e);s=f;break L2894;break};case 4:{r=(c[g>>2]|0)+4|0;c[r>>2]=(c[r>>2]|0)-1;fu(b,e,(c[e+12>>2]|0)+17|0,0)|0;s=f;break L2894;break};case 7:{fu(b,e,(c[e+16>>2]|0)+24|0,0)|0;s=f;break L2894;break};case 9:{eW(b,e);s=f;break L2894;break};case 6:{eX(b,e);s=f;break L2894;break};case 8:{fU(b,e|0);s=f;break L2894;break};case 10:{eS(b,e);s=f;break L2894;break};default:{s=f;break L2894}}}else{a[p]=a[i]&3|q&-8;s=e|0}}while(0);q=c[s>>2]|0;if((q|0)==0){l=s;n=2312;break}else{h=k;f=s;e=q}}if((n|0)==2310){return l|0}else if((n|0)==2312){return l|0}return 0}function e1(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;d=c[b+16>>2]|0;e=(c[d+84>>2]|0)*10|0;f=d+68|0;g=d+64|0;h=d+76|0;c[h>>2]=(c[f>>2]|0)-(c[g>>2]|0)+(c[h>>2]|0);i=d+21|0;j=(e|0)==0?2147483646:e;do{j=j-(e4(b)|0)|0;k=a[i]|0;}while(k<<24>>24!=0&(j|0)>0);if(k<<24>>24==0){c[g>>2]=aa(c[d+80>>2]|0,((c[d+72>>2]|0)>>>0)/100|0)|0;return}d=c[h>>2]|0;if(d>>>0<1024){c[g>>2]=(c[f>>2]|0)+1024;return}else{c[h>>2]=d-1024;c[g>>2]=c[f>>2];return}}function e2(b,d){b=b|0;d=d|0;var e=0;e=c[b+16>>2]|0;b=d+5|0;a[b]=a[b]&-5;b=e+40|0;c[d+24>>2]=c[b>>2];c[b>>2]=d;return}function e3(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=c[b+16>>2]|0;b=f+28|0;c[d>>2]=c[b>>2];c[b>>2]=d;a[d+5|0]=a[f+20|0]&3;a[d+4|0]=e;return}function e4(b){b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;e=b+16|0;f=c[e>>2]|0;g=f+21|0;switch(d[g]|0|0){case 0:{e6(b);h=0;return h|0};case 1:{i=f+36|0;if((c[i>>2]|0)!=0){h=fb(f)|0;return h|0}j=f+120|0;k=c[f+140>>2]|0;do{if((k|0)!=(j|0)){l=k;do{do{if((a[l+5|0]&7)==0){m=c[l+8>>2]|0;if((c[m+8>>2]|0)<=3){break}n=c[m>>2]|0;if((a[n+5|0]&3)==0){break}e8(f,n)}}while(0);l=c[l+20>>2]|0;}while((l|0)!=(j|0));if((c[i>>2]|0)==0){break}do{fb(f)|0;}while((c[i>>2]|0)!=0)}}while(0);j=f+44|0;c[i>>2]=c[j>>2];c[j>>2]=0;if((a[b+5|0]&3)!=0){e8(f,b)}fa(f);if((c[i>>2]|0)!=0){do{fb(f)|0;}while((c[i>>2]|0)!=0)}k=f+40|0;l=c[k>>2]|0;c[i>>2]=l;c[k>>2]=0;if((l|0)!=0){do{fb(f)|0;}while((c[i>>2]|0)!=0)}l=eY(b,0)|0;k=f+48|0;n=c[k>>2]|0;if((n|0)!=0){m=f+20|0;o=n;do{o=c[o>>2]|0;n=o+5|0;a[n]=a[m]&3|a[n]&-8;e8(f,o);}while((o|0)!=(c[k>>2]|0))}if((c[i>>2]|0)==0){p=0}else{k=0;while(1){o=(fb(f)|0)+k|0;if((c[i>>2]|0)==0){p=o;break}else{k=o}}}k=c[j>>2]|0;if((k|0)!=0){j=k;do{k=j;i=c[j+28>>2]|0;if(!((a[j+5|0]&16)==0|(i|0)==0)){o=j+12|0;m=i;do{m=m-1|0;i=c[o>>2]|0;n=i+(m<<4)+8|0;q=c[n>>2]|0;do{if((q|0)>3){r=(c[i+(m<<4)>>2]|0)+5|0;s=a[r]|0;if((q|0)==4){a[r]=s&-4;break}if((s&3)==0){if((q|0)!=7){break}if((s&8)==0){break}}c[n>>2]=0}}while(0);}while((m|0)!=0)}m=j+16|0;o=1<<(d[k+7|0]|0);do{o=o-1|0;n=c[m>>2]|0;q=n+(o<<5)|0;i=n+(o<<5)+8|0;s=c[i>>2]|0;L2988:do{if((s|0)!=0){r=n+(o<<5)+24|0;t=c[r>>2]|0;do{if((t|0)>3){u=(c[n+(o<<5)+16>>2]|0)+5|0;v=a[u]|0;if((t|0)==4){a[u]=v&-4;w=c[i>>2]|0;x=2367;break}else{if((v&3)==0){w=s;x=2367;break}else{break}}}else{w=s;x=2367}}while(0);do{if((x|0)==2367){x=0;if((w|0)<=3){break L2988}t=(c[q>>2]|0)+5|0;v=a[t]|0;if((w|0)==4){a[t]=v&-4;break L2988}if((v&3)!=0){break}if((w|0)!=7){break L2988}if((v&8)==0){break L2988}}}while(0);c[i>>2]=0;if((c[r>>2]|0)<=3){break}c[r>>2]=11}}while(0);}while((o|0)!=0);j=c[j+24>>2]|0;}while((j|0)!=0)}j=f+20|0;a[j]=a[j]^3;c[f+24>>2]=0;c[f+32>>2]=f+28;a[g]=2;c[f+72>>2]=(c[f+68>>2]|0)-(p+l);h=0;return h|0};case 4:{if((c[f+48>>2]|0)==0){a[g]=0;c[f+76>>2]=0;h=0;return h|0}e_(b);l=f+72|0;p=c[l>>2]|0;if(p>>>0<=100){h=100;return h|0}c[l>>2]=p-100;h=100;return h|0};case 2:{p=f+68|0;l=c[p>>2]|0;j=f+24|0;w=c[j>>2]|0;c[j>>2]=w+1;e0(b,(c[f>>2]|0)+(w<<2)|0,-3)|0;if((c[j>>2]|0)>=(c[f+8>>2]|0)){a[g]=3}j=f+72|0;c[j>>2]=(c[p>>2]|0)-l+(c[j>>2]|0);h=10;return h|0};case 3:{j=f+68|0;l=c[j>>2]|0;p=f+32|0;w=e0(b,c[p>>2]|0,40)|0;c[p>>2]=w;if((c[w>>2]|0)==0){w=c[e>>2]|0;e=c[w+8>>2]|0;if((c[w+4>>2]|0)>>>0<((e|0)/4|0)>>>0&(e|0)>64){fZ(b,(e|0)/2|0)}e=w+52|0;p=w+60|0;w=c[p>>2]|0;if(w>>>0>64){x=w>>>1;if((x+1|0)>>>0<4294967294){o=e|0;y=fu(b,c[o>>2]|0,w,x)|0;z=o}else{y=fv(b)|0;z=e|0}c[z>>2]=y;c[p>>2]=x}a[g]=4}g=f+72|0;c[g>>2]=(c[j>>2]|0)-l+(c[g>>2]|0);h=400;return h|0};default:{h=0;return h|0}}return 0}function e5(b){b=b|0;var d=0,e=0,f=0,g=0;d=c[b+16>>2]|0;e=d+21|0;f=a[e]|0;if((f&255)<2){c[d+24>>2]=0;c[d+32>>2]=d+28;c[d+36>>2]=0;c[d+40>>2]=0;c[d+44>>2]=0;a[e]=2;g=2407}else{if(f<<24>>24!=4){g=2407}}if((g|0)==2407){while(1){g=0;e4(b)|0;if((a[e]|0)==4){break}else{g=2407}}}e6(b);if((a[e]|0)!=0){do{e4(b)|0;}while((a[e]|0)!=0)}c[d+64>>2]=aa(c[d+80>>2]|0,((c[d+72>>2]|0)>>>0)/100|0)|0;return}function e6(b){b=b|0;var d=0,e=0,f=0,g=0,h=0;d=b+16|0;b=c[d>>2]|0;c[b+36>>2]=0;c[b+40>>2]=0;c[b+44>>2]=0;e=b+112|0;f=c[e>>2]|0;if((a[f+5|0]&3)==0){g=f}else{e8(b,f);g=c[e>>2]|0}do{if((c[g+80>>2]|0)>3){e=c[g+72>>2]|0;if((a[e+5|0]&3)==0){break}e8(b,e)}}while(0);g=c[d>>2]|0;if((c[g+104>>2]|0)<=3){fa(b);h=b+21|0;a[h]=1;return}d=c[g+96>>2]|0;if((a[d+5|0]&3)==0){fa(b);h=b+21|0;a[h]=1;return}e8(b,d);fa(b);h=b+21|0;a[h]=1;return}function e7(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=c[b+16>>2]|0;if((a[f+21|0]|0)==1){e8(f,e);return}else{e=d+5|0;a[e]=a[f+20|0]&3|a[e]&-8;return}}function e8(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;f=e;L3073:while(1){g=f+5|0;e=a[g]&-4;a[g]=e;switch(d[f+4|0]|0|0){case 7:{break};case 5:{h=2442;break L3073;break};case 6:{h=2441;break L3073;break};case 9:{h=2444;break L3073;break};case 8:{h=2443;break L3073;break};case 10:{h=2436;break L3073;break};default:{h=2446;break L3073}}i=c[f+8>>2]|0;a[g]=e|4;do{if((i|0)!=0){if((a[i+5|0]&3)==0){break}e8(b,i)}}while(0);i=c[f+12>>2]|0;if((a[i+5|0]&3)==0){h=2448;break}f=i}if((h|0)==2442){i=b+36|0;c[f+24>>2]=c[i>>2];c[i>>2]=f;return}else if((h|0)==2441){i=b+36|0;c[f+8>>2]=c[i>>2];c[i>>2]=f;return}else if((h|0)==2444){i=b+36|0;c[f+68>>2]=c[i>>2];c[i>>2]=f;return}else if((h|0)==2443){i=b+36|0;c[f+108>>2]=c[i>>2];c[i>>2]=f;return}else if((h|0)==2436){i=f+8|0;e=c[i>>2]|0;do{if((c[e+8>>2]|0)>3){j=c[e>>2]|0;if((a[j+5|0]&3)==0){k=e;break}e8(b,j);k=c[i>>2]|0}else{k=e}}while(0);if((k|0)!=(f+16|0)){return}a[g]=a[g]|4;return}else if((h|0)==2446){return}else if((h|0)==2448){return}}function e9(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;e=b+16|0;b=c[e>>2]|0;f=b+28|0;c[d>>2]=c[f>>2];c[f>>2]=d;f=d+5|0;g=a[f]|0;if((g&7)!=0){return}if((a[b+21|0]|0)!=1){a[f]=a[b+20|0]&3|g&-8;return}a[f]=g|4;b=c[d+8>>2]|0;if((c[b+8>>2]|0)<=3){return}d=c[b>>2]|0;if((a[d+5|0]&3)==0){return}b=c[e>>2]|0;if((a[b+21|0]|0)==1){e8(b,d);return}else{a[f]=a[b+20|0]&3|g&-8;return}}function fa(b){b=b|0;var d=0;d=c[b+152>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+156>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+160>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+164>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+168>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+172>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+176>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+180>>2]|0;do{if((d|0)!=0){if((a[d+5|0]&3)==0){break}e8(b,d)}}while(0);d=c[b+184>>2]|0;if((d|0)==0){return}if((a[d+5|0]&3)==0){return}e8(b,d);return}function fb(b){b=b|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0;e=b+36|0;f=c[e>>2]|0;g=f+5|0;a[g]=a[g]|4;h=d[f+4|0]|0;if((h|0)==5){i=f;j=f+24|0;c[e>>2]=c[j>>2];k=f+8|0;l=c[k>>2]|0;m=l;do{if((l|0)==0){n=0;o=2512}else{if((a[m+5|0]&3)==0){p=m}else{e8(b,l);q=c[k>>2]|0;if((q|0)==0){n=0;o=2512;break}else{p=q}}if((a[p+6|0]&8)!=0){n=0;o=2512;break}q=gf(p,3,c[b+200>>2]|0)|0;if((q|0)==0){n=0;o=2512;break}if((c[q+8>>2]|0)!=4){n=0;o=2512;break}r=(c[q>>2]|0)+16|0;q=(aU(r|0,107)|0)!=0;s=(aU(r|0,118)|0)!=0;r=s&1;if(q|s){a[g]=(r<<4|(q&1)<<3|a[g]&-25&255)&255;t=b+44|0;c[j>>2]=c[t>>2];c[t>>2]=f}if(q&s){u=i+7|0;o=2541;break}else{if(s){v=q;w=r;x=1;o=2518;break}else{n=q;o=2512;break}}}}while(0);do{if((o|0)==2512){j=c[f+28>>2]|0;if((j|0)==0){v=n;w=0;x=0;o=2518;break}p=f+12|0;k=j;while(1){j=k-1|0;l=c[p>>2]|0;do{if((c[l+(j<<4)+8>>2]|0)>3){m=c[l+(j<<4)>>2]|0;if((a[m+5|0]&3)==0){break}e8(b,m)}}while(0);if((j|0)==0){v=n;w=0;x=0;o=2518;break}else{k=j}}}}while(0);if((o|0)==2518){n=i+7|0;i=(1<<d[n])-1|0;k=f+16|0;L3188:do{if(v){p=x^1;l=i;while(1){m=c[k>>2]|0;q=m+(l<<5)|0;r=c[m+(l<<5)+8>>2]|0;do{if((r|0)==0){s=m+(l<<5)+24|0;if((c[s>>2]|0)<=3){break}c[s>>2]=11}else{if(!((r|0)>3&p)){break}s=c[q>>2]|0;if((a[s+5|0]&3)==0){break}e8(b,s)}}while(0);if((l|0)==0){break L3188}l=l-1|0}}else{l=i;while(1){p=c[k>>2]|0;q=p+(l<<5)|0;r=p+(l<<5)+8|0;m=p+(l<<5)+24|0;j=(c[m>>2]|0)>3;do{if((c[r>>2]|0)==0){if(!j){break}c[m>>2]=11}else{do{if(j){s=c[p+(l<<5)+16>>2]|0;if((a[s+5|0]&3)==0){break}e8(b,s)}}while(0);if(x){break}if((c[r>>2]|0)<=3){break}s=c[q>>2]|0;if((a[s+5|0]&3)==0){break}e8(b,s)}}while(0);if((l|0)==0){break L3188}l=l-1|0}}}while(0);if((w|0)==0&(v^1)){y=n}else{u=n;o=2541}}if((o|0)==2541){a[g]=a[g]&-5;y=u}z=(c[f+28>>2]<<4)+32+(32<<d[y])|0;return z|0}else if((h|0)==6){y=f;c[e>>2]=c[f+8>>2];u=c[f+12>>2]|0;if((a[u+5|0]&3)!=0){e8(b,u)}u=f+6|0;do{if((a[u]|0)==0){o=f;n=c[f+16>>2]|0;if((a[n+5|0]&3)!=0){e8(b,n)}n=y+7|0;v=a[n]|0;if(v<<24>>24==0){A=0;break}else{B=0;C=v}while(1){v=c[o+20+(B<<2)>>2]|0;if((a[v+5|0]&3)==0){D=C}else{e8(b,v);D=a[n]|0}v=B+1|0;if((v|0)<(D&255|0)){B=v;C=D}else{A=D;break}}}else{n=y+7|0;o=a[n]|0;if(o<<24>>24==0){A=0;break}else{E=0;F=o}while(1){do{if((c[y+24+(E<<4)+8>>2]|0)>3){o=c[y+24+(E<<4)>>2]|0;if((a[o+5|0]&3)==0){G=F;break}e8(b,o);G=a[n]|0}else{G=F}}while(0);o=E+1|0;if((o|0)<(G&255|0)){E=o;F=G}else{A=G;break}}}}while(0);G=A&255;if((a[u]|0)==0){z=(G<<2)+20|0;return z|0}else{z=(G<<4)+24|0;return z|0}}else if((h|0)==8){G=f|0;u=f+108|0;c[e>>2]=c[u>>2];A=b+40|0;c[u>>2]=c[A>>2];c[A>>2]=f;a[g]=a[g]&-5;do{if((c[f+80>>2]|0)>3){g=c[f+72>>2]|0;if((a[g+5|0]&3)==0){break}e8(b,g)}}while(0);g=f+8|0;A=c[g>>2]|0;u=f+40|0;F=c[u>>2]|0;E=f+20|0;y=c[E>>2]|0;if(F>>>0>y>>>0){H=A}else{D=A;C=F;while(1){F=c[C+8>>2]|0;B=D>>>0<F>>>0?F:D;F=C+24|0;if(F>>>0>y>>>0){H=B;break}else{D=B;C=F}}}C=f+32|0;D=c[C>>2]|0;if(D>>>0<A>>>0){y=D;F=A;while(1){do{if((c[y+8>>2]|0)>3){A=c[y>>2]|0;if((a[A+5|0]&3)==0){I=F;break}e8(b,A);I=c[g>>2]|0}else{I=F}}while(0);A=y+16|0;if(A>>>0<I>>>0){y=A;F=I}else{J=A;break}}}else{J=D}if(J>>>0<=H>>>0){D=J;do{c[D+8>>2]=0;D=D+16|0;}while(D>>>0<=H>>>0)}D=H-(c[C>>2]|0)|0;C=f+48|0;H=c[C>>2]|0;do{if((H|0)>2e4){K=f+44|0}else{if(((((c[E>>2]|0)-(c[u>>2]|0)|0)/24|0)<<2|0)<(H|0)&(H|0)>16){ez(G,(H|0)/2|0)}J=f+44|0;I=c[J>>2]|0;if(!((D>>2|0)<(I|0)&(I|0)>90)){K=J;break}ey(G,(I|0)/2|0);K=J}}while(0);z=(c[K>>2]<<4)+120+((c[C>>2]|0)*24|0)|0;return z|0}else if((h|0)==9){c[e>>2]=c[f+68>>2];e=c[f+32>>2]|0;if((e|0)!=0){h=e+5|0;a[h]=a[h]&-4}h=f+40|0;e=c[h>>2]|0;if((e|0)>0){C=f+8|0;K=0;G=e;while(1){e=c[C>>2]|0;do{if((c[e+(K<<4)+8>>2]|0)>3){D=c[e+(K<<4)>>2]|0;if((a[D+5|0]&3)==0){L=G;break}e8(b,D);L=c[h>>2]|0}else{L=G}}while(0);e=K+1|0;if((e|0)<(L|0)){K=e;G=L}else{break}}}L=f+36|0;G=c[L>>2]|0;if((G|0)>0){K=f+28|0;C=0;e=G;while(1){G=c[(c[K>>2]|0)+(C<<2)>>2]|0;if((G|0)==0){M=e}else{D=G+5|0;a[D]=a[D]&-4;M=c[L>>2]|0}D=C+1|0;if((D|0)<(M|0)){C=D;e=M}else{break}}}M=f+52|0;e=c[M>>2]|0;if((e|0)>0){C=f+16|0;K=0;D=e;while(1){G=c[(c[C>>2]|0)+(K<<2)>>2]|0;do{if((G|0)==0){N=D}else{if((a[G+5|0]&3)==0){N=D;break}e8(b,G);N=c[M>>2]|0}}while(0);G=K+1|0;if((G|0)<(N|0)){K=G;D=N}else{O=N;break}}}else{O=e}e=f+56|0;N=c[e>>2]|0;if((N|0)>0){D=f+24|0;K=0;b=N;while(1){C=c[(c[D>>2]|0)+(K*12|0)>>2]|0;if((C|0)==0){P=b}else{G=C+5|0;a[G]=a[G]&-4;P=c[e>>2]|0}G=K+1|0;if((G|0)<(P|0)){K=G;b=P}else{break}}Q=c[M>>2]|0;R=P}else{Q=O;R=N}z=(c[h>>2]<<4)+76+(R*12|0)+(Q+(c[f+44>>2]|0)+(c[f+48>>2]|0)+(c[L>>2]|0)<<2)|0;return z|0}else{z=0;return z|0}return 0}function fc(b){b=b|0;var d=0,e=0,f=0;d=0;do{e=c[744+(d<<2)>>2]|0;f=f_(b,e,j_(e|0)|0)|0;e=f+5|0;a[e]=a[e]|32;d=d+1|0;a[f+6|0]=d&255;}while((d|0)<21);return}function fd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=i;if((b|0)>=257){e=c[744+(b-257<<2)>>2]|0;i=d;return e|0}f=(b8(b|0)|0)==0;g=c[a+52>>2]|0;if(f){f=fy(g,6208,(h=i,i=i+8|0,c[h>>2]=b,h)|0)|0;i=h;e=f;i=d;return e|0}else{f=fy(g,6424,(h=i,i=i+8|0,c[h>>2]=b,h)|0)|0;i=h;e=f;i=d;return e|0}return 0}function fe(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;f=i;i=i+160|0;g=f|0;h=f+80|0;j=b+64|0;fz(h,(c[j>>2]|0)+16|0,80);k=b+52|0;l=b+4|0;m=c[l>>2]|0;n=fy(c[k>>2]|0,5960,(o=i,i=i+24|0,c[o>>2]=h,c[o+8>>2]=m,c[o+16>>2]=d,o)|0)|0;i=o;if((e|0)==0){p=c[k>>2]|0;eC(p,3);i=f;return}d=c[k>>2]|0;do{if((e-284|0)>>>0<3){m=b+60|0;h=c[m>>2]|0;q=h+4|0;r=c[q>>2]|0;s=h+8|0;t=c[s>>2]|0;if((r+1|0)>>>0>t>>>0){if(t>>>0>2147483645){u=g|0;fz(u,(c[j>>2]|0)+16|0,80);v=c[k>>2]|0;w=c[l>>2]|0;fy(v,5960,(o=i,i=i+24|0,c[o>>2]=u,c[o+8>>2]=w,c[o+16>>2]=5096,o)|0)|0;i=o;eC(c[k>>2]|0,3);x=c[s>>2]|0;y=c[k>>2]|0}else{x=t;y=d}t=x<<1;if((t|0)==-2){z=fv(y)|0;A=h|0}else{w=h|0;z=fu(y,c[w>>2]|0,x,t)|0;A=w}c[A>>2]=z;c[s>>2]=t;B=c[q>>2]|0;C=z}else{B=r;C=c[h>>2]|0}c[q>>2]=B+1;a[C+B|0]=0;D=c[c[m>>2]>>2]|0}else{if((e|0)>=257){D=c[744+(e-257<<2)>>2]|0;break}m=(b8(e|0)|0)==0;q=c[k>>2]|0;if(m){m=fy(q,6208,(o=i,i=i+8|0,c[o>>2]=e,o)|0)|0;i=o;D=m;break}else{m=fy(q,6424,(o=i,i=i+8|0,c[o>>2]=e,o)|0)|0;i=o;D=m;break}}}while(0);fy(d,5768,(o=i,i=i+16|0,c[o>>2]=n,c[o+8>>2]=D,o)|0)|0;i=o;p=c[k>>2]|0;eC(p,3);i=f;return}function ff(a,b){a=a|0;b=b|0;fe(a,b,c[a+16>>2]|0);return}function fg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;e=c[a+52>>2]|0;f=f_(e,b,d)|0;d=gd(e,c[(c[a+48>>2]|0)+4>>2]|0,f)|0;a=d+8|0;if((c[a>>2]|0)!=0){return f|0}c[d>>2]=1;c[a>>2]=1;a=c[e+16>>2]|0;if((c[a+68>>2]|0)>>>0<(c[a+64>>2]|0)>>>0){return f|0}e1(e);return f|0}function fh(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;a[e+68|0]=46;c[e+52>>2]=b;c[e+32>>2]=287;h=e+56|0;c[h>>2]=f;c[e+48>>2]=0;c[e+4>>2]=1;c[e+8>>2]=1;c[e+64>>2]=g;g=e+60|0;f=c[g>>2]|0;i=fu(b,c[f>>2]|0,c[f+8>>2]|0,32)|0;c[c[g>>2]>>2]=i;c[(c[g>>2]|0)+8>>2]=32;g=c[h>>2]|0;i=c[g>>2]|0;c[g>>2]=i-1;g=c[h>>2]|0;if((i|0)==0){j=gu(g)|0;k=e|0;c[k>>2]=j;return}else{i=g+4|0;g=c[i>>2]|0;c[i>>2]=g+1;j=d[g]|0;k=e|0;c[k>>2]=j;return}}function fi(a){a=a|0;var b=0,d=0,e=0;c[a+8>>2]=c[a+4>>2];b=a+32|0;d=b|0;if((c[d>>2]|0)==287){c[a+16>>2]=fj(a,a+24|0)|0;return}else{e=a+16|0;a=b;c[e>>2]=c[a>>2];c[e+4>>2]=c[a+4>>2];c[e+8>>2]=c[a+8>>2];c[e+12>>2]=c[a+12>>2];c[d>>2]=287;return}}function fj(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0,aL=0,aN=0,aO=0,aP=0,aQ=0,aR=0,aS=0,aT=0,aU=0,aV=0,aW=0,aX=0,aY=0,aZ=0,a_=0,a$=0,a0=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0,ba=0,bb=0,bc=0,bd=0,be=0,bf=0,bg=0,bh=0,bi=0,bj=0,bk=0,bl=0,bm=0,bn=0,bo=0;f=i;i=i+960|0;g=f|0;h=f+80|0;j=f+160|0;k=f+240|0;l=f+320|0;m=f+400|0;n=f+480|0;o=f+560|0;p=f+640|0;q=f+720|0;r=f+800|0;s=f+880|0;t=b+60|0;c[(c[t>>2]|0)+4>>2]=0;u=b|0;v=b+56|0;L3380:while(1){w=c[u>>2]|0;L3382:while(1){switch(w|0){case 126:{x=2712;break L3380;break};case 62:{x=2704;break L3380;break};case 10:case 13:{x=2667;break L3382;break};case 91:{x=2684;break L3380;break};case 60:{x=2696;break L3380;break};case 45:{break L3382;break};case 34:case 39:{x=2720;break L3380;break};case 61:{break L3380;break};case 46:{x=2827;break L3380;break};case-1:{y=287;x=2903;break L3380;break};default:{}}if((aB(w|0)|0)==0){x=2873;break L3380}z=c[v>>2]|0;A=c[z>>2]|0;c[z>>2]=A-1;z=c[v>>2]|0;if((A|0)==0){B=gu(z)|0}else{A=z+4|0;z=c[A>>2]|0;c[A>>2]=z+1;B=d[z]|0}c[u>>2]=B;w=B}if((x|0)==2667){x=0;fl(b);continue}z=c[v>>2]|0;A=c[z>>2]|0;c[z>>2]=A-1;z=c[v>>2]|0;if((A|0)==0){C=gu(z)|0}else{A=z+4|0;z=c[A>>2]|0;c[A>>2]=z+1;C=d[z]|0}c[u>>2]=C;if((C|0)!=45){y=45;x=2904;break}z=c[v>>2]|0;A=c[z>>2]|0;c[z>>2]=A-1;z=c[v>>2]|0;if((A|0)==0){D=gu(z)|0}else{A=z+4|0;z=c[A>>2]|0;c[A>>2]=z+1;D=d[z]|0}c[u>>2]=D;do{if((D|0)==91){z=fm(b)|0;c[(c[t>>2]|0)+4>>2]=0;if((z|0)>-1){fn(b,0,z);c[(c[t>>2]|0)+4>>2]=0;continue L3380}else{E=c[u>>2]|0;break}}else{E=D}}while(0);while(1){if((E|0)==10|(E|0)==13|(E|0)==(-1|0)){continue L3380}z=c[v>>2]|0;A=c[z>>2]|0;c[z>>2]=A-1;z=c[v>>2]|0;if((A|0)==0){F=gu(z)|0}else{A=z+4|0;z=c[A>>2]|0;c[A>>2]=z+1;F=d[z]|0}c[u>>2]=F;E=F}}do{if((x|0)==2712){F=c[v>>2]|0;E=c[F>>2]|0;c[F>>2]=E-1;F=c[v>>2]|0;if((E|0)==0){G=gu(F)|0}else{E=F+4|0;F=c[E>>2]|0;c[E>>2]=F+1;G=d[F]|0}c[u>>2]=G;if((G|0)!=61){y=126;i=f;return y|0}F=c[v>>2]|0;E=c[F>>2]|0;c[F>>2]=E-1;F=c[v>>2]|0;if((E|0)==0){H=gu(F)|0}else{E=F+4|0;F=c[E>>2]|0;c[E>>2]=F+1;H=d[F]|0}c[u>>2]=H;y=283;i=f;return y|0}else if((x|0)==2704){F=c[v>>2]|0;E=c[F>>2]|0;c[F>>2]=E-1;F=c[v>>2]|0;if((E|0)==0){I=gu(F)|0}else{E=F+4|0;F=c[E>>2]|0;c[E>>2]=F+1;I=d[F]|0}c[u>>2]=I;if((I|0)!=61){y=62;i=f;return y|0}F=c[v>>2]|0;E=c[F>>2]|0;c[F>>2]=E-1;F=c[v>>2]|0;if((E|0)==0){J=gu(F)|0}else{E=F+4|0;F=c[E>>2]|0;c[E>>2]=F+1;J=d[F]|0}c[u>>2]=J;y=281;i=f;return y|0}else if((x|0)==2684){F=fm(b)|0;if((F|0)>-1){fn(b,e,F);y=286;i=f;return y|0}if((F|0)==-1){y=91;i=f;return y|0}else{fe(b,5680,286);break}}else if((x|0)==2696){F=c[v>>2]|0;E=c[F>>2]|0;c[F>>2]=E-1;F=c[v>>2]|0;if((E|0)==0){K=gu(F)|0}else{E=F+4|0;F=c[E>>2]|0;c[E>>2]=F+1;K=d[F]|0}c[u>>2]=K;if((K|0)!=61){y=60;i=f;return y|0}F=c[v>>2]|0;E=c[F>>2]|0;c[F>>2]=E-1;F=c[v>>2]|0;if((E|0)==0){L=gu(F)|0}else{E=F+4|0;F=c[E>>2]|0;c[E>>2]=F+1;L=d[F]|0}c[u>>2]=L;y=282;i=f;return y|0}else if((x|0)==2720){F=c[t>>2]|0;E=F+4|0;D=c[E>>2]|0;C=F+8|0;B=c[C>>2]|0;if((D+1|0)>>>0>B>>>0){if(B>>>0>2147483645){z=r|0;fz(z,(c[b+64>>2]|0)+16|0,80);A=b+52|0;M=c[A>>2]|0;N=c[b+4>>2]|0;fy(M,5960,(O=i,i=i+24|0,c[O>>2]=z,c[O+8>>2]=N,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[A>>2]|0,3);P=c[C>>2]|0;Q=A}else{P=B;Q=b+52|0}B=P<<1;A=c[Q>>2]|0;if((B|0)==-2){R=fv(A)|0;S=F|0}else{N=F|0;R=fu(A,c[N>>2]|0,P,B)|0;S=N}c[S>>2]=R;c[C>>2]=B;T=c[E>>2]|0;U=R}else{T=D;U=c[F>>2]|0}F=w&255;c[E>>2]=T+1;a[U+T|0]=F;E=c[v>>2]|0;D=c[E>>2]|0;c[E>>2]=D-1;E=c[v>>2]|0;if((D|0)==0){V=gu(E)|0}else{D=E+4|0;E=c[D>>2]|0;c[D>>2]=E+1;V=d[E]|0}c[u>>2]=V;if((V|0)==(w|0)){W=V&255}else{E=m|0;D=b+64|0;B=b+52|0;C=b+4|0;N=s|0;A=p|0;z=o|0;M=n|0;X=q|0;Y=V;while(1){L3483:do{if((Y|0)==(-1|0)){fz(N,(c[D>>2]|0)+16|0,80);Z=c[C>>2]|0;_=fy(c[B>>2]|0,5960,(O=i,i=i+24|0,c[O>>2]=N,c[O+8>>2]=Z,c[O+16>>2]=4984,O)|0)|0;i=O;Z=c[B>>2]|0;fy(Z,5768,(O=i,i=i+16|0,c[O>>2]=_,c[O+8>>2]=6584,O)|0)|0;i=O;eC(c[B>>2]|0,3);x=2734}else if((Y|0)==10|(Y|0)==13){fe(b,4984,286);x=2734}else if((Y|0)==92){_=c[v>>2]|0;Z=c[_>>2]|0;c[_>>2]=Z-1;_=c[v>>2]|0;if((Z|0)==0){$=gu(_)|0}else{Z=_+4|0;_=c[Z>>2]|0;c[Z>>2]=_+1;$=d[_]|0}c[u>>2]=$;switch($|0){case 98:{aa=8;break};case 102:{aa=12;break};case 110:{aa=10;break};case 114:{aa=13;break};case 116:{aa=9;break};case-1:{ab=-1;break L3483;break};case 118:{aa=11;break};case 10:case 13:{_=c[t>>2]|0;Z=_+4|0;ac=c[Z>>2]|0;ad=_+8|0;ae=c[ad>>2]|0;if((ac+1|0)>>>0>ae>>>0){if(ae>>>0>2147483645){fz(X,(c[D>>2]|0)+16|0,80);af=c[B>>2]|0;ag=c[C>>2]|0;fy(af,5960,(O=i,i=i+24|0,c[O>>2]=X,c[O+8>>2]=ag,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[B>>2]|0,3);ah=c[ad>>2]|0}else{ah=ae}ae=ah<<1;ag=c[B>>2]|0;if((ae|0)==-2){ai=fv(ag)|0;aj=_|0}else{af=_|0;ai=fu(ag,c[af>>2]|0,ah,ae)|0;aj=af}c[aj>>2]=ai;c[ad>>2]=ae;ak=c[Z>>2]|0;al=ai}else{ak=ac;al=c[_>>2]|0}c[Z>>2]=ak+1;a[al+ak|0]=10;fl(b);x=2734;break L3483;break};case 97:{aa=7;break};default:{if(($-48|0)>>>0<10){am=0;an=0;ao=$}else{Z=c[t>>2]|0;_=Z+4|0;ac=c[_>>2]|0;ae=Z+8|0;ad=c[ae>>2]|0;if((ac+1|0)>>>0>ad>>>0){if(ad>>>0>2147483645){fz(A,(c[D>>2]|0)+16|0,80);af=c[B>>2]|0;ag=c[C>>2]|0;fy(af,5960,(O=i,i=i+24|0,c[O>>2]=A,c[O+8>>2]=ag,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[B>>2]|0,3);ap=c[ae>>2]|0}else{ap=ad}ad=ap<<1;ag=c[B>>2]|0;if((ad|0)==-2){aq=fv(ag)|0;ar=Z|0}else{af=Z|0;aq=fu(ag,c[af>>2]|0,ap,ad)|0;ar=af}c[ar>>2]=aq;c[ae>>2]=ad;as=c[_>>2]|0;at=aq}else{as=ac;at=c[Z>>2]|0}c[_>>2]=as+1;a[at+as|0]=$&255;_=c[v>>2]|0;Z=c[_>>2]|0;c[_>>2]=Z-1;_=c[v>>2]|0;if((Z|0)==0){au=gu(_)|0}else{Z=_+4|0;_=c[Z>>2]|0;c[Z>>2]=_+1;au=d[_]|0}c[u>>2]=au;ab=au;break L3483}while(1){av=ao-48+(an*10|0)|0;_=c[v>>2]|0;Z=c[_>>2]|0;c[_>>2]=Z-1;_=c[v>>2]|0;if((Z|0)==0){aw=gu(_)|0}else{Z=_+4|0;_=c[Z>>2]|0;c[Z>>2]=_+1;aw=d[_]|0}c[u>>2]=aw;_=am+1|0;if((_|0)>=3){break}if((aw-48|0)>>>0<10){am=_;an=av;ao=aw}else{break}}if((av|0)>255){fe(b,4848,286)}_=c[t>>2]|0;Z=_+4|0;ac=c[Z>>2]|0;ad=_+8|0;ae=c[ad>>2]|0;if((ac+1|0)>>>0>ae>>>0){if(ae>>>0>2147483645){fz(z,(c[D>>2]|0)+16|0,80);af=c[B>>2]|0;ag=c[C>>2]|0;fy(af,5960,(O=i,i=i+24|0,c[O>>2]=z,c[O+8>>2]=ag,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[B>>2]|0,3);ax=c[ad>>2]|0}else{ax=ae}ae=ax<<1;ag=c[B>>2]|0;if((ae|0)==-2){ay=fv(ag)|0;az=_|0}else{af=_|0;ay=fu(ag,c[af>>2]|0,ax,ae)|0;az=af}c[az>>2]=ay;c[ad>>2]=ae;aA=c[Z>>2]|0;aC=ay}else{aA=ac;aC=c[_>>2]|0}c[Z>>2]=aA+1;a[aC+aA|0]=av&255;x=2734;break L3483}}Z=c[t>>2]|0;_=Z+4|0;ac=c[_>>2]|0;ae=Z+8|0;ad=c[ae>>2]|0;if((ac+1|0)>>>0>ad>>>0){if(ad>>>0>2147483645){fz(M,(c[D>>2]|0)+16|0,80);af=c[B>>2]|0;ag=c[C>>2]|0;fy(af,5960,(O=i,i=i+24|0,c[O>>2]=M,c[O+8>>2]=ag,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[B>>2]|0,3);aD=c[ae>>2]|0}else{aD=ad}ad=aD<<1;ag=c[B>>2]|0;if((ad|0)==-2){aE=fv(ag)|0;aF=Z|0}else{af=Z|0;aE=fu(ag,c[af>>2]|0,aD,ad)|0;aF=af}c[aF>>2]=aE;c[ae>>2]=ad;aG=c[_>>2]|0;aH=aE}else{aG=ac;aH=c[Z>>2]|0}c[_>>2]=aG+1;a[aH+aG|0]=aa;_=c[v>>2]|0;Z=c[_>>2]|0;c[_>>2]=Z-1;_=c[v>>2]|0;if((Z|0)==0){aI=gu(_)|0}else{Z=_+4|0;_=c[Z>>2]|0;c[Z>>2]=_+1;aI=d[_]|0}c[u>>2]=aI;ab=aI}else{_=c[t>>2]|0;Z=_+4|0;ac=c[Z>>2]|0;ad=_+8|0;ae=c[ad>>2]|0;if((ac+1|0)>>>0>ae>>>0){if(ae>>>0>2147483645){fz(E,(c[D>>2]|0)+16|0,80);af=c[B>>2]|0;ag=c[C>>2]|0;fy(af,5960,(O=i,i=i+24|0,c[O>>2]=E,c[O+8>>2]=ag,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[B>>2]|0,3);aJ=c[ad>>2]|0}else{aJ=ae}ae=aJ<<1;ag=c[B>>2]|0;if((ae|0)==-2){aK=fv(ag)|0;aL=_|0}else{af=_|0;aK=fu(ag,c[af>>2]|0,aJ,ae)|0;aL=af}c[aL>>2]=aK;c[ad>>2]=ae;aN=c[Z>>2]|0;aO=aK}else{aN=ac;aO=c[_>>2]|0}c[Z>>2]=aN+1;a[aO+aN|0]=Y&255;Z=c[v>>2]|0;_=c[Z>>2]|0;c[Z>>2]=_-1;Z=c[v>>2]|0;if((_|0)==0){aP=gu(Z)|0}else{_=Z+4|0;Z=c[_>>2]|0;c[_>>2]=Z+1;aP=d[Z]|0}c[u>>2]=aP;ab=aP}}while(0);if((x|0)==2734){x=0;ab=c[u>>2]|0}if((ab|0)==(w|0)){W=F;break}else{Y=ab}}}Y=c[t>>2]|0;F=Y+4|0;B=c[F>>2]|0;E=Y+8|0;C=c[E>>2]|0;if((B+1|0)>>>0>C>>>0){if(C>>>0>2147483645){D=l|0;fz(D,(c[b+64>>2]|0)+16|0,80);M=b+52|0;z=c[M>>2]|0;A=c[b+4>>2]|0;fy(z,5960,(O=i,i=i+24|0,c[O>>2]=D,c[O+8>>2]=A,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[M>>2]|0,3);aQ=c[E>>2]|0;aR=M}else{aQ=C;aR=b+52|0}C=aQ<<1;M=c[aR>>2]|0;if((C|0)==-2){aS=fv(M)|0;aT=Y|0}else{A=Y|0;aS=fu(M,c[A>>2]|0,aQ,C)|0;aT=A}c[aT>>2]=aS;c[E>>2]=C;aU=c[F>>2]|0;aV=aS}else{aU=B;aV=c[Y>>2]|0}c[F>>2]=aU+1;a[aV+aU|0]=W;F=c[v>>2]|0;Y=c[F>>2]|0;c[F>>2]=Y-1;F=c[v>>2]|0;if((Y|0)==0){aW=gu(F)|0}else{Y=F+4|0;F=c[Y>>2]|0;c[Y>>2]=F+1;aW=d[F]|0}c[u>>2]=aW;F=c[t>>2]|0;Y=c[b+52>>2]|0;B=f_(Y,(c[F>>2]|0)+1|0,(c[F+4>>2]|0)-2|0)|0;F=gd(Y,c[(c[b+48>>2]|0)+4>>2]|0,B)|0;C=F+8|0;do{if((c[C>>2]|0)==0){c[F>>2]=1;c[C>>2]=1;E=c[Y+16>>2]|0;if((c[E+68>>2]|0)>>>0<(c[E+64>>2]|0)>>>0){break}e1(Y)}}while(0);c[e>>2]=B;y=286;i=f;return y|0}else if((x|0)==2827){Y=c[t>>2]|0;C=Y+4|0;F=c[C>>2]|0;E=Y+8|0;A=c[E>>2]|0;if((F+1|0)>>>0>A>>>0){if(A>>>0>2147483645){M=k|0;fz(M,(c[b+64>>2]|0)+16|0,80);D=b+52|0;z=c[D>>2]|0;X=c[b+4>>2]|0;fy(z,5960,(O=i,i=i+24|0,c[O>>2]=M,c[O+8>>2]=X,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[D>>2]|0,3);aX=c[E>>2]|0;aY=D}else{aX=A;aY=b+52|0}A=aX<<1;D=c[aY>>2]|0;if((A|0)==-2){aZ=fv(D)|0;a_=Y|0}else{X=Y|0;aZ=fu(D,c[X>>2]|0,aX,A)|0;a_=X}c[a_>>2]=aZ;c[E>>2]=A;a$=c[C>>2]|0;a0=aZ}else{a$=F;a0=c[Y>>2]|0}c[C>>2]=a$+1;a[a0+a$|0]=46;C=c[v>>2]|0;Y=c[C>>2]|0;c[C>>2]=Y-1;C=c[v>>2]|0;if((Y|0)==0){a1=gu(C)|0}else{Y=C+4|0;C=c[Y>>2]|0;c[Y>>2]=C+1;a1=d[C]|0}c[u>>2]=a1;if((aM(5600,a1|0,2)|0)==0){if((a1-48|0)>>>0>=10){y=46;i=f;return y|0}fs(b,e);y=284;i=f;return y|0}C=c[t>>2]|0;Y=C+4|0;F=c[Y>>2]|0;A=C+8|0;E=c[A>>2]|0;if((F+1|0)>>>0>E>>>0){if(E>>>0>2147483645){X=h|0;fz(X,(c[b+64>>2]|0)+16|0,80);D=b+52|0;M=c[D>>2]|0;z=c[b+4>>2]|0;fy(M,5960,(O=i,i=i+24|0,c[O>>2]=X,c[O+8>>2]=z,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[D>>2]|0,3);a2=c[A>>2]|0;a3=D}else{a2=E;a3=b+52|0}E=a2<<1;D=c[a3>>2]|0;if((E|0)==-2){a4=fv(D)|0;a5=C|0}else{z=C|0;a4=fu(D,c[z>>2]|0,a2,E)|0;a5=z}c[a5>>2]=a4;c[A>>2]=E;a6=c[Y>>2]|0;a7=a4}else{a6=F;a7=c[C>>2]|0}c[Y>>2]=a6+1;a[a7+a6|0]=a1&255;Y=c[v>>2]|0;C=c[Y>>2]|0;c[Y>>2]=C-1;Y=c[v>>2]|0;if((C|0)==0){a8=gu(Y)|0}else{C=Y+4|0;Y=c[C>>2]|0;c[C>>2]=Y+1;a8=d[Y]|0}c[u>>2]=a8;if((aM(5600,a8|0,2)|0)==0){y=278;i=f;return y|0}Y=c[t>>2]|0;C=Y+4|0;F=c[C>>2]|0;E=Y+8|0;A=c[E>>2]|0;if((F+1|0)>>>0>A>>>0){if(A>>>0>2147483645){z=g|0;fz(z,(c[b+64>>2]|0)+16|0,80);D=b+52|0;X=c[D>>2]|0;M=c[b+4>>2]|0;fy(X,5960,(O=i,i=i+24|0,c[O>>2]=z,c[O+8>>2]=M,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[D>>2]|0,3);a9=c[E>>2]|0;ba=D}else{a9=A;ba=b+52|0}A=a9<<1;D=c[ba>>2]|0;if((A|0)==-2){bb=fv(D)|0;bc=Y|0}else{M=Y|0;bb=fu(D,c[M>>2]|0,a9,A)|0;bc=M}c[bc>>2]=bb;c[E>>2]=A;bd=c[C>>2]|0;be=bb}else{bd=F;be=c[Y>>2]|0}c[C>>2]=bd+1;a[be+bd|0]=a8&255;C=c[v>>2]|0;Y=c[C>>2]|0;c[C>>2]=Y-1;C=c[v>>2]|0;if((Y|0)==0){bf=gu(C)|0}else{Y=C+4|0;C=c[Y>>2]|0;c[Y>>2]=C+1;bf=d[C]|0}c[u>>2]=bf;y=279;i=f;return y|0}else if((x|0)==2873){C=c[u>>2]|0;if((C-48|0)>>>0<10){fs(b,e);y=284;i=f;return y|0}do{if((bt(C|0)|0)==0){Y=c[u>>2]|0;if((Y|0)==95){break}F=c[v>>2]|0;A=c[F>>2]|0;c[F>>2]=A-1;F=c[v>>2]|0;if((A|0)==0){bg=gu(F)|0}else{A=F+4|0;F=c[A>>2]|0;c[A>>2]=F+1;bg=d[F]|0}c[u>>2]=bg;y=Y;i=f;return y|0}}while(0);C=j|0;B=b+64|0;Y=b+52|0;F=b+4|0;while(1){A=c[u>>2]|0;E=c[t>>2]|0;M=E+4|0;D=c[M>>2]|0;z=E+8|0;X=c[z>>2]|0;if((D+1|0)>>>0>X>>>0){if(X>>>0>2147483645){fz(C,(c[B>>2]|0)+16|0,80);N=c[Y>>2]|0;Z=c[F>>2]|0;fy(N,5960,(O=i,i=i+24|0,c[O>>2]=C,c[O+8>>2]=Z,c[O+16>>2]=5096,O)|0)|0;i=O;eC(c[Y>>2]|0,3);bh=c[z>>2]|0}else{bh=X}X=bh<<1;Z=c[Y>>2]|0;if((X|0)==-2){bi=fv(Z)|0;bj=E|0}else{N=E|0;bi=fu(Z,c[N>>2]|0,bh,X)|0;bj=N}c[bj>>2]=bi;c[z>>2]=X;bk=c[M>>2]|0;bl=bi}else{bk=D;bl=c[E>>2]|0}c[M>>2]=bk+1;a[bl+bk|0]=A&255;A=c[v>>2]|0;M=c[A>>2]|0;c[A>>2]=M-1;A=c[v>>2]|0;if((M|0)==0){bm=gu(A)|0}else{M=A+4|0;A=c[M>>2]|0;c[M>>2]=A+1;bm=d[A]|0}c[u>>2]=bm;if((bq(bm|0)|0)!=0){continue}if((c[u>>2]|0)!=95){break}}C=c[t>>2]|0;F=c[Y>>2]|0;B=f_(F,c[C>>2]|0,c[C+4>>2]|0)|0;C=gd(F,c[(c[b+48>>2]|0)+4>>2]|0,B)|0;A=C+8|0;do{if((c[A>>2]|0)==0){c[C>>2]=1;c[A>>2]=1;M=c[F+16>>2]|0;if((c[M+68>>2]|0)>>>0<(c[M+64>>2]|0)>>>0){break}e1(F)}}while(0);F=a[B+6|0]|0;if(F<<24>>24==0){c[e>>2]=B;y=285;i=f;return y|0}else{y=F&255|256;i=f;return y|0}}else if((x|0)==2903){i=f;return y|0}else if((x|0)==2904){i=f;return y|0}}while(0);x=c[v>>2]|0;e=c[x>>2]|0;c[x>>2]=e-1;x=c[v>>2]|0;if((e|0)==0){bn=gu(x)|0}else{e=x+4|0;x=c[e>>2]|0;c[e>>2]=x+1;bn=d[x]|0}c[u>>2]=bn;if((bn|0)!=61){y=61;i=f;return y|0}bn=c[v>>2]|0;x=c[bn>>2]|0;c[bn>>2]=x-1;bn=c[v>>2]|0;if((x|0)==0){bo=gu(bn)|0}else{x=bn+4|0;bn=c[x>>2]|0;c[x>>2]=bn+1;bo=d[bn]|0}c[u>>2]=bo;y=280;i=f;return y|0}function fk(a){a=a|0;c[a+32>>2]=fj(a,a+40|0)|0;return}function fl(a){a=a|0;var b=0,e=0,f=0,g=0,h=0,i=0,j=0;b=a|0;e=c[b>>2]|0;f=a+56|0;g=c[f>>2]|0;h=c[g>>2]|0;c[g>>2]=h-1;g=c[f>>2]|0;if((h|0)==0){i=gu(g)|0}else{h=g+4|0;g=c[h>>2]|0;c[h>>2]=g+1;i=d[g]|0}c[b>>2]=i;do{if((i|0)==10|(i|0)==13){if((i|0)==(e|0)){break}g=c[f>>2]|0;h=c[g>>2]|0;c[g>>2]=h-1;g=c[f>>2]|0;if((h|0)==0){j=gu(g)|0}else{h=g+4|0;g=c[h>>2]|0;c[h>>2]=g+1;j=d[g]|0}c[b>>2]=j}}while(0);j=a+4|0;b=(c[j>>2]|0)+1|0;c[j>>2]=b;if((b|0)<=2147483644){return}fe(a,4344,c[a+16>>2]|0);return}function fm(b){b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;e=i;i=i+160|0;f=e|0;g=e+80|0;h=b|0;j=c[h>>2]|0;k=b+60|0;l=c[k>>2]|0;m=l+4|0;n=c[m>>2]|0;o=l+8|0;p=c[o>>2]|0;if((n+1|0)>>>0>p>>>0){if(p>>>0>2147483645){q=g|0;fz(q,(c[b+64>>2]|0)+16|0,80);g=b+52|0;r=c[g>>2]|0;s=c[b+4>>2]|0;fy(r,5960,(t=i,i=i+24|0,c[t>>2]=q,c[t+8>>2]=s,c[t+16>>2]=5096,t)|0)|0;i=t;eC(c[g>>2]|0,3);u=c[o>>2]|0;v=g}else{u=p;v=b+52|0}p=u<<1;g=c[v>>2]|0;if((p|0)==-2){w=fv(g)|0;x=l|0}else{v=l|0;w=fu(g,c[v>>2]|0,u,p)|0;x=v}c[x>>2]=w;c[o>>2]=p;y=c[m>>2]|0;z=w}else{y=n;z=c[l>>2]|0}c[m>>2]=y+1;a[z+y|0]=j&255;y=b+56|0;z=c[y>>2]|0;m=c[z>>2]|0;c[z>>2]=m-1;z=c[y>>2]|0;if((m|0)==0){A=gu(z)|0}else{m=z+4|0;z=c[m>>2]|0;c[m>>2]=z+1;A=d[z]|0}c[h>>2]=A;if((A|0)!=61){B=A;C=0;D=(B|0)!=(j|0);E=D<<31>>31;F=E^C;i=e;return F|0}A=f|0;f=b+64|0;z=b+52|0;m=b+4|0;b=61;l=0;while(1){n=c[k>>2]|0;w=n+4|0;p=c[w>>2]|0;o=n+8|0;x=c[o>>2]|0;if((p+1|0)>>>0>x>>>0){if(x>>>0>2147483645){fz(A,(c[f>>2]|0)+16|0,80);v=c[z>>2]|0;u=c[m>>2]|0;fy(v,5960,(t=i,i=i+24|0,c[t>>2]=A,c[t+8>>2]=u,c[t+16>>2]=5096,t)|0)|0;i=t;eC(c[z>>2]|0,3);G=c[o>>2]|0}else{G=x}x=G<<1;u=c[z>>2]|0;if((x|0)==-2){H=fv(u)|0;I=n|0}else{v=n|0;H=fu(u,c[v>>2]|0,G,x)|0;I=v}c[I>>2]=H;c[o>>2]=x;J=c[w>>2]|0;K=H}else{J=p;K=c[n>>2]|0}c[w>>2]=J+1;a[K+J|0]=b;w=c[y>>2]|0;n=c[w>>2]|0;c[w>>2]=n-1;w=c[y>>2]|0;if((n|0)==0){L=gu(w)|0}else{n=w+4|0;w=c[n>>2]|0;c[n>>2]=w+1;L=d[w]|0}c[h>>2]=L;w=l+1|0;if((L|0)==61){b=L&255;l=w}else{B=L;C=w;break}}D=(B|0)!=(j|0);E=D<<31>>31;F=E^C;i=e;return F|0}function fn(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0;g=i;i=i+480|0;h=g|0;j=g+80|0;k=g+160|0;l=g+240|0;m=g+320|0;n=g+400|0;o=b|0;p=c[o>>2]|0;q=b+60|0;r=c[q>>2]|0;s=r+4|0;t=c[s>>2]|0;u=r+8|0;v=c[u>>2]|0;if((t+1|0)>>>0>v>>>0){if(v>>>0>2147483645){w=m|0;fz(w,(c[b+64>>2]|0)+16|0,80);m=b+52|0;x=c[m>>2]|0;y=c[b+4>>2]|0;fy(x,5960,(z=i,i=i+24|0,c[z>>2]=w,c[z+8>>2]=y,c[z+16>>2]=5096,z)|0)|0;i=z;eC(c[m>>2]|0,3);A=c[u>>2]|0;B=m}else{A=v;B=b+52|0}v=A<<1;m=c[B>>2]|0;if((v|0)==-2){C=fv(m)|0;D=r|0}else{B=r|0;C=fu(m,c[B>>2]|0,A,v)|0;D=B}c[D>>2]=C;c[u>>2]=v;E=c[s>>2]|0;F=C}else{E=t;F=c[r>>2]|0}c[s>>2]=E+1;a[F+E|0]=p&255;p=b+56|0;E=c[p>>2]|0;F=c[E>>2]|0;c[E>>2]=F-1;E=c[p>>2]|0;if((F|0)==0){G=gu(E)|0}else{F=E+4|0;E=c[F>>2]|0;c[F>>2]=E+1;G=d[E]|0}c[o>>2]=G;if((G|0)==10|(G|0)==13){fl(b);H=2981}else{I=G}L3799:while(1){if((H|0)==2981){H=0;I=c[o>>2]|0}J=(e|0)==0;G=h|0;K=b+64|0;L=b+52|0;M=b+4|0;E=l|0;F=(f|0)==0;s=I;L3803:while(1){L3805:do{if(J){r=s;while(1){switch(r|0){case 10:case 13:{H=3018;break L3803;break};case 93:{H=3005;break L3803;break};case 91:{break L3805;break};case-1:{H=2990;break L3803;break};default:{}}t=c[p>>2]|0;C=c[t>>2]|0;c[t>>2]=C-1;t=c[p>>2]|0;if((C|0)==0){N=gu(t)|0}else{C=t+4|0;t=c[C>>2]|0;c[C>>2]=t+1;N=d[t]|0}c[o>>2]=N;r=N}}else{r=s;while(1){switch(r|0){case 10:case 13:{H=3018;break L3803;break};case 93:{H=3005;break L3803;break};case 91:{break L3805;break};case-1:{H=2990;break L3803;break};default:{}}t=c[q>>2]|0;C=t+4|0;v=c[C>>2]|0;u=t+8|0;D=c[u>>2]|0;if((v+1|0)>>>0>D>>>0){if(D>>>0>2147483645){fz(G,(c[K>>2]|0)+16|0,80);B=c[L>>2]|0;A=c[M>>2]|0;fy(B,5960,(z=i,i=i+24|0,c[z>>2]=G,c[z+8>>2]=A,c[z+16>>2]=5096,z)|0)|0;i=z;eC(c[L>>2]|0,3);O=c[u>>2]|0}else{O=D}D=O<<1;A=c[L>>2]|0;if((D|0)==-2){P=fv(A)|0;Q=t|0}else{B=t|0;P=fu(A,c[B>>2]|0,O,D)|0;Q=B}c[Q>>2]=P;c[u>>2]=D;R=c[C>>2]|0;S=P}else{R=v;S=c[t>>2]|0}c[C>>2]=R+1;a[S+R|0]=r&255;C=c[p>>2]|0;t=c[C>>2]|0;c[C>>2]=t-1;C=c[p>>2]|0;if((t|0)==0){T=gu(C)|0}else{t=C+4|0;C=c[t>>2]|0;c[t>>2]=C+1;T=d[C]|0}c[o>>2]=T;r=T}}}while(0);if((fm(b)|0)!=(f|0)){H=2981;continue L3799}r=c[o>>2]|0;C=c[q>>2]|0;t=C+4|0;v=c[t>>2]|0;D=C+8|0;u=c[D>>2]|0;if((v+1|0)>>>0>u>>>0){if(u>>>0>2147483645){fz(E,(c[K>>2]|0)+16|0,80);B=c[L>>2]|0;A=c[M>>2]|0;fy(B,5960,(z=i,i=i+24|0,c[z>>2]=E,c[z+8>>2]=A,c[z+16>>2]=5096,z)|0)|0;i=z;eC(c[L>>2]|0,3);U=c[D>>2]|0}else{U=u}u=U<<1;A=c[L>>2]|0;if((u|0)==-2){V=fv(A)|0;W=C|0}else{B=C|0;V=fu(A,c[B>>2]|0,U,u)|0;W=B}c[W>>2]=V;c[D>>2]=u;X=c[t>>2]|0;Y=V}else{X=v;Y=c[C>>2]|0}c[t>>2]=X+1;a[Y+X|0]=r&255;r=c[p>>2]|0;t=c[r>>2]|0;c[r>>2]=t-1;r=c[p>>2]|0;if((t|0)==0){Z=gu(r)|0}else{t=r+4|0;r=c[t>>2]|0;c[t>>2]=r+1;Z=d[r]|0}c[o>>2]=Z;if(F){H=3004;break}else{s=Z}}if((H|0)==3018){H=0;s=c[q>>2]|0;F=s+4|0;E=c[F>>2]|0;G=s+8|0;r=c[G>>2]|0;if((E+1|0)>>>0>r>>>0){if(r>>>0>2147483645){t=j|0;fz(t,(c[K>>2]|0)+16|0,80);C=c[L>>2]|0;v=c[M>>2]|0;fy(C,5960,(z=i,i=i+24|0,c[z>>2]=t,c[z+8>>2]=v,c[z+16>>2]=5096,z)|0)|0;i=z;eC(c[L>>2]|0,3);_=c[G>>2]|0}else{_=r}r=_<<1;v=c[L>>2]|0;if((r|0)==-2){$=fv(v)|0;aa=s|0}else{t=s|0;$=fu(v,c[t>>2]|0,_,r)|0;aa=t}c[aa>>2]=$;c[G>>2]=r;ab=c[F>>2]|0;ac=$}else{ab=E;ac=c[s>>2]|0}c[F>>2]=ab+1;a[ac+ab|0]=10;fl(b);if(!J){H=2981;continue}c[(c[q>>2]|0)+4>>2]=0;H=2981;continue}else if((H|0)==3004){H=0;fe(b,4472,91);H=2981;continue}else if((H|0)==3005){H=0;if((fm(b)|0)==(f|0)){break}else{H=2981;continue}}else if((H|0)==2990){H=0;F=n|0;fz(F,(c[K>>2]|0)+16|0,80);s=c[M>>2]|0;E=fy(c[L>>2]|0,5960,(z=i,i=i+24|0,c[z>>2]=F,c[z+8>>2]=s,c[z+16>>2]=(e|0)!=0?4664:4560,z)|0)|0;i=z;fy(c[L>>2]|0,5768,(z=i,i=i+16|0,c[z>>2]=E,c[z+8>>2]=6584,z)|0)|0;i=z;eC(c[L>>2]|0,3);H=2981;continue}}H=c[o>>2]|0;n=c[q>>2]|0;ab=n+4|0;ac=c[ab>>2]|0;$=n+8|0;aa=c[$>>2]|0;if((ac+1|0)>>>0>aa>>>0){if(aa>>>0>2147483645){_=k|0;fz(_,(c[K>>2]|0)+16|0,80);K=c[L>>2]|0;k=c[M>>2]|0;fy(K,5960,(z=i,i=i+24|0,c[z>>2]=_,c[z+8>>2]=k,c[z+16>>2]=5096,z)|0)|0;i=z;eC(c[L>>2]|0,3);ad=c[$>>2]|0}else{ad=aa}aa=ad<<1;z=c[L>>2]|0;if((aa|0)==-2){ae=fv(z)|0;af=n|0}else{k=n|0;ae=fu(z,c[k>>2]|0,ad,aa)|0;af=k}c[af>>2]=ae;c[$>>2]=aa;ag=c[ab>>2]|0;ah=ae}else{ag=ac;ah=c[n>>2]|0}c[ab>>2]=ag+1;a[ah+ag|0]=H&255;H=c[p>>2]|0;ag=c[H>>2]|0;c[H>>2]=ag-1;H=c[p>>2]|0;if((ag|0)==0){ai=gu(H)|0}else{ag=H+4|0;H=c[ag>>2]|0;c[ag>>2]=H+1;ai=d[H]|0}c[o>>2]=ai;if(J){i=g;return}J=c[q>>2]|0;q=f+2|0;f=c[L>>2]|0;L=f_(f,(c[J>>2]|0)+q|0,(c[J+4>>2]|0)-(q<<1)|0)|0;q=gd(f,c[(c[b+48>>2]|0)+4>>2]|0,L)|0;b=q+8|0;do{if((c[b>>2]|0)==0){c[q>>2]=1;c[b>>2]=1;J=c[f+16>>2]|0;if((c[J+68>>2]|0)>>>0<(c[J+64>>2]|0)>>>0){break}e1(f)}}while(0);c[e>>2]=L;i=g;return}function fo(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;if(a>>>0>15){b=a;c=1;do{d=b+1|0;b=d>>>1;c=c+1|0;}while(d>>>0>31);e=b;f=c<<3}else{e=a;f=8}if(e>>>0<8){g=e;return g|0}g=f|e-8;return g|0}function fp(a){a=a|0;var b=0,c=0;b=a>>>3&31;if((b|0)==0){c=a;return c|0}c=(a&7|8)<<b-1;return c|0}function fq(a){a=a|0;var b=0,c=0,e=0,f=0,g=0,h=0;if(a>>>0>255){b=a;c=-1;while(1){e=c+8|0;f=b>>>8;if(b>>>0>65535){b=f;c=e}else{g=f;h=e;break}}}else{g=a;h=-1}return(d[1048+g|0]|0)+h|0}function fr(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+8>>2]|0;if((d|0)!=(c[b+8>>2]|0)){e=0;return e|0}if((d|0)==1){e=(c[a>>2]|0)==(c[b>>2]|0)|0;return e|0}else if((d|0)==2){e=(c[a>>2]|0)==(c[b>>2]|0)|0;return e|0}else if((d|0)==0){e=1;return e|0}else if((d|0)==3){e=+h[a>>3]==+h[b>>3]|0;return e|0}else{e=(c[a>>2]|0)==(c[b>>2]|0)|0;return e|0}return 0}function fs(b,e){b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0;f=i;i=i+400|0;g=f|0;h=f+80|0;j=f+160|0;k=f+240|0;l=b|0;m=b+60|0;n=f+320|0;o=b+64|0;p=b+52|0;q=b+4|0;r=b+56|0;s=c[l>>2]&255;while(1){t=c[m>>2]|0;u=t+4|0;v=c[u>>2]|0;w=t+8|0;x=c[w>>2]|0;if((v+1|0)>>>0>x>>>0){if(x>>>0>2147483645){fz(n,(c[o>>2]|0)+16|0,80);y=c[p>>2]|0;z=c[q>>2]|0;fy(y,5960,(A=i,i=i+24|0,c[A>>2]=n,c[A+8>>2]=z,c[A+16>>2]=5096,A)|0)|0;i=A;eC(c[p>>2]|0,3);B=c[w>>2]|0}else{B=x}x=B<<1;z=c[p>>2]|0;if((x|0)==-2){C=fv(z)|0;D=t|0}else{y=t|0;C=fu(z,c[y>>2]|0,B,x)|0;D=y}c[D>>2]=C;c[w>>2]=x;E=c[u>>2]|0;F=C}else{E=v;F=c[t>>2]|0}c[u>>2]=E+1;a[F+E|0]=s;u=c[r>>2]|0;t=c[u>>2]|0;c[u>>2]=t-1;u=c[r>>2]|0;if((t|0)==0){G=gu(u)|0}else{t=u+4|0;u=c[t>>2]|0;c[t>>2]=u+1;G=d[u]|0}c[l>>2]=G;if((G-48|0)>>>0<10){s=G&255;continue}if((G|0)==46){s=46}else{break}}do{if((aM(5344,G|0,3)|0)==0){H=G}else{s=c[m>>2]|0;E=s+4|0;F=c[E>>2]|0;C=s+8|0;D=c[C>>2]|0;if((F+1|0)>>>0>D>>>0){if(D>>>0>2147483645){B=h|0;fz(B,(c[o>>2]|0)+16|0,80);n=c[p>>2]|0;u=c[q>>2]|0;fy(n,5960,(A=i,i=i+24|0,c[A>>2]=B,c[A+8>>2]=u,c[A+16>>2]=5096,A)|0)|0;i=A;eC(c[p>>2]|0,3);I=c[C>>2]|0}else{I=D}D=I<<1;u=c[p>>2]|0;if((D|0)==-2){J=fv(u)|0;K=s|0}else{B=s|0;J=fu(u,c[B>>2]|0,I,D)|0;K=B}c[K>>2]=J;c[C>>2]=D;L=c[E>>2]|0;M=J}else{L=F;M=c[s>>2]|0}c[E>>2]=L+1;a[M+L|0]=G&255;E=c[r>>2]|0;s=c[E>>2]|0;c[E>>2]=s-1;E=c[r>>2]|0;if((s|0)==0){N=gu(E)|0}else{s=E+4|0;E=c[s>>2]|0;c[s>>2]=E+1;N=d[E]|0}c[l>>2]=N;if((aM(5336,N|0,3)|0)==0){H=N;break}E=c[m>>2]|0;s=E+4|0;F=c[s>>2]|0;D=E+8|0;C=c[D>>2]|0;if((F+1|0)>>>0>C>>>0){if(C>>>0>2147483645){B=g|0;fz(B,(c[o>>2]|0)+16|0,80);u=c[p>>2]|0;n=c[q>>2]|0;fy(u,5960,(A=i,i=i+24|0,c[A>>2]=B,c[A+8>>2]=n,c[A+16>>2]=5096,A)|0)|0;i=A;eC(c[p>>2]|0,3);O=c[D>>2]|0}else{O=C}C=O<<1;n=c[p>>2]|0;if((C|0)==-2){P=fv(n)|0;Q=E|0}else{B=E|0;P=fu(n,c[B>>2]|0,O,C)|0;Q=B}c[Q>>2]=P;c[D>>2]=C;R=c[s>>2]|0;S=P}else{R=F;S=c[E>>2]|0}c[s>>2]=R+1;a[S+R|0]=N&255;s=c[r>>2]|0;E=c[s>>2]|0;c[s>>2]=E-1;s=c[r>>2]|0;if((E|0)==0){T=gu(s)|0}else{E=s+4|0;s=c[E>>2]|0;c[E>>2]=s+1;T=d[s]|0}c[l>>2]=T;H=T}}while(0);T=k|0;k=H;while(1){H=(bq(k|0)|0)==0;N=c[l>>2]|0;if(H){if((N|0)==95){U=95}else{break}}else{U=N&255}N=c[m>>2]|0;H=N+4|0;R=c[H>>2]|0;S=N+8|0;P=c[S>>2]|0;if((R+1|0)>>>0>P>>>0){if(P>>>0>2147483645){fz(T,(c[o>>2]|0)+16|0,80);Q=c[p>>2]|0;O=c[q>>2]|0;fy(Q,5960,(A=i,i=i+24|0,c[A>>2]=T,c[A+8>>2]=O,c[A+16>>2]=5096,A)|0)|0;i=A;eC(c[p>>2]|0,3);V=c[S>>2]|0}else{V=P}P=V<<1;O=c[p>>2]|0;if((P|0)==-2){W=fv(O)|0;X=N|0}else{Q=N|0;W=fu(O,c[Q>>2]|0,V,P)|0;X=Q}c[X>>2]=W;c[S>>2]=P;Y=c[H>>2]|0;Z=W}else{Y=R;Z=c[N>>2]|0}c[H>>2]=Y+1;a[Z+Y|0]=U;H=c[r>>2]|0;N=c[H>>2]|0;c[H>>2]=N-1;H=c[r>>2]|0;if((N|0)==0){_=gu(H)|0}else{N=H+4|0;H=c[N>>2]|0;c[N>>2]=H+1;_=d[H]|0}c[l>>2]=_;k=_}_=c[m>>2]|0;k=_+4|0;l=c[k>>2]|0;r=_+8|0;U=c[r>>2]|0;if((l+1|0)>>>0>U>>>0){if(U>>>0>2147483645){Y=j|0;fz(Y,(c[o>>2]|0)+16|0,80);o=c[p>>2]|0;j=c[q>>2]|0;fy(o,5960,(A=i,i=i+24|0,c[A>>2]=Y,c[A+8>>2]=j,c[A+16>>2]=5096,A)|0)|0;i=A;eC(c[p>>2]|0,3);$=c[r>>2]|0}else{$=U}U=$<<1;A=c[p>>2]|0;if((U|0)==-2){aa=fv(A)|0;ab=_|0}else{p=_|0;aa=fu(A,c[p>>2]|0,$,U)|0;ab=p}c[ab>>2]=aa;c[r>>2]=U;ac=c[k>>2]|0;ad=aa}else{ac=l;ad=c[_>>2]|0}c[k>>2]=ac+1;a[ad+ac|0]=0;ac=b+68|0;ad=a[ac]|0;k=c[m>>2]|0;_=c[k>>2]|0;l=c[k+4>>2]|0;if((l|0)==0){ae=_}else{k=l;do{k=k-1|0;l=_+k|0;if((a[l]|0)==46){a[l]=ad}}while((k|0)!=0);ae=c[c[m>>2]>>2]|0}k=e|0;if((fw(ae,k)|0)!=0){i=f;return}ae=bD()|0;e=a[ac]|0;if((ae|0)==0){af=46}else{af=a[c[ae>>2]|0]|0}a[ac]=af;ae=c[m>>2]|0;ad=c[ae>>2]|0;_=c[ae+4>>2]|0;if((_|0)==0){ag=ad}else{ae=_;do{ae=ae-1|0;_=ad+ae|0;if((a[_]|0)==e<<24>>24){a[_]=af}}while((ae|0)!=0);ag=c[c[m>>2]>>2]|0}if((fw(ag,k)|0)!=0){i=f;return}k=a[ac]|0;ac=c[m>>2]|0;m=c[ac>>2]|0;ag=c[ac+4>>2]|0;if((ag|0)!=0){ac=ag;do{ac=ac-1|0;ag=m+ac|0;if((a[ag]|0)==k<<24>>24){a[ag]=46}}while((ac|0)!=0)}fe(b,5232,284);i=f;return}function ft(a,b,d,e,f,g){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0;h=i;j=c[d>>2]|0;do{if((j|0)<((f|0)/2|0|0)){k=j<<1;l=(k|0)<4?4:k}else{if((j|0)<(f|0)){l=f;break}es(a,g,(m=i,i=i+1|0,i=i+7>>3<<3,c[m>>2]=0,m)|0);i=m;l=f}}while(0);if((l+1|0)>>>0>(4294967293/(e>>>0)|0)>>>0){es(a,2288,(m=i,i=i+1|0,i=i+7>>3<<3,c[m>>2]=0,m)|0);i=m;n=0;c[d>>2]=l;i=h;return n|0}m=aa(c[d>>2]|0,e)|0;f=aa(l,e)|0;e=c[a+16>>2]|0;g=cg[c[e+12>>2]&511](c[e+16>>2]|0,b,m,f)|0;if(!((g|0)!=0|(f|0)==0)){eC(a,4)}a=e+68|0;c[a>>2]=f-m+(c[a>>2]|0);n=g;c[d>>2]=l;i=h;return n|0}function fu(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=c[a+16>>2]|0;g=cg[c[f+12>>2]&511](c[f+16>>2]|0,b,d,e)|0;if(!((g|0)!=0|(e|0)==0)){eC(a,4)}a=f+68|0;c[a>>2]=e-d+(c[a>>2]|0);return g|0}function fv(a){a=a|0;var b=0;b=i;es(a,2288,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0);i=a;i=b;return 0}function fw(b,e){b=b|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0;f=i;i=i+8|0;g=f|0;h[e>>3]=+jZ(b,g);j=c[g>>2]|0;if((j|0)==(b|0)){k=0;i=f;return k|0}l=a[j]|0;if((l<<24>>24|0)==120|(l<<24>>24|0)==88){h[e>>3]=+((as(b|0,g|0,16)|0)>>>0>>>0);b=c[g>>2]|0;m=b;n=a[b]|0}else{m=j;n=l}if(n<<24>>24==0){k=1;i=f;return k|0}if((aB(n&255|0)|0)==0){o=m}else{n=m;do{n=n+1|0;}while((aB(d[n]|0)|0)!=0);c[g>>2]=n;o=n}k=(a[o]|0)==0|0;i=f;return k|0}function fx(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0;f=i;i=i+40|0;g=f|0;j=f+32|0;k=b+8|0;l=c[k>>2]|0;c[l>>2]=f_(b,10512,0)|0;c[l+8>>2]=4;l=b+28|0;m=c[k>>2]|0;if(((c[l>>2]|0)-m|0)<17){eA(b,1);n=c[k>>2]|0}else{n=m}m=n+16|0;c[k>>2]=m;n=aU(d|0,37)|0;L4082:do{if((n|0)==0){o=1;p=d;q=m}else{r=j|0;s=j+1|0;t=j+2|0;u=g|0;w=g+1|0;x=f+8|0;y=1;z=d;A=n;B=m;while(1){c[B>>2]=f_(b,z,A-z|0)|0;c[B+8>>2]=4;C=c[k>>2]|0;if(((c[l>>2]|0)-C|0)<17){eA(b,1);D=c[k>>2]|0}else{D=C}C=D+16|0;c[k>>2]=C;E=A+1|0;switch(a[E]|0){case 115:{F=(v=c[e+4>>2]|0,c[e+4>>2]=v+8,c[(c[e>>2]|0)+v>>2]|0);G=(F|0)==0?8496:F;F=c[k>>2]|0;c[F>>2]=f_(b,G,j_(G|0)|0)|0;c[F+8>>2]=4;F=c[k>>2]|0;if(((c[l>>2]|0)-F|0)<17){eA(b,1);H=c[k>>2]|0}else{H=F}F=H+16|0;c[k>>2]=F;I=F;break};case 100:{h[C>>3]=+((v=c[e+4>>2]|0,c[e+4>>2]=v+8,c[(c[e>>2]|0)+v>>2]|0)|0);c[D+24>>2]=3;F=c[k>>2]|0;if(((c[l>>2]|0)-F|0)<17){eA(b,1);J=c[k>>2]|0}else{J=F}F=J+16|0;c[k>>2]=F;I=F;break};case 99:{a[u]=(v=c[e+4>>2]|0,c[e+4>>2]=v+8,c[(c[e>>2]|0)+v>>2]|0)&255;a[w]=0;F=c[k>>2]|0;c[F>>2]=f_(b,u,j_(u|0)|0)|0;c[F+8>>2]=4;F=c[k>>2]|0;if(((c[l>>2]|0)-F|0)<17){eA(b,1);K=c[k>>2]|0}else{K=F}F=K+16|0;c[k>>2]=F;I=F;break};case 112:{F=(v=c[e+4>>2]|0,c[e+4>>2]=v+8,c[(c[e>>2]|0)+v>>2]|0);a$(x|0,8256,(G=i,i=i+8|0,c[G>>2]=F,G)|0)|0;i=G;G=c[k>>2]|0;c[G>>2]=f_(b,x,j_(x|0)|0)|0;c[G+8>>2]=4;G=c[k>>2]|0;if(((c[l>>2]|0)-G|0)<17){eA(b,1);L=c[k>>2]|0}else{L=G}G=L+16|0;c[k>>2]=G;I=G;break};case 37:{c[C>>2]=f_(b,6416,1)|0;c[D+24>>2]=4;G=c[k>>2]|0;if(((c[l>>2]|0)-G|0)<17){eA(b,1);M=c[k>>2]|0}else{M=G}G=M+16|0;c[k>>2]=G;I=G;break};case 102:{h[C>>3]=(v=c[e+4>>2]|0,c[e+4>>2]=v+8,+h[(c[e>>2]|0)+v>>3]);c[D+24>>2]=3;G=c[k>>2]|0;if(((c[l>>2]|0)-G|0)<17){eA(b,1);N=c[k>>2]|0}else{N=G}G=N+16|0;c[k>>2]=G;I=G;break};default:{a[r]=37;a[s]=a[E]|0;a[t]=0;c[C>>2]=f_(b,r,j_(r|0)|0)|0;c[D+24>>2]=4;C=c[k>>2]|0;if(((c[l>>2]|0)-C|0)<17){eA(b,1);O=c[k>>2]|0}else{O=C}C=O+16|0;c[k>>2]=C;I=C}}C=y+2|0;E=A+2|0;G=aU(E|0,37)|0;if((G|0)==0){o=C;p=E;q=I;break L4082}else{y=C;z=E;A=G;B=I}}}}while(0);c[q>>2]=f_(b,p,j_(p|0)|0)|0;c[q+8>>2]=4;q=c[k>>2]|0;if(((c[l>>2]|0)-q|0)>=17){P=q;Q=P+16|0;c[k>>2]=Q;R=o+1|0;S=b+12|0;T=c[S>>2]|0;U=Q;V=T;W=U-V|0;X=W>>4;Y=X-1|0;gq(b,R,Y);Z=c[k>>2]|0;_=-o|0;$=Z+(_<<4)|0;c[k>>2]=$;aa=~o;ab=Z+(aa<<4)|0;ac=ab;ad=c[ac>>2]|0;ae=ad+16|0;af=ae;i=f;return af|0}eA(b,1);P=c[k>>2]|0;Q=P+16|0;c[k>>2]=Q;R=o+1|0;S=b+12|0;T=c[S>>2]|0;U=Q;V=T;W=U-V|0;X=W>>4;Y=X-1|0;gq(b,R,Y);Z=c[k>>2]|0;_=-o|0;$=Z+(_<<4)|0;c[k>>2]=$;aa=~o;ab=Z+(aa<<4)|0;ac=ab;ad=c[ac>>2]|0;ae=ad+16|0;af=ae;i=f;return af|0}function fy(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=i;i=i+16|0;f=e|0;g=f;c[g>>2]=d;c[g+4>>2]=0;g=fx(a,b,f|0)|0;i=e;return g|0}function fz(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0,g=0,h=0;e=a[c]|0;if((e<<24>>24|0)==61){f=c+1|0;j3(b|0,f|0,d|0)|0;a[b+(d-1)|0]=0;return}else if((e<<24>>24|0)==64){e=c+1|0;f=j_(e|0)|0;a[b]=0;if(f>>>0>(d-8|0)>>>0){g=b+(j_(b|0)|0)|0;w=3026478;a[g]=w&255;w=w>>8;a[g+1|0]=w&255;w=w>>8;a[g+2|0]=w&255;w=w>>8;a[g+3|0]=w&255;h=c+(8-d+1+f)|0}else{h=e}j4(b|0,h|0)|0;return}else{h=a2(c|0,4048)|0;e=d-17|0;d=h>>>0>e>>>0?e:h;j$(b|0,3536,10)|0;if((a[c+d|0]|0)==0){j4(b|0,c|0)|0}else{bS(b|0,c|0,d|0)|0;d=b+(j_(b|0)|0)|0;w=3026478;a[d]=w&255;w=w>>8;a[d+1|0]=w&255;w=w>>8;a[d+2|0]=w&255;w=w>>8;a[d+3|0]=w&255}d=b+(j_(b|0)|0)|0;a[d]=a[2920]|0;a[d+1|0]=a[2921|0]|0;a[d+2|0]=a[2922|0]|0;return}}function fA(e,f,g,h){e=e|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0;j=i;i=i+648|0;k=j|0;l=j+72|0;c[k+60>>2]=g;fh(e,k,f,f_(e,h,j_(h|0)|0)|0);fB(k,l);h=l|0;a[(c[h>>2]|0)+74|0]=2;fi(k);l=k+52|0;e=(c[l>>2]|0)+52|0;f=(b[e>>1]|0)+1&65535;b[e>>1]=f;if((f&65535)>200){fe(k,6912,0)}f=k+16|0;e=k+48|0;L4144:do{switch(c[f>>2]|0){case 260:case 261:case 262:case 276:case 287:{break L4144;break};default:{}}g=fD(k)|0;if((c[f>>2]|0)==59){fi(k)}m=c[e>>2]|0;c[m+36>>2]=d[m+50|0]|0;}while((g|0)==0);e=(c[l>>2]|0)+52|0;b[e>>1]=(b[e>>1]|0)-1&65535;if((c[f>>2]|0)==287){fC(k);n=c[h>>2]|0;i=j;return n|0}f=c[l>>2]|0;l=fd(k,287)|0;e=fy(f,7112,(f=i,i=i+8|0,c[f>>2]=l,f)|0)|0;i=f;ff(k,e);fC(k);n=c[h>>2]|0;i=j;return n|0}function fB(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=c[b+52>>2]|0;f=eV(e)|0;c[d>>2]=f;g=b+48|0;c[d+8>>2]=c[g>>2];c[d+12>>2]=b;c[d+16>>2]=e;c[g>>2]=d;c[d+24>>2]=0;c[d+28>>2]=-1;c[d+32>>2]=-1;c[d+20>>2]=0;j2(d+36|0,0,15);c[f+32>>2]=c[b+64>>2];a[f+75|0]=2;b=f5(e,0,0)|0;c[d+4>>2]=b;d=e+8|0;g=c[d>>2]|0;c[g>>2]=b;c[g+8>>2]=5;g=e+28|0;b=c[d>>2]|0;if(((c[g>>2]|0)-b|0)<17){eA(e,1);h=c[d>>2]|0}else{h=b}b=h+16|0;c[d>>2]=b;c[b>>2]=f;c[h+24>>2]=9;h=c[d>>2]|0;if(((c[g>>2]|0)-h|0)>=17){i=h;j=i+16|0;c[d>>2]=j;return}eA(e,1);i=c[d>>2]|0;j=i+16|0;c[d>>2]=j;return}function fC(f){f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;g=c[f+52>>2]|0;h=f+48|0;i=c[h>>2]|0;j=i|0;k=c[j>>2]|0;l=i+50|0;m=a[l]|0;n=i+24|0;L4164:do{if(m<<24>>24!=0){o=m;p=k;while(1){q=c[n>>2]|0;r=o-1&255;a[l]=r;c[(c[p+24>>2]|0)+((e[i+172+((r&255)<<1)>>1]|0)*12|0)+8>>2]=q;q=a[l]|0;if(q<<24>>24==0){break L4164}o=q;p=c[j>>2]|0}}}while(0);dP(i,0,0);j=c[n>>2]|0;if((j+1|0)>>>0<1073741824){l=k+12|0;m=k+44|0;s=fu(g,c[l>>2]|0,c[m>>2]<<2,j<<2)|0;t=l;u=m}else{s=fv(g)|0;t=k+12|0;u=k+44|0}c[t>>2]=s;c[u>>2]=c[n>>2];u=c[n>>2]|0;if((u+1|0)>>>0<1073741824){s=k+20|0;t=k+48|0;v=fu(g,c[s>>2]|0,c[t>>2]<<2,u<<2)|0;w=s;x=t}else{v=fv(g)|0;w=k+20|0;x=k+48|0}c[w>>2]=v;c[x>>2]=c[n>>2];n=i+40|0;x=c[n>>2]|0;if((x+1|0)>>>0<268435456){v=k+8|0;w=k+40|0;y=fu(g,c[v>>2]|0,c[w>>2]<<4,x<<4)|0;z=v;A=w}else{y=fv(g)|0;z=k+8|0;A=k+40|0}c[z>>2]=y;c[A>>2]=c[n>>2];n=i+44|0;A=c[n>>2]|0;if((A+1|0)>>>0<1073741824){y=k+16|0;z=k+52|0;B=fu(g,c[y>>2]|0,c[z>>2]<<2,A<<2)|0;C=y;D=z}else{B=fv(g)|0;C=k+16|0;D=k+52|0}c[C>>2]=B;c[D>>2]=c[n>>2];n=i+48|0;D=b[n>>1]|0;if((D+1|0)>>>0<357913942){B=k+24|0;C=k+56|0;E=fu(g,c[B>>2]|0,(c[C>>2]|0)*12|0,D*12|0)|0;F=B;G=C}else{E=fv(g)|0;F=k+24|0;G=k+56|0}c[F>>2]=E;c[G>>2]=b[n>>1]|0;n=k+72|0;G=k+28|0;E=k+36|0;c[G>>2]=fu(g,c[G>>2]|0,c[E>>2]<<2,d[n]<<2)|0;c[E>>2]=d[n]|0;c[h>>2]=c[i+8>>2];if((i|0)==0){H=g+8|0;I=c[H>>2]|0;J=I-32|0;c[H>>2]=J;return}if(((c[f+16>>2]|0)-285|0)>>>0>=2){H=g+8|0;I=c[H>>2]|0;J=I-32|0;c[H>>2]=J;return}i=c[f+24>>2]|0;fg(f,i+16|0,c[i+12>>2]|0)|0;H=g+8|0;I=c[H>>2]|0;J=I-32|0;c[H>>2]=J;return}function fD(f){f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0;g=i;i=i+392|0;h=g|0;j=g+24|0;k=g+48|0;l=g+72|0;m=g+104|0;n=g+128|0;o=g+152|0;p=g+176|0;q=g+200|0;r=g+224|0;s=g+248|0;t=g+272|0;u=g+288|0;v=g+304|0;w=g+328|0;x=g+344|0;y=g+368|0;z=g+384|0;A=f+4|0;B=c[A>>2]|0;C=f+16|0;switch(c[C>>2]|0){case 266:{D=c[f+48>>2]|0;c[z>>2]=-1;E=fS(f)|0;while(1){F=c[C>>2]|0;if((F|0)==260){G=3286;break}else if((F|0)!=261){G=3287;break}dO(D,z,dM(D)|0);dR(D,E);E=fS(f)|0}if((G|0)==3286){dO(D,z,dM(D)|0);dR(D,E);fi(f);fE(f)}else if((G|0)==3287){dO(D,z,E)}dR(D,c[z>>2]|0);fF(f,262,266,B);H=0;i=g;return H|0};case 277:{z=f+48|0;D=c[z>>2]|0;fi(f);E=dI(D)|0;fI(f,x,0)|0;F=x|0;if((c[F>>2]|0)==1){c[F>>2]=3}d5(c[z>>2]|0,x);z=c[x+20>>2]|0;c[y+4>>2]=-1;a[y+10|0]=1;x=D+50|0;a[y+8|0]=a[x]|0;a[y+9|0]=0;F=D+20|0;c[y>>2]=c[F>>2];c[F>>2]=y;if((c[C>>2]|0)!=259){y=c[f+52>>2]|0;I=fd(f,259)|0;J=fy(y,7112,(K=i,i=i+8|0,c[K>>2]=I,K)|0)|0;i=K;ff(f,J)}fi(f);fE(f);dQ(D,dM(D)|0,E);fF(f,262,277,B);E=c[F>>2]|0;c[F>>2]=c[E>>2];F=E+8|0;J=a[F]|0;I=c[(c[D+12>>2]|0)+48>>2]|0;y=I+50|0;L=a[y]|0;if((L&255)>(J&255)){M=I+24|0;N=I|0;O=L;do{L=c[M>>2]|0;P=O-1&255;a[y]=P;c[(c[(c[N>>2]|0)+24>>2]|0)+((e[I+172+((P&255)<<1)>>1]|0)*12|0)+8>>2]=L;O=a[y]|0;}while((O&255)>(J&255))}if((a[E+9|0]|0)!=0){J=d[F]|0;dL(D,35,J,0,0)|0}c[D+36>>2]=d[x]|0;dR(D,c[E+4>>2]|0);dR(D,z);H=0;i=g;return H|0};case 272:{z=f+48|0;D=c[z>>2]|0;E=dI(D)|0;c[t+4>>2]=-1;a[t+10|0]=1;x=D+50|0;a[t+8|0]=a[x]|0;a[t+9|0]=0;J=D+20|0;c[t>>2]=c[J>>2];c[J>>2]=t;c[u+4>>2]=-1;a[u+10|0]=0;a[u+8|0]=a[x]|0;t=u+9|0;a[t]=0;c[u>>2]=c[J>>2];c[J>>2]=u;fi(f);u=f+52|0;F=(c[u>>2]|0)+52|0;O=(b[F>>1]|0)+1&65535;b[F>>1]=O;if((O&65535)>200){fe(f,6912,0)}L4226:do{switch(c[C>>2]|0){case 260:case 261:case 262:case 276:case 287:{break L4226;break};default:{}}O=fD(f)|0;if((c[C>>2]|0)==59){fi(f)}F=c[z>>2]|0;c[F+36>>2]=d[F+50|0]|0;}while((O|0)==0);O=(c[u>>2]|0)+52|0;b[O>>1]=(b[O>>1]|0)-1&65535;fF(f,276,272,B);fI(f,s,0)|0;O=s|0;if((c[O>>2]|0)==1){c[O>>2]=3}d5(c[z>>2]|0,s);O=c[s+20>>2]|0;if((a[t]|0)==0){t=c[J>>2]|0;c[J>>2]=c[t>>2];s=t+8|0;u=a[s]|0;F=c[(c[D+12>>2]|0)+48>>2]|0;y=F+50|0;I=a[y]|0;if((I&255)>(u&255)){N=F+24|0;M=F|0;L=I;do{I=c[N>>2]|0;P=L-1&255;a[y]=P;c[(c[(c[M>>2]|0)+24>>2]|0)+((e[F+172+((P&255)<<1)>>1]|0)*12|0)+8>>2]=I;L=a[y]|0;}while((L&255)>(u&255))}if((a[t+9|0]|0)!=0){u=d[s]|0;dL(D,35,u,0,0)|0}c[D+36>>2]=d[x]|0;dR(D,c[t+4>>2]|0);dQ(c[z>>2]|0,O,E)}else{t=c[z>>2]|0;u=c[t+20>>2]|0;L4238:do{if((u|0)==0){Q=0;G=3353}else{s=0;L=u;while(1){if((a[L+10|0]|0)!=0){R=s;S=L;break L4238}y=d[L+9|0]|s;F=c[L>>2]|0;if((F|0)==0){Q=y;G=3353;break}else{s=y;L=F}}}}while(0);if((G|0)==3353){ff(f,9e3);R=Q;S=0}if((R|0)!=0){R=d[S+8|0]|0;dL(t,35,R,0,0)|0}dO(t,S+4|0,dM(t)|0);dR(c[z>>2]|0,O);O=c[J>>2]|0;c[J>>2]=c[O>>2];t=O+8|0;S=a[t]|0;R=c[(c[D+12>>2]|0)+48>>2]|0;Q=R+50|0;u=a[Q]|0;if((u&255)>(S&255)){L=R+24|0;s=R|0;F=u;do{u=c[L>>2]|0;y=F-1&255;a[Q]=y;c[(c[(c[s>>2]|0)+24>>2]|0)+((e[R+172+((y&255)<<1)>>1]|0)*12|0)+8>>2]=u;F=a[Q]|0;}while((F&255)>(S&255))}if((a[O+9|0]|0)!=0){S=d[t]|0;dL(D,35,S,0,0)|0}c[D+36>>2]=d[x]|0;dR(D,c[O+4>>2]|0);O=c[z>>2]|0;dQ(O,dM(D)|0,E)}E=c[J>>2]|0;c[J>>2]=c[E>>2];J=E+8|0;O=a[J]|0;z=c[(c[D+12>>2]|0)+48>>2]|0;S=z+50|0;t=a[S]|0;if((t&255)>(O&255)){F=z+24|0;Q=z|0;R=t;do{t=c[F>>2]|0;s=R-1&255;a[S]=s;c[(c[(c[Q>>2]|0)+24>>2]|0)+((e[z+172+((s&255)<<1)>>1]|0)*12|0)+8>>2]=t;R=a[S]|0;}while((R&255)>(O&255))}if((a[E+9|0]|0)!=0){O=d[J]|0;dL(D,35,O,0,0)|0}c[D+36>>2]=d[x]|0;dR(D,c[E+4>>2]|0);H=0;i=g;return H|0};case 259:{fi(f);fE(f);fF(f,262,259,B);H=0;i=g;return H|0};case 258:{fi(f);E=c[f+48>>2]|0;D=c[E+20>>2]|0;L4278:do{if((D|0)==0){T=0;G=3412}else{x=0;O=D;while(1){if((a[O+10|0]|0)!=0){U=x;V=O;break L4278}J=d[O+9|0]|x;R=c[O>>2]|0;if((R|0)==0){T=J;G=3412;break}else{x=J;O=R}}}}while(0);if((G|0)==3412){ff(f,9e3);U=T;V=0}if((U|0)!=0){U=d[V+8|0]|0;dL(E,35,U,0,0)|0}dO(E,V+4|0,dM(E)|0);H=1;i=g;return H|0};case 273:{E=f+48|0;V=c[E>>2]|0;fi(f);L4296:do{switch(c[C>>2]|0){case 260:case 261:case 262:case 276:case 287:case 59:{W=0;X=0;break};default:{fI(f,m,0)|0;if((c[C>>2]|0)==44){U=1;while(1){fi(f);d_(c[E>>2]|0,m);fI(f,m,0)|0;T=U+1|0;if((c[C>>2]|0)==44){U=T}else{Y=T;break}}}else{Y=1}U=m|0;if(((c[U>>2]|0)-13|0)>>>0<2){dX(V,m,-1);if((c[U>>2]|0)==13&(Y|0)==1){U=(c[(c[V>>2]|0)+12>>2]|0)+(c[m+8>>2]<<2)|0;c[U>>2]=c[U>>2]&-64|29}W=-1;X=d[V+50|0]|0;break L4296}else{if((Y|0)==1){W=1;X=d0(V,m)|0;break L4296}else{d_(V,m);W=Y;X=d[V+50|0]|0;break L4296}}}}}while(0);dP(V,X,W);H=1;i=g;return H|0};case 264:{W=f+48|0;X=c[W>>2]|0;c[w+4>>2]=-1;a[w+10|0]=1;V=X+50|0;a[w+8|0]=a[V]|0;a[w+9|0]=0;Y=X+20|0;c[w>>2]=c[Y>>2];c[Y>>2]=w;fi(f);if((c[C>>2]|0)!=285){w=c[f+52>>2]|0;m=fd(f,285)|0;E=fy(w,7112,(K=i,i=i+8|0,c[K>>2]=m,K)|0)|0;i=K;ff(f,E)}E=f+24|0;m=c[E>>2]|0;fi(f);w=c[C>>2]|0;if((w|0)==44|(w|0)==267){U=c[W>>2]|0;T=c[U+36>>2]|0;fL(f,fg(f,8632,15)|0,0);fL(f,fg(f,8456,11)|0,1);fL(f,fg(f,8240,13)|0,2);fL(f,m,3);D=c[C>>2]|0;if((D|0)==44){O=f+52|0;x=4;while(1){fi(f);if((c[C>>2]|0)!=285){R=c[O>>2]|0;J=fd(f,285)|0;S=fy(R,7112,(K=i,i=i+8|0,c[K>>2]=J,K)|0)|0;i=K;ff(f,S)}S=c[E>>2]|0;fi(f);fL(f,S,x);Z=c[C>>2]|0;if((Z|0)==44){x=x+1|0}else{break}}_=x-2|0;$=Z}else{_=1;$=D}if(($|0)!=267){$=c[f+52>>2]|0;D=fd(f,267)|0;Z=fy($,7112,(K=i,i=i+8|0,c[K>>2]=D,K)|0)|0;i=K;ff(f,Z)}fi(f);Z=c[A>>2]|0;fI(f,v,0)|0;if((c[C>>2]|0)==44){D=1;while(1){fi(f);d_(c[W>>2]|0,v);fI(f,v,0)|0;$=D+1|0;if((c[C>>2]|0)==44){D=$}else{aa=$;break}}}else{aa=1}D=c[W>>2]|0;$=3-aa|0;aa=c[v>>2]|0;do{if((aa|0)==13|(aa|0)==14){x=$+1|0;E=(x|0)<0?0:x;dX(D,v,E);if((E|0)<=1){break}dT(D,E-1|0)}else if((aa|0)==0){G=3325}else{d_(D,v);G=3325}}while(0);do{if((G|0)==3325){if(($|0)<=0){break}v=c[D+36>>2]|0;dT(D,$);dK(D,v,$)}}while(0);dS(U,3);fR(f,T,Z,_,0)}else if((w|0)==61){w=c[W>>2]|0;_=w+36|0;Z=c[_>>2]|0;fL(f,fg(f,8016,11)|0,0);fL(f,fg(f,7784,11)|0,1);fL(f,fg(f,7544,10)|0,2);fL(f,m,3);if((c[C>>2]|0)!=61){m=c[f+52>>2]|0;T=fd(f,61)|0;U=fy(m,7112,(K=i,i=i+8|0,c[K>>2]=T,K)|0)|0;i=K;ff(f,U)}fi(f);fI(f,k,0)|0;d_(c[W>>2]|0,k);if((c[C>>2]|0)!=44){k=c[f+52>>2]|0;U=fd(f,44)|0;T=fy(k,7112,(K=i,i=i+8|0,c[K>>2]=U,K)|0)|0;i=K;ff(f,T)}fi(f);fI(f,j,0)|0;d_(c[W>>2]|0,j);if((c[C>>2]|0)==44){fi(f);fI(f,h,0)|0;d_(c[W>>2]|0,h)}else{h=c[_>>2]|0;_=dW(w,1.0)|0;dN(w,1,h,_)|0;dT(w,1)}fR(f,Z,B,1,1)}else{ff(f,8840)}fF(f,262,264,B);Z=c[Y>>2]|0;c[Y>>2]=c[Z>>2];Y=Z+8|0;w=a[Y]|0;_=c[(c[X+12>>2]|0)+48>>2]|0;h=_+50|0;W=a[h]|0;if((W&255)>(w&255)){j=_+24|0;T=_|0;U=W;do{W=c[j>>2]|0;k=U-1&255;a[h]=k;c[(c[(c[T>>2]|0)+24>>2]|0)+((e[_+172+((k&255)<<1)>>1]|0)*12|0)+8>>2]=W;U=a[h]|0;}while((U&255)>(w&255))}if((a[Z+9|0]|0)!=0){w=d[Y]|0;dL(X,35,w,0,0)|0}c[X+36>>2]=d[V]|0;dR(X,c[Z+4>>2]|0);H=0;i=g;return H|0};case 265:{fi(f);if((c[C>>2]|0)!=285){Z=c[f+52>>2]|0;X=fd(f,285)|0;V=fy(Z,7112,(K=i,i=i+8|0,c[K>>2]=X,K)|0)|0;i=K;ff(f,V)}V=c[f+24>>2]|0;fi(f);X=f+48|0;Z=c[X>>2]|0;if((fQ(Z,V,q,1)|0)==8){c[q+8>>2]=dU(Z,V)|0}while(1){V=c[C>>2]|0;if((V|0)==58){G=3374;break}else if((V|0)!=46){ab=0;break}fO(f,q)}if((G|0)==3374){fO(f,q);ab=1}fK(f,r,ab,B);d3(c[X>>2]|0,q,r);ea(c[X>>2]|0,B);H=0;i=g;return H|0};case 268:{fi(f);B=c[C>>2]|0;if((B|0)==265){fi(f);X=f+48|0;r=c[X>>2]|0;if((c[C>>2]|0)!=285){q=c[f+52>>2]|0;ab=fd(f,285)|0;V=fy(q,7112,(K=i,i=i+8|0,c[K>>2]=ab,K)|0)|0;i=K;ff(f,V)}V=c[f+24>>2]|0;fi(f);fL(f,V,0);V=c[r+36>>2]|0;c[o+16>>2]=-1;c[o+20>>2]=-1;c[o>>2]=6;c[o+8>>2]=V;dT(r,1);V=c[X>>2]|0;X=V+50|0;ab=(a[X]|0)+1&255;a[X]=ab;c[(c[(c[V>>2]|0)+24>>2]|0)+((e[V+172+((ab&255)-1<<1)>>1]|0)*12|0)+4>>2]=c[V+24>>2];fK(f,p,0,c[A>>2]|0);d3(r,o,p);c[(c[(c[r>>2]|0)+24>>2]|0)+((e[r+172+((d[r+50|0]|0)-1<<1)>>1]|0)*12|0)+4>>2]=c[r+24>>2];H=0;i=g;return H|0}r=f+24|0;p=f+52|0;o=0;A=B;while(1){if((A|0)!=285){B=c[p>>2]|0;V=fd(f,285)|0;ab=fy(B,7112,(K=i,i=i+8|0,c[K>>2]=V,K)|0)|0;i=K;ff(f,ab)}ab=c[r>>2]|0;fi(f);ac=o+1|0;fL(f,ab,o);ab=c[C>>2]|0;if((ab|0)==61){G=3385;break}else if((ab|0)!=44){G=3388;break}fi(f);o=ac;A=c[C>>2]|0}do{if((G|0)==3385){fi(f);fI(f,n,0)|0;if((c[C>>2]|0)==44){A=f+48|0;r=1;while(1){fi(f);d_(c[A>>2]|0,n);fI(f,n,0)|0;K=r+1|0;if((c[C>>2]|0)==44){r=K}else{ad=K;break}}}else{ad=1}r=c[n>>2]|0;A=f+48|0;K=c[A>>2]|0;p=ac-ad|0;if((r|0)==0){ae=A;af=K;ag=p;G=3393;break}else if(!((r|0)==13|(r|0)==14)){d_(K,n);ae=A;af=K;ag=p;G=3393;break}r=p+1|0;p=(r|0)<0?0:r;dX(K,n,p);if((p|0)<=1){ah=A;break}dT(K,p-1|0);ah=A}else if((G|0)==3388){c[n>>2]=0;A=f+48|0;ae=A;af=c[A>>2]|0;ag=ac;G=3393}}while(0);do{if((G|0)==3393){if((ag|0)<=0){ah=ae;break}n=c[af+36>>2]|0;dT(af,ag);dK(af,n,ag);ah=ae}}while(0);ae=c[ah>>2]|0;ah=ae+50|0;ag=(d[ah]|0)+ac|0;a[ah]=ag&255;if((ac|0)==0){H=0;i=g;return H|0}af=ae+24|0;G=ae|0;c[(c[(c[G>>2]|0)+24>>2]|0)+((e[ae+172+((ag&255)-ac<<1)>>1]|0)*12|0)+4>>2]=c[af>>2];if((o|0)==0){H=0;i=g;return H|0}else{ai=o}while(1){c[(c[(c[G>>2]|0)+24>>2]|0)+((e[ae+172+((d[ah]|0)-ai<<1)>>1]|0)*12|0)+4>>2]=c[af>>2];o=ai-1|0;if((o|0)==0){H=0;break}else{ai=o}}i=g;return H|0};default:{ai=c[f+48>>2]|0;af=l+8|0;fG(f,af);if((c[af>>2]|0)==13){af=(c[(c[ai>>2]|0)+12>>2]|0)+(c[l+16>>2]<<2)|0;c[af>>2]=c[af>>2]&-8372225|16384;H=0;i=g;return H|0}else{c[l>>2]=0;fH(f,l,1);H=0;i=g;return H|0}}}return 0}function fE(f){f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;g=i;i=i+16|0;h=g|0;j=f+48|0;k=c[j>>2]|0;c[h+4>>2]=-1;a[h+10|0]=0;l=k+50|0;a[h+8|0]=a[l]|0;a[h+9|0]=0;m=k+20|0;c[h>>2]=c[m>>2];c[m>>2]=h;h=f+52|0;n=(c[h>>2]|0)+52|0;o=(b[n>>1]|0)+1&65535;b[n>>1]=o;if((o&65535)>200){fe(f,6912,0)}o=f+16|0;L4:do{switch(c[o>>2]|0){case 260:case 261:case 262:case 276:case 287:{break L4;break};default:{}}n=fD(f)|0;if((c[o>>2]|0)==59){fi(f)}p=c[j>>2]|0;c[p+36>>2]=d[p+50|0]|0;}while((n|0)==0);j=(c[h>>2]|0)+52|0;b[j>>1]=(b[j>>1]|0)-1&65535;j=c[m>>2]|0;c[m>>2]=c[j>>2];m=j+8|0;h=a[m]|0;f=c[(c[k+12>>2]|0)+48>>2]|0;o=f+50|0;n=a[o]|0;if((n&255)>(h&255)){p=f+24|0;q=f|0;r=n;do{n=c[p>>2]|0;s=r-1&255;a[o]=s;c[(c[(c[q>>2]|0)+24>>2]|0)+((e[f+172+((s&255)<<1)>>1]|0)*12|0)+8>>2]=n;r=a[o]|0;}while((r&255)>(h&255))}if((a[j+9|0]|0)==0){t=a[l]|0;u=t&255;v=k+36|0;c[v>>2]=u;w=j+4|0;x=c[w>>2]|0;dR(k,x);i=g;return}dL(k,35,d[m]|0,0,0)|0;t=a[l]|0;u=t&255;v=k+36|0;c[v>>2]=u;w=j+4|0;x=c[w>>2]|0;dR(k,x);i=g;return}function fF(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;f=i;if((c[a+16>>2]|0)==(b|0)){fi(a);i=f;return}g=(c[a+4>>2]|0)==(e|0);h=c[a+52>>2]|0;j=fd(a,b)|0;if(g){g=fy(h,7112,(k=i,i=i+8|0,c[k>>2]=j,k)|0)|0;i=k;ff(a,g);i=f;return}else{g=fd(a,d)|0;d=fy(h,7320,(k=i,i=i+24|0,c[k>>2]=j,c[k+8>>2]=g,c[k+16>>2]=e,k)|0)|0;i=k;ff(a,d);i=f;return}}function fG(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=i;i=i+48|0;e=d|0;f=d+24|0;g=a+48|0;h=c[g>>2]|0;j=a+16|0;k=c[j>>2]|0;do{if((k|0)==40){l=c[a+4>>2]|0;fi(a);fI(a,b,0)|0;fF(a,41,40,l);dZ(c[g>>2]|0,b)}else if((k|0)==285){l=c[a+24>>2]|0;fi(a);m=c[g>>2]|0;if((fQ(m,l,b,1)|0)!=8){break}c[b+8>>2]=dU(m,l)|0}else{ff(a,9512)}}while(0);k=a+24|0;l=f+16|0;m=f+20|0;n=f|0;o=f+8|0;p=a+52|0;L37:while(1){switch(c[j>>2]|0){case 46:{fO(a,b);continue L37;break};case 91:{d0(h,b)|0;fN(a,e);d6(h,b,e);continue L37;break};case 58:{fi(a);if((c[j>>2]|0)!=285){q=c[p>>2]|0;r=fd(a,285)|0;s=fy(q,7112,(q=i,i=i+8|0,c[q>>2]=r,q)|0)|0;i=q;ff(a,s)}s=c[k>>2]|0;fi(a);q=dU(c[g>>2]|0,s)|0;c[l>>2]=-1;c[m>>2]=-1;c[n>>2]=4;c[o>>2]=q;d4(h,b,f);fP(a,b);continue L37;break};case 40:case 286:case 123:{d_(h,b);fP(a,b);continue L37;break};default:{break L37}}}i=d;return}function fH(a,b,d){a=a|0;b=b|0;d=d|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;f=i;i=i+56|0;g=f|0;h=f+24|0;j=b+8|0;if(((c[j>>2]|0)-6|0)>>>0>=4){ff(a,9200)}k=a+16|0;l=c[k>>2]|0;if((l|0)==61){m=60}else if((l|0)==44){fi(a);c[h>>2]=b;l=h+8|0;fG(a,l);do{if((c[l>>2]|0)==6){n=c[a+48>>2]|0;o=n+36|0;p=c[o>>2]|0;if((b|0)==0){break}q=h+16|0;r=b;s=0;while(1){do{if((c[r+8>>2]|0)==9){t=r+16|0;u=t;v=c[q>>2]|0;if((c[u>>2]|0)==(v|0)){c[u>>2]=p;w=1;x=c[q>>2]|0}else{w=s;x=v}v=t+4|0;if((c[v>>2]|0)!=(x|0)){y=w;break}c[v>>2]=p;y=1}else{y=s}}while(0);v=c[r>>2]|0;if((v|0)==0){break}else{r=v;s=y}}if((y|0)==0){break}dL(n,0,c[o>>2]|0,c[q>>2]|0,0)|0;dT(n,1)}}while(0);y=200-(e[(c[a+52>>2]|0)+52>>1]|0)|0;w=a+48|0;if((y|0)<(d|0)){x=c[w>>2]|0;b=c[(c[x>>2]|0)+60>>2]|0;l=c[x+16>>2]|0;if((b|0)==0){s=fy(l,10384,(z=i,i=i+16|0,c[z>>2]=y,c[z+8>>2]=10064,z)|0)|0;i=z;A=s}else{s=fy(l,10216,(z=i,i=i+24|0,c[z>>2]=b,c[z+8>>2]=y,c[z+16>>2]=10064,z)|0)|0;i=z;A=s}fe(c[x+12>>2]|0,A,0)}fH(a,h,d+1|0);B=w;C=g|0}else{w=c[a+52>>2]|0;h=fd(a,61)|0;A=fy(w,7112,(z=i,i=i+8|0,c[z>>2]=h,z)|0)|0;i=z;ff(a,A);m=60}do{if((m|0)==60){fi(a);fI(a,g,0)|0;A=a+48|0;if((c[k>>2]|0)==44){z=1;while(1){fi(a);d_(c[A>>2]|0,g);fI(a,g,0)|0;h=z+1|0;if((c[k>>2]|0)==44){z=h}else{D=h;break}}}else{D=1}z=c[A>>2]|0;if((D|0)==(d|0)){dY(z,g);d3(c[A>>2]|0,j,g);i=f;return}n=d-D|0;q=g|0;o=c[q>>2]|0;do{if((o|0)==13|(o|0)==14){h=n+1|0;w=(h|0)<0?0:h;dX(z,g,w);if((w|0)<=1){break}dT(z,w-1|0)}else if((o|0)==0){m=67}else{d_(z,g);m=67}}while(0);do{if((m|0)==67){if((n|0)<=0){break}o=c[z+36>>2]|0;dT(z,n);dK(z,o,n)}}while(0);if((D|0)<=(d|0)){B=A;C=q;break}z=(c[A>>2]|0)+36|0;c[z>>2]=n+(c[z>>2]|0);B=A;C=q}}while(0);d=c[B>>2]|0;B=(c[d+36>>2]|0)-1|0;c[g+16>>2]=-1;c[g+20>>2]=-1;c[C>>2]=12;c[g+8>>2]=B;d3(d,j,g);i=f;return}function fI(e,f,g){e=e|0;f=f|0;g=g|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;j=i;i=i+24|0;k=j|0;l=e+52|0;m=(c[l>>2]|0)+52|0;n=(b[m>>1]|0)+1&65535;b[m>>1]=n;if((n&65535)>200){fe(e,6912,0)}n=e+16|0;switch(c[n>>2]|0){case 265:{fi(e);fK(e,f,0,c[e+4>>2]|0);break};case 45:{o=0;p=81;break};case 35:{o=2;p=81;break};case 270:{o=1;p=81;break};case 284:{c[f+16>>2]=-1;c[f+20>>2]=-1;c[f>>2]=5;c[f+8>>2]=0;h[f+8>>3]=+h[e+24>>3];p=93;break};case 286:{m=dU(c[e+48>>2]|0,c[e+24>>2]|0)|0;c[f+16>>2]=-1;c[f+20>>2]=-1;c[f>>2]=4;c[f+8>>2]=m;p=93;break};case 269:{c[f+16>>2]=-1;c[f+20>>2]=-1;c[f>>2]=1;c[f+8>>2]=0;p=93;break};case 275:{c[f+16>>2]=-1;c[f+20>>2]=-1;c[f>>2]=2;c[f+8>>2]=0;p=93;break};case 263:{c[f+16>>2]=-1;c[f+20>>2]=-1;c[f>>2]=3;c[f+8>>2]=0;p=93;break};case 279:{m=c[e+48>>2]|0;q=m|0;r=c[q>>2]|0;s=a[r+74|0]|0;if(s<<24>>24==0){ff(e,8128);t=c[q>>2]|0;u=t;v=a[t+74|0]|0}else{u=r;v=s}a[u+74|0]=v&-5;v=dL(m,37,0,1,0)|0;c[f+16>>2]=-1;c[f+20>>2]=-1;c[f>>2]=14;c[f+8>>2]=v;p=93;break};case 123:{fJ(e|0,f|0);break};default:{fG(e,f)}}if((p|0)==93){fi(e)}else if((p|0)==81){fi(e);fI(e,f,8)|0;d7(c[e+48>>2]|0,o,f)}switch(c[n>>2]|0){case 45:{w=1;break};case 42:{w=2;break};case 47:{w=3;break};case 37:{w=4;break};case 94:{w=5;break};case 278:{w=6;break};case 283:{w=7;break};case 280:{w=8;break};case 60:{w=9;break};case 282:{w=10;break};case 62:{w=11;break};case 281:{w=12;break};case 257:{w=13;break};case 271:{w=14;break};case 43:{w=0;break};default:{x=15;y=c[l>>2]|0;z=y+52|0;A=b[z>>1]|0;B=A-1&65535;b[z>>1]=B;i=j;return x|0}}n=e+48|0;o=w;while(1){if((d[328+(o<<1)|0]|0)>>>0<=g>>>0){x=o;p=114;break}fi(e);d9(c[n>>2]|0,o,f);w=fI(e,k,d[329+(o<<1)|0]|0)|0;eb(c[n>>2]|0,o,f,k);if((w|0)==15){x=15;p=115;break}else{o=w}}if((p|0)==114){y=c[l>>2]|0;z=y+52|0;A=b[z>>1]|0;B=A-1&65535;b[z>>1]=B;i=j;return x|0}else if((p|0)==115){y=c[l>>2]|0;z=y+52|0;A=b[z>>1]|0;B=A-1&65535;b[z>>1]=B;i=j;return x|0}return 0}function fJ(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;d=i;i=i+40|0;e=d|0;f=a+48|0;g=c[f>>2]|0;h=c[a+4>>2]|0;j=dL(g,10,0,0,0)|0;k=e+36|0;c[k>>2]=0;l=e+28|0;c[l>>2]=0;m=e+32|0;c[m>>2]=0;n=e+24|0;c[n>>2]=b;c[b+16>>2]=-1;c[b+20>>2]=-1;c[b>>2]=11;c[b+8>>2]=j;o=e|0;c[e+16>>2]=-1;c[e+20>>2]=-1;p=e|0;c[p>>2]=0;c[e+8>>2]=0;d_(c[f>>2]|0,b);b=a+16|0;if((c[b>>2]|0)!=123){q=c[a+52>>2]|0;r=fd(a,123)|0;s=fy(q,7112,(t=i,i=i+8|0,c[t>>2]=r,t)|0)|0;i=t;ff(a,s)}fi(a);L148:do{if((c[b>>2]|0)!=125){s=a+32|0;do{do{if((c[p>>2]|0)!=0){d_(g,o);c[p>>2]=0;if((c[k>>2]|0)!=50){break}ed(g,c[(c[n>>2]|0)+8>>2]|0,c[m>>2]|0,50);c[k>>2]=0}}while(0);r=c[b>>2]|0;do{if((r|0)==91){fM(a,e)}else if((r|0)==285){fk(a);if((c[s>>2]|0)==61){fM(a,e);break}fI(a,o,0)|0;q=c[m>>2]|0;if((q|0)>2147483645){u=c[f>>2]|0;v=c[(c[u>>2]|0)+60>>2]|0;w=c[u+16>>2]|0;if((v|0)==0){x=fy(w,10384,(t=i,i=i+16|0,c[t>>2]=2147483645,c[t+8>>2]=2256,t)|0)|0;i=t;y=x}else{x=fy(w,10216,(t=i,i=i+24|0,c[t>>2]=v,c[t+8>>2]=2147483645,c[t+16>>2]=2256,t)|0)|0;i=t;y=x}fe(c[u+12>>2]|0,y,0);z=c[m>>2]|0}else{z=q}c[m>>2]=z+1;c[k>>2]=(c[k>>2]|0)+1}else{fI(a,o,0)|0;q=c[m>>2]|0;if((q|0)>2147483645){u=c[f>>2]|0;x=c[(c[u>>2]|0)+60>>2]|0;v=c[u+16>>2]|0;if((x|0)==0){w=fy(v,10384,(t=i,i=i+16|0,c[t>>2]=2147483645,c[t+8>>2]=2256,t)|0)|0;i=t;A=w}else{w=fy(v,10216,(t=i,i=i+24|0,c[t>>2]=x,c[t+8>>2]=2147483645,c[t+16>>2]=2256,t)|0)|0;i=t;A=w}fe(c[u+12>>2]|0,A,0);B=c[m>>2]|0}else{B=q}c[m>>2]=B+1;c[k>>2]=(c[k>>2]|0)+1}}while(0);r=c[b>>2]|0;if((r|0)==44){fi(a)}else if((r|0)==59){fi(a)}else{break L148}}while((c[b>>2]|0)!=125)}}while(0);fF(a,125,123,h);h=c[k>>2]|0;do{if((h|0)!=0){a=c[p>>2]|0;if((a|0)==13|(a|0)==14){dX(g,o,-1);ed(g,c[(c[n>>2]|0)+8>>2]|0,c[m>>2]|0,-1);c[m>>2]=(c[m>>2]|0)-1;break}else if((a|0)==0){C=h}else{d_(g,o);C=c[k>>2]|0}ed(g,c[(c[n>>2]|0)+8>>2]|0,c[m>>2]|0,C)}}while(0);C=g|0;g=c[(c[(c[C>>2]|0)+12>>2]|0)+(j<<2)>>2]&8388607;n=(fo(c[m>>2]|0)|0)<<23|g;c[(c[(c[C>>2]|0)+12>>2]|0)+(j<<2)>>2]=n;n=c[(c[(c[C>>2]|0)+12>>2]|0)+(j<<2)>>2]&-8372225;g=(fo(c[l>>2]|0)|0)<<14&8372224|n;c[(c[(c[C>>2]|0)+12>>2]|0)+(j<<2)>>2]=g;i=d;return}function fK(f,g,h,j){f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0;k=i;i=i+576|0;l=k|0;fB(f,l);m=l|0;c[(c[m>>2]|0)+60>>2]=j;n=f+16|0;if((c[n>>2]|0)!=40){o=c[f+52>>2]|0;p=fd(f,40)|0;q=fy(o,7112,(r=i,i=i+8|0,c[r>>2]=p,r)|0)|0;i=r;ff(f,q)}fi(f);if((h|0)==0){s=f+48|0}else{fL(f,fg(f,6328,4)|0,0);h=f+48|0;q=c[h>>2]|0;p=q+50|0;o=(a[p]|0)+1&255;a[p]=o;c[(c[(c[q>>2]|0)+24>>2]|0)+((e[q+172+((o&255)-1<<1)>>1]|0)*12|0)+4>>2]=c[q+24>>2];s=h}h=c[s>>2]|0;q=c[h>>2]|0;o=q+74|0;a[o]=0;p=c[n>>2]|0;L198:do{if((p|0)==41){t=0}else{u=f+24|0;v=0;w=p;while(1){if((w|0)==279){break}else if((w|0)==285){x=c[u>>2]|0;fi(f);fL(f,x,v);y=v+1|0}else{ff(f,3504);y=v}if((a[o]|0)!=0){t=y;break L198}if((c[n>>2]|0)!=44){t=y;break L198}fi(f);v=y;w=c[n>>2]|0}fi(f);fL(f,fg(f,4032,3)|0,v);a[o]=7;t=v+1|0}}while(0);y=c[s>>2]|0;p=y+50|0;w=(d[p]|0)+t|0;a[p]=w&255;do{if((t|0)!=0){u=y+24|0;x=y|0;c[(c[(c[x>>2]|0)+24>>2]|0)+((e[y+172+((w&255)-t<<1)>>1]|0)*12|0)+4>>2]=c[u>>2];z=t-1|0;if((z|0)==0){break}else{A=z}do{c[(c[(c[x>>2]|0)+24>>2]|0)+((e[y+172+((d[p]|0)-A<<1)>>1]|0)*12|0)+4>>2]=c[u>>2];A=A-1|0;}while((A|0)!=0)}}while(0);A=h+50|0;a[q+73|0]=(a[A]|0)-(a[o]&1)&255;dT(h,d[A]|0);A=f+52|0;if((c[n>>2]|0)!=41){h=c[A>>2]|0;o=fd(f,41)|0;q=fy(h,7112,(r=i,i=i+8|0,c[r>>2]=o,r)|0)|0;i=r;ff(f,q)}fi(f);q=(c[A>>2]|0)+52|0;r=(b[q>>1]|0)+1&65535;b[q>>1]=r;if((r&65535)>200){fe(f,6912,0)}L220:do{switch(c[n>>2]|0){case 260:case 261:case 262:case 276:case 287:{break L220;break};default:{}}r=fD(f)|0;if((c[n>>2]|0)==59){fi(f)}q=c[s>>2]|0;c[q+36>>2]=d[q+50|0]|0;}while((r|0)==0);n=(c[A>>2]|0)+52|0;b[n>>1]=(b[n>>1]|0)-1&65535;c[(c[m>>2]|0)+64>>2]=c[f+4>>2];fF(f,262,265,j);fC(f);f=c[s>>2]|0;s=c[f>>2]|0;j=s+52|0;n=c[j>>2]|0;r=f+44|0;if(((c[r>>2]|0)+1|0)>(n|0)){q=s+16|0;c[q>>2]=ft(c[A>>2]|0,c[q>>2]|0,j,4,262143,4888)|0;B=c[j>>2]|0;C=q}else{B=n;C=s+16|0}if((n|0)<(B|0)){B=n;while(1){n=B+1|0;c[(c[C>>2]|0)+(B<<2)>>2]=0;if((n|0)<(c[j>>2]|0)){B=n}else{break}}}B=c[m>>2]|0;j=c[r>>2]|0;c[r>>2]=j+1;c[(c[C>>2]|0)+(j<<2)>>2]=B;B=c[m>>2]|0;j=B;do{if((a[B+5|0]&3)!=0){if((a[s+5|0]&4)==0){break}e7(c[A>>2]|0,s,j)}}while(0);j=dN(f,36,0,(c[r>>2]|0)-1|0)|0;c[g+16>>2]=-1;c[g+20>>2]=-1;c[g>>2]=11;c[g+8>>2]=j;if((a[(c[m>>2]|0)+72|0]|0)==0){i=k;return}else{D=0}do{dL(f,(a[l+51+(D<<1)|0]|0)==6?0:4,0,d[l+51+(D<<1)+1|0]|0,0)|0;D=D+1|0;}while((D|0)<(d[(c[m>>2]|0)+72|0]|0));i=k;return}function fL(e,f,g){e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;h=i;j=e+48|0;k=c[j>>2]|0;l=k+50|0;if((g+1+(d[l]|0)|0)>200){m=c[(c[k>>2]|0)+60>>2]|0;n=c[k+16>>2]|0;if((m|0)==0){o=fy(n,10384,(p=i,i=i+16|0,c[p>>2]=200,c[p+8>>2]=2904,p)|0)|0;i=p;q=o}else{o=fy(n,10216,(p=i,i=i+24|0,c[p>>2]=m,c[p+8>>2]=200,c[p+16>>2]=2904,p)|0)|0;i=p;q=o}fe(c[k+12>>2]|0,q,0);r=c[j>>2]|0}else{r=k}j=c[r>>2]|0;q=j+56|0;o=c[q>>2]|0;p=r+48|0;if(((b[p>>1]|0)+1|0)>(o|0)){r=j+24|0;c[r>>2]=ft(c[e+52>>2]|0,c[r>>2]|0,q,12,32767,2552)|0;s=c[q>>2]|0;t=r}else{s=o;t=j+24|0}if((o|0)<(s|0)){s=o;while(1){o=s+1|0;c[(c[t>>2]|0)+(s*12|0)>>2]=0;if((o|0)<(c[q>>2]|0)){s=o}else{break}}}c[(c[t>>2]|0)+((b[p>>1]|0)*12|0)>>2]=f;if((a[f+5|0]&3)==0){u=b[p>>1]|0;v=u+1&65535;b[p>>1]=v;w=a[l]|0;x=w&255;y=x+g|0;z=k+172+(y<<1)|0;b[z>>1]=u;i=h;return}if((a[j+5|0]&4)==0){u=b[p>>1]|0;v=u+1&65535;b[p>>1]=v;w=a[l]|0;x=w&255;y=x+g|0;z=k+172+(y<<1)|0;b[z>>1]=u;i=h;return}e7(c[e+52>>2]|0,j,f);u=b[p>>1]|0;v=u+1&65535;b[p>>1]=v;w=a[l]|0;x=w&255;y=x+g|0;z=k+172+(y<<1)|0;b[z>>1]=u;i=h;return}function fM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;d=i;i=i+48|0;e=d|0;f=d+24|0;g=a+48|0;h=c[g>>2]|0;j=h+36|0;k=c[j>>2]|0;l=a+16|0;if((c[l>>2]|0)==285){m=b+28|0;do{if((c[m>>2]|0)>2147483645){n=c[(c[h>>2]|0)+60>>2]|0;o=c[h+16>>2]|0;if((n|0)==0){p=fy(o,10384,(q=i,i=i+16|0,c[q>>2]=2147483645,c[q+8>>2]=2256,q)|0)|0;i=q;r=p}else{p=fy(o,10216,(q=i,i=i+24|0,c[q>>2]=n,c[q+8>>2]=2147483645,c[q+16>>2]=2256,q)|0)|0;i=q;r=p}fe(c[h+12>>2]|0,r,0);if((c[l>>2]|0)==285){break}p=c[a+52>>2]|0;n=fd(a,285)|0;o=fy(p,7112,(q=i,i=i+8|0,c[q>>2]=n,q)|0)|0;i=q;ff(a,o)}}while(0);r=c[a+24>>2]|0;fi(a);o=dU(c[g>>2]|0,r)|0;c[e+16>>2]=-1;c[e+20>>2]=-1;c[e>>2]=4;c[e+8>>2]=o;s=m}else{fN(a,e);s=b+28|0}c[s>>2]=(c[s>>2]|0)+1;if((c[l>>2]|0)==61){fi(a);t=d2(h,e)|0;u=fI(a,f,0)|0;v=b+24|0;w=c[v>>2]|0;x=w+8|0;y=x;z=c[y>>2]|0;A=d2(h,f)|0;B=dL(h,9,z,t,A)|0;c[j>>2]=k;i=d;return}l=c[a+52>>2]|0;s=fd(a,61)|0;m=fy(l,7112,(q=i,i=i+8|0,c[q>>2]=s,q)|0)|0;i=q;ff(a,m);fi(a);t=d2(h,e)|0;u=fI(a,f,0)|0;v=b+24|0;w=c[v>>2]|0;x=w+8|0;y=x;z=c[y>>2]|0;A=d2(h,f)|0;B=dL(h,9,z,t,A)|0;c[j>>2]=k;i=d;return}function fN(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;fi(a);fI(a,b,0)|0;d1(c[a+48>>2]|0,b);if((c[a+16>>2]|0)==93){fi(a);i=d;return}b=c[a+52>>2]|0;e=fd(a,93)|0;f=fy(b,7112,(b=i,i=i+8|0,c[b>>2]=e,b)|0)|0;i=b;ff(a,f);fi(a);i=d;return}function fO(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0;d=i;i=i+24|0;e=d|0;f=a+48|0;g=c[f>>2]|0;d0(g,b)|0;fi(a);if((c[a+16>>2]|0)!=285){h=c[a+52>>2]|0;j=fd(a,285)|0;k=fy(h,7112,(h=i,i=i+8|0,c[h>>2]=j,h)|0)|0;i=h;ff(a,k)}k=c[a+24>>2]|0;fi(a);a=dU(c[f>>2]|0,k)|0;c[e+16>>2]=-1;c[e+20>>2]=-1;c[e>>2]=4;c[e+8>>2]=a;d6(g,b,e);i=d;return}function fP(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;d=i;i=i+24|0;e=d|0;f=a+48|0;g=c[f>>2]|0;h=c[a+4>>2]|0;j=a+16|0;k=c[j>>2]|0;if((k|0)==123){fJ(a|0,e|0)}else if((k|0)==286){l=dU(g,c[a+24>>2]|0)|0;c[e+16>>2]=-1;c[e+20>>2]=-1;c[e>>2]=4;c[e+8>>2]=l;fi(a)}else if((k|0)==40){if((h|0)!=(c[a+8>>2]|0)){ff(a,9952)}fi(a);if((c[j>>2]|0)==41){c[e>>2]=0}else{fI(a,e,0)|0;if((c[j>>2]|0)==44){do{fi(a);d_(c[f>>2]|0,e);fI(a,e,0)|0;}while((c[j>>2]|0)==44)}dX(g,e,-1)}fF(a,41,40,h)}else{ff(a,9704);i=d;return}a=b+8|0;j=c[a>>2]|0;f=c[e>>2]|0;if((f|0)==0){m=240}else if((f|0)==13|(f|0)==14){n=0}else{d_(g,e);m=240}if((m|0)==240){n=(c[g+36>>2]|0)-j|0}m=dL(g,28,j,n,2)|0;c[b+16>>2]=-1;c[b+20>>2]=-1;c[b>>2]=13;c[a>>2]=m;ea(g,h);c[g+36>>2]=j+1;i=d;return}function fQ(b,f,g,h){b=b|0;f=f|0;g=g|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;j=i;if((b|0)==0){c[g+16>>2]=-1;c[g+20>>2]=-1;c[g>>2]=8;c[g+8>>2]=255;k=8;i=j;return k|0}l=b|0;m=d[b+50|0]|0;while(1){n=m-1|0;if((m|0)<=0){break}if((c[(c[(c[l>>2]|0)+24>>2]|0)+((e[b+172+(n<<1)>>1]|0)*12|0)>>2]|0)==(f|0)){o=250;break}else{m=n}}if((o|0)==250){c[g+16>>2]=-1;c[g+20>>2]=-1;c[g>>2]=6;c[g+8>>2]=n;if((h|0)!=0){k=6;i=j;return k|0}h=b+20|0;while(1){p=c[h>>2]|0;if((p|0)==0){k=6;o=279;break}if((d[p+8|0]|0|0)>(n|0)){h=p|0}else{break}}if((o|0)==279){i=j;return k|0}a[p+9|0]=1;k=6;i=j;return k|0}if((fQ(c[b+8>>2]|0,f,g,0)|0)==8){k=8;i=j;return k|0}p=c[l>>2]|0;l=p+36|0;h=c[l>>2]|0;n=p+72|0;m=a[n]|0;q=m&255;L342:do{if(m<<24>>24==0){r=0;o=261}else{s=c[g>>2]|0;t=g+8|0;u=0;while(1){if((d[b+51+(u<<1)|0]|0|0)==(s|0)){if((d[b+51+(u<<1)+1|0]|0|0)==(c[t>>2]|0)){v=u;break L342}}w=u+1|0;if((w|0)<(q|0)){u=w}else{r=m;o=261;break}}}}while(0);if((o|0)==261){if((q+1|0)>>>0>60){q=c[p+60>>2]|0;o=c[b+16>>2]|0;if((q|0)==0){m=fy(o,10384,(x=i,i=i+16|0,c[x>>2]=60,c[x+8>>2]=9272,x)|0)|0;i=x;y=m}else{m=fy(o,10216,(x=i,i=i+24|0,c[x>>2]=q,c[x+8>>2]=60,c[x+16>>2]=9272,x)|0)|0;i=x;y=m}fe(c[b+12>>2]|0,y,0);z=a[n]|0;A=c[l>>2]|0}else{z=r;A=h}if(((z&255)+1|0)>(A|0)){z=p+28|0;c[z>>2]=ft(c[b+16>>2]|0,c[z>>2]|0,l,4,2147483645,10560)|0;B=c[l>>2]|0;C=z}else{B=A;C=p+28|0}if((h|0)<(B|0)){B=h;while(1){h=B+1|0;c[(c[C>>2]|0)+(B<<2)>>2]=0;if((h|0)<(c[l>>2]|0)){B=h}else{break}}}c[(c[C>>2]|0)+((d[n]|0)<<2)>>2]=f;C=f;do{if((a[f+5|0]&3)!=0){if((a[p+5|0]&4)==0){break}e7(c[b+16>>2]|0,p,C)}}while(0);a[b+51+((d[n]|0)<<1)|0]=c[g>>2]&255;a[b+51+((d[n]|0)<<1)+1|0]=c[g+8>>2]&255;b=a[n]|0;a[n]=b+1&255;v=b&255}c[g+8>>2]=v;c[g>>2]=7;k=7;i=j;return k|0}function fR(b,f,g,h,j){b=b|0;f=f|0;g=g|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;k=i;i=i+16|0;l=k|0;m=b+48|0;n=c[m>>2]|0;o=n+50|0;p=(a[o]|0)+3&255;a[o]=p;q=n+24|0;r=n|0;c[(c[(c[r>>2]|0)+24>>2]|0)+((e[n+172+((p&255)-3<<1)>>1]|0)*12|0)+4>>2]=c[q>>2];c[(c[(c[r>>2]|0)+24>>2]|0)+((e[n+172+((d[o]|0)-2<<1)>>1]|0)*12|0)+4>>2]=c[q>>2];c[(c[(c[r>>2]|0)+24>>2]|0)+((e[n+172+((d[o]|0)-1<<1)>>1]|0)*12|0)+4>>2]=c[q>>2];if((c[b+16>>2]|0)!=259){q=c[b+52>>2]|0;r=fd(b,259)|0;p=fy(q,7112,(q=i,i=i+8|0,c[q>>2]=r,q)|0)|0;i=q;ff(b,p)}fi(b);p=(j|0)!=0;if(p){s=dN(n,32,f,131070)|0}else{s=dM(n)|0}c[l+4>>2]=-1;a[l+10|0]=0;a[l+8|0]=a[o]|0;a[l+9|0]=0;j=n+20|0;c[l>>2]=c[j>>2];c[j>>2]=l;l=c[m>>2]|0;m=l+50|0;q=(d[m]|0)+h|0;a[m]=q&255;do{if((h|0)!=0){r=l+24|0;t=l|0;c[(c[(c[t>>2]|0)+24>>2]|0)+((e[l+172+((q&255)-h<<1)>>1]|0)*12|0)+4>>2]=c[r>>2];u=h-1|0;if((u|0)==0){break}else{v=u}do{c[(c[(c[t>>2]|0)+24>>2]|0)+((e[l+172+((d[m]|0)-v<<1)>>1]|0)*12|0)+4>>2]=c[r>>2];v=v-1|0;}while((v|0)!=0)}}while(0);dT(n,h);fE(b);b=c[j>>2]|0;c[j>>2]=c[b>>2];j=b+8|0;v=a[j]|0;m=c[(c[n+12>>2]|0)+48>>2]|0;l=m+50|0;q=a[l]|0;if((q&255)>(v&255)){r=m+24|0;t=m|0;u=q;do{q=c[r>>2]|0;w=u-1&255;a[l]=w;c[(c[(c[t>>2]|0)+24>>2]|0)+((e[m+172+((w&255)<<1)>>1]|0)*12|0)+8>>2]=q;u=a[l]|0;}while((u&255)>(v&255))}if((a[b+9|0]|0)!=0){v=d[j]|0;dL(n,35,v,0,0)|0}c[n+36>>2]=d[o]|0;dR(n,c[b+4>>2]|0);dR(n,s);if(p){p=dN(n,31,f,131070)|0;ea(n,g);x=p;y=s+1|0;dQ(n,x,y);i=k;return}else{dL(n,33,f,0,h)|0;ea(n,g);x=dM(n)|0;y=s+1|0;dQ(n,x,y);i=k;return}}function fS(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;i=i+24|0;d=b|0;fi(a);fI(a,d,0)|0;e=d|0;if((c[e>>2]|0)==1){c[e>>2]=3}d5(c[a+48>>2]|0,d);e=c[d+20>>2]|0;if((c[a+16>>2]|0)==274){fi(a);fE(a);i=b;return e|0}d=c[a+52>>2]|0;f=fd(a,274)|0;g=fy(d,7112,(d=i,i=i+8|0,c[d>>2]=f,d)|0)|0;i=d;ff(a,g);fi(a);fE(a);i=b;return e|0}function fT(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;d=fu(b,0,0,120)|0;e3(b,d,8);c[d+16>>2]=c[b+16>>2];e=d+32|0;c[e>>2]=0;f=d+44|0;c[f>>2]=0;c[d+112>>2]=0;g=d+68|0;c[g>>2]=0;h=d+56|0;a[h]=0;i=d+60|0;c[i>>2]=0;a[d+57|0]=1;j=d+64|0;c[j>>2]=0;c[d+104>>2]=0;k=d+48|0;a[d+6|0]=0;l=d+20|0;c[l>>2]=0;m=d+40|0;c[m>>2]=0;c[d+24>>2]=0;c[d+116>>2]=0;n=d+80|0;c[n>>2]=0;o=k;c[o>>2]=0;c[o+4>>2]=0;o=fu(b,0,0,192)|0;p=o;c[m>>2]=p;c[l>>2]=p;c[k>>2]=8;c[d+36>>2]=o+168;o=fu(b,0,0,720)|0;k=o;c[e>>2]=k;c[f>>2]=45;f=d+8|0;c[f>>2]=k;c[d+28>>2]=o+624;c[(c[l>>2]|0)+4>>2]=k;k=c[f>>2]|0;c[f>>2]=k+16;c[k+8>>2]=0;k=c[f>>2]|0;c[c[l>>2]>>2]=k;c[d+12>>2]=k;c[(c[l>>2]|0)+8>>2]=(c[f>>2]|0)+320;f=b+72|0;l=d+72|0;k=c[f+4>>2]|0;c[l>>2]=c[f>>2];c[l+4>>2]=k;c[n>>2]=c[b+80>>2];a[h]=a[b+56|0]|0;h=c[b+60>>2]|0;c[i>>2]=h;c[g>>2]=c[b+68>>2];c[j>>2]=h;return d|0}function fU(a,b){a=a|0;b=b|0;var d=0;d=b+32|0;eU(b,c[d>>2]|0);fu(a,c[b+40>>2]|0,(c[b+48>>2]|0)*24|0,0)|0;fu(a,c[d>>2]|0,c[b+44>>2]<<4,0)|0;fu(a,b,120,0)|0;return}function fV(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;e=cg[b&511](d,0,0,376)|0;if((e|0)==0){f=0;return f|0}g=e;h=e+120|0;c[e>>2]=0;a[e+4|0]=8;a[e+140|0]=33;a[e+5|0]=97;i=e+16|0;c[i>>2]=h;j=e+32|0;c[j>>2]=0;k=e+44|0;c[k>>2]=0;c[e+112>>2]=0;c[e+68>>2]=0;a[e+56|0]=0;c[e+60>>2]=0;a[e+57|0]=1;c[e+64>>2]=0;c[e+104>>2]=0;l=e+48|0;a[e+6|0]=0;c[e+20>>2]=0;m=e+40|0;c[m>>2]=0;c[e+24>>2]=0;c[e+116>>2]=0;c[e+80>>2]=0;n=l;c[n>>2]=0;c[n+4>>2]=0;c[e+132>>2]=b;c[e+136>>2]=d;c[e+232>>2]=g;d=e+240|0;c[e+256>>2]=d;c[e+260>>2]=d;c[e+184>>2]=0;c[e+128>>2]=0;c[e+124>>2]=0;c[h>>2]=0;c[e+224>>2]=0;c[e+172>>2]=0;c[e+180>>2]=0;c[e+208>>2]=0;a[e+141|0]=0;h=e+148|0;c[h>>2]=e;c[e+144>>2]=0;c[e+152>>2]=h;j2(e+156|0,0,16);c[e+188>>2]=376;c[e+200>>2]=200;c[e+204>>2]=200;c[e+196>>2]=0;j2(e+272|0,0,36);if((ex(g,254,0)|0)==0){f=g;return f|0}h=c[i>>2]|0;eU(g,c[j>>2]|0);e$(g);d=c[i>>2]|0;fu(g,c[d>>2]|0,c[d+8>>2]<<2,0)|0;d=h+52|0;i=h+60|0;c[d>>2]=fu(g,c[d>>2]|0,c[i>>2]|0,0)|0;c[i>>2]=0;fu(g,c[m>>2]|0,(c[l>>2]|0)*24|0,0)|0;fu(g,c[j>>2]|0,c[k>>2]<<4,0)|0;cg[c[h+12>>2]&511](c[h+16>>2]|0,e,376,0)|0;f=0;return f|0}function fW(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;d=b+16|0;e=c[d>>2]|0;f=fu(b,0,0,192)|0;g=f;c[b+40>>2]=g;h=b+20|0;c[h>>2]=g;c[b+48>>2]=8;c[b+36>>2]=f+168;f=fu(b,0,0,720)|0;g=f;c[b+32>>2]=g;c[b+44>>2]=45;i=b+8|0;c[i>>2]=g;c[b+28>>2]=f+624;c[(c[h>>2]|0)+4>>2]=g;g=c[i>>2]|0;c[i>>2]=g+16;c[g+8>>2]=0;g=c[i>>2]|0;c[c[h>>2]>>2]=g;c[b+12>>2]=g;c[(c[h>>2]|0)+8>>2]=(c[i>>2]|0)+320;c[b+72>>2]=f5(b,0,2)|0;c[b+80>>2]=5;i=c[d>>2]|0;c[i+96>>2]=f5(b,0,2)|0;c[i+104>>2]=5;fZ(b,32);ge(b);fc(b);i=(f_(b,8768,17)|0)+5|0;a[i]=a[i]|32;c[e+64>>2]=c[e+68>>2]<<2;return}function fX(a){a=a|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;d=c[(c[a+16>>2]|0)+112>>2]|0;a=d+32|0;eU(d,c[a>>2]|0);eY(d,1)|0;c[d+116>>2]=0;e=d+40|0;f=d+20|0;g=d+8|0;h=d+12|0;i=d+54|0;j=d+52|0;do{k=c[e>>2]|0;c[f>>2]=k;l=c[k>>2]|0;c[g>>2]=l;c[h>>2]=l;b[i>>1]=0;b[j>>1]=0;}while((ex(d,256,0)|0)!=0);j=d+16|0;i=c[j>>2]|0;eU(d,c[a>>2]|0);e$(d);h=c[j>>2]|0;fu(d,c[h>>2]|0,c[h+8>>2]<<2,0)|0;h=i+52|0;j=i+60|0;c[h>>2]=fu(d,c[h>>2]|0,c[j>>2]|0,0)|0;c[j>>2]=0;fu(d,c[e>>2]|0,(c[d+48>>2]|0)*24|0,0)|0;fu(d,c[a>>2]|0,c[d+44>>2]<<4,0)|0;cg[c[i+12>>2]&511](c[i+16>>2]|0,d,376,0)|0;return}function fY(a,b){a=a|0;b=b|0;eZ(a);return}function fZ(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;e=b+16|0;if((a[(c[e>>2]|0)+21|0]|0)==2){return}if((d+1|0)>>>0<1073741824){f=fu(b,0,0,d<<2)|0}else{f=fv(b)|0}g=f;h=c[e>>2]|0;if((d|0)>0){j2(f|0,0,d<<2|0)}f=h+8|0;e=c[f>>2]|0;i=h|0;h=c[i>>2]|0;if((e|0)>0){j=d-1|0;k=0;l=h;m=e;while(1){n=c[l+(k<<2)>>2]|0;if((n|0)==0){o=m;p=l}else{q=n;while(1){n=q|0;r=c[n>>2]|0;s=g+((c[q+8>>2]&j)<<2)|0;c[n>>2]=c[s>>2];c[s>>2]=q;if((r|0)==0){break}else{q=r}}o=c[f>>2]|0;p=c[i>>2]|0}q=k+1|0;if((q|0)<(o|0)){k=q;l=p;m=o}else{t=o;u=p;break}}}else{t=e;u=h}fu(b,u,t<<2,0)|0;c[f>>2]=d;c[i>>2]=g;return}function f_(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;g=(f>>>5)+1|0;if(g>>>0>f>>>0){h=f}else{i=f;j=f;while(1){k=(i<<5)+(i>>>2)+(d[e+(j-1)|0]|0)^i;l=j-g|0;if(l>>>0<g>>>0){h=k;break}else{i=k;j=l}}}j=b+16|0;i=c[j>>2]|0;g=c[(c[i>>2]|0)+(((c[i+8>>2]|0)-1&h)<<2)>>2]|0;L449:do{if((g|0)!=0){l=g;while(1){if((c[l+12>>2]|0)==(f|0)){m=l;if((j5(e|0,l+16|0,f|0)|0)==0){break}}k=c[l>>2]|0;if((k|0)==0){break L449}else{l=k}}k=l+5|0;n=a[k]|0;if((n&3&((d[i+20|0]|0)^3)|0)==0){o=m;return o|0}a[k]=n^3;o=m;return o|0}}while(0);if((f+1|0)>>>0>4294967277){fv(b)|0}m=fu(b,0,0,f+17|0)|0;i=m;c[m+12>>2]=f;c[m+8>>2]=h;a[m+5|0]=a[(c[j>>2]|0)+20|0]&3;a[m+4|0]=4;a[m+6|0]=0;g=m+16|0;j$(g|0,e|0,f)|0;a[m+(f+16)|0]=0;f=c[j>>2]|0;j=f+8|0;e=(c[j>>2]|0)-1&h;h=f|0;c[m>>2]=c[(c[h>>2]|0)+(e<<2)>>2];c[(c[h>>2]|0)+(e<<2)>>2]=m;m=f+4|0;f=(c[m>>2]|0)+1|0;c[m>>2]=f;m=c[j>>2]|0;if(!(f>>>0>m>>>0&(m|0)<1073741823)){o=i;return o|0}fZ(b,m<<1);o=i;return o|0}function f$(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;if(d>>>0>4294967269){fv(b)|0}f=fu(b,0,0,d+24|0)|0;g=b+16|0;a[f+5|0]=a[(c[g>>2]|0)+20|0]&3;a[f+4|0]=7;c[f+16>>2]=d;c[f+8>>2]=0;c[f+12>>2]=e;c[f>>2]=c[c[(c[g>>2]|0)+112>>2]>>2];c[c[(c[g>>2]|0)+112>>2]>>2]=f;return f|0}function f0(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;f=i;g=e+8|0;L473:do{switch(c[g>>2]|0){case 4:{j=(c[b+16>>2]|0)+(((1<<(d[b+7|0]|0))-1&c[(c[e>>2]|0)+8>>2])<<5)|0;k=370;break};case 1:{j=(c[b+16>>2]|0)+(((1<<(d[b+7|0]|0))-1&c[e>>2])<<5)|0;k=370;break};case 2:{j=(c[b+16>>2]|0)+((((c[e>>2]|0)>>>0)%(((1<<(d[b+7|0]|0))-1|1)>>>0)|0)<<5)|0;k=370;break};case 0:{l=-1;break};case 3:{m=e|0;n=+h[m>>3];o=c[m>>2]|0;p=c[m+4>>2]|0;m=~~n;do{if(+(m|0)==n&(m|0)>0){if((m|0)>(c[b+28>>2]|0)){break}l=m-1|0;break L473}}while(0);if(n==0.0){j=c[b+16>>2]|0;k=370;break L473}else{j=(c[b+16>>2]|0)+((((p+o|0)>>>0)%(((1<<(d[b+7|0]|0))-1|1)>>>0)|0)<<5)|0;k=370;break L473}break};default:{j=(c[b+16>>2]|0)+((((c[e>>2]|0)>>>0)%(((1<<(d[b+7|0]|0))-1|1)>>>0)|0)<<5)|0;k=370}}}while(0);do{if((k|0)==370){m=e;q=j;L488:while(1){r=q+16|0;if((fr(r,e)|0)!=0){k=375;break}do{if((c[q+24>>2]|0)==11){if((c[g>>2]|0)<=3){break}if((c[r>>2]|0)==(c[m>>2]|0)){k=375;break L488}}}while(0);r=c[q+28>>2]|0;if((r|0)==0){k=377;break}else{q=r}}if((k|0)==375){l=(q-(c[b+16>>2]|0)>>5)+(c[b+28>>2]|0)|0;break}else if((k|0)==377){es(a,6216,(m=i,i=i+1|0,i=i+7>>3<<3,c[m>>2]=0,m)|0);i=m;l=0;break}}}while(0);a=c[b+28>>2]|0;j=b+12|0;m=l;while(1){s=m+1|0;if((s|0)>=(a|0)){break}if((c[(c[j>>2]|0)+(s<<4)+8>>2]|0)==0){m=s}else{k=381;break}}if((k|0)==381){h[e>>3]=+(m+2|0);c[g>>2]=3;m=c[j>>2]|0;j=m+(s<<4)|0;l=e+16|0;o=c[j+4>>2]|0;c[l>>2]=c[j>>2];c[l+4>>2]=o;c[e+24>>2]=c[m+(s<<4)+8>>2];t=1;i=f;return t|0}m=1<<(d[b+7|0]|0);o=b+16|0;b=s-a|0;while(1){if((b|0)>=(m|0)){t=0;k=389;break}u=c[o>>2]|0;if((c[u+(b<<5)+8>>2]|0)==0){b=b+1|0}else{break}}if((k|0)==389){i=f;return t|0}k=u+(b<<5)+16|0;m=e;a=c[k+4>>2]|0;c[m>>2]=c[k>>2];c[m+4>>2]=a;c[g>>2]=c[u+(b<<5)+24>>2];u=c[o>>2]|0;o=u+(b<<5)|0;g=e+16|0;a=c[o+4>>2]|0;c[g>>2]=c[o>>2];c[g+4>>2]=a;c[e+24>>2]=c[u+(b<<5)+8>>2];t=1;i=f;return t|0}function f1(a,b,e){a=a|0;b=b|0;e=e|0;var f=0;if((c[b+16>>2]|0)==1656){f=0}else{f=1<<(d[b+7|0]|0)}f2(a,b,e,f);return}function f2(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0.0,B=0,C=0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;j=i;i=i+16|0;l=j|0;m=e+28|0;n=c[m>>2]|0;o=e+7|0;p=d[o]|0;q=e+16|0;r=c[q>>2]|0;if((n|0)<(f|0)){if((f+1|0)>>>0<268435456){s=e+12|0;t=fu(b,c[s>>2]|0,n<<4,f<<4)|0;u=s}else{t=fv(b)|0;u=e+12|0}s=t;c[u>>2]=s;t=c[m>>2]|0;do{if((t|0)<(f|0)){c[s+(t<<4)+8>>2]=0;v=t+1|0;if((v|0)<(f|0)){w=v}else{break}do{c[(c[u>>2]|0)+(w<<4)+8>>2]=0;w=w+1|0;}while((w|0)<(f|0))}}while(0);c[m>>2]=f}f6(b,e,g);if((n|0)>(f|0)){c[m>>2]=f;g=e+12|0;w=l|0;u=l+8|0;t=f;while(1){s=c[g>>2]|0;v=s+(t<<4)+8|0;x=t+1|0;if((c[v>>2]|0)!=0){L536:do{if(t>>>0<(c[m>>2]|0)>>>0){y=s+(t<<4)|0;z=413}else{A=+(x|0);if((x|0)==0){B=c[q>>2]|0}else{h[k>>3]=A;B=(c[q>>2]|0)+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[o]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[B+24>>2]|0)==3){if(+h[B+16>>3]==A){break}}C=c[B+28>>2]|0;if((C|0)==0){E=A;z=415;break L536}else{B=C}}y=B|0;z=413}}while(0);do{if((z|0)==413){z=0;if((y|0)!=1032){F=y;break}E=+(x|0);z=415}}while(0);if((z|0)==415){z=0;h[w>>3]=E;c[u>>2]=3;F=gb(b,e,l)|0}C=s+(t<<4)|0;G=F;H=c[C+4>>2]|0;c[G>>2]=c[C>>2];c[G+4>>2]=H;c[F+8>>2]=c[v>>2]}if((x|0)<(n|0)){t=x}else{break}}if((f+1|0)>>>0<268435456){t=e+12|0;I=fu(b,c[t>>2]|0,n<<4,f<<4)|0;J=t}else{I=fv(b)|0;J=e+12|0}c[J>>2]=I}I=1<<p;if((I|0)>0){p=e+6|0;J=I;do{J=J-1|0;t=r+(J<<5)+8|0;if((c[t>>2]|0)!=0){f=r+(J<<5)|0;n=r+(J<<5)+16|0;F=n;l=f8(e,F)|0;a[p]=0;if((l|0)==1032){u=c[r+(J<<5)+24>>2]|0;do{if((u|0)==3){E=+h[n>>3];if(E==E&!(D=0.0,D!=D)){break}es(b,10016,(K=i,i=i+1|0,i=i+7>>3<<3,c[K>>2]=0,K)|0);i=K}else if((u|0)==0){es(b,8512,(K=i,i=i+1|0,i=i+7>>3<<3,c[K>>2]=0,K)|0);i=K}}while(0);L=gb(b,e,F)|0}else{L=l}u=f;n=L;x=c[u+4>>2]|0;c[n>>2]=c[u>>2];c[n+4>>2]=x;c[L+8>>2]=c[t>>2]}}while((J|0)>0)}if((r|0)==1656){i=j;return}fu(b,r,I<<5,0)|0;i=j;return}function f3(a,b){a=a|0;b=b|0;var e=0,f=0,g=0.0,i=0,j=0;e=b-1|0;if(e>>>0<(c[a+28>>2]|0)>>>0){f=(c[a+12>>2]|0)+(e<<4)|0;return f|0}g=+(b|0);if((b|0)==0){i=c[a+16>>2]|0}else{h[k>>3]=g;i=(c[a+16>>2]|0)+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[a+7|0]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[i+24>>2]|0)==3){if(+h[i+16>>3]==g){break}}a=c[i+28>>2]|0;if((a|0)==0){f=1032;j=449;break}else{i=a}}if((j|0)==449){return f|0}f=i|0;return f|0}function f4(a,b){a=a|0;b=b|0;var e=0,f=0,g=0;e=(c[a+16>>2]|0)+(((1<<(d[a+7|0]|0))-1&c[b+8>>2])<<5)|0;while(1){if((c[e+24>>2]|0)==4){if((c[e+16>>2]|0)==(b|0)){break}}a=c[e+28>>2]|0;if((a|0)==0){f=1032;g=458;break}else{e=a}}if((g|0)==458){return f|0}f=e|0;return f|0}function f5(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0;f=fu(b,0,0,32)|0;g=f;e3(b,f,5);c[f+8>>2]=0;a[f+6|0]=-1;h=f+12|0;c[h>>2]=0;i=f+28|0;c[i>>2]=0;a[f+7|0]=0;c[f+16>>2]=1656;if((d+1|0)>>>0<268435456){j=fu(b,0,0,d<<4)|0}else{j=fv(b)|0}f=j;c[h>>2]=f;j=c[i>>2]|0;if((j|0)>=(d|0)){c[i>>2]=d;f6(b,g,e);return g|0}c[f+(j<<4)+8>>2]=0;f=j+1|0;if((f|0)<(d|0)){k=f}else{c[i>>2]=d;f6(b,g,e);return g|0}do{c[(c[h>>2]|0)+(k<<4)+8>>2]=0;k=k+1|0;}while((k|0)<(d|0));c[i>>2]=d;f6(b,g,e);return g|0}function f6(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f=i;do{if((e|0)==0){c[d+16>>2]=1656;g=0;h=0;j=1656}else{k=(fq(e-1|0)|0)+1|0;if((k|0)>26){es(b,8040,(l=i,i=i+1|0,i=i+7>>3<<3,c[l>>2]=0,l)|0);i=l}l=1<<k;if((l+1|0)>>>0<134217728){m=fu(b,0,0,l<<5)|0}else{m=fv(b)|0}n=m;o=d+16|0;c[o>>2]=n;p=k&255;if((l|0)>0){q=0;r=n}else{g=l;h=p;j=n;break}while(1){c[r+(q<<5)+28>>2]=0;c[r+(q<<5)+24>>2]=0;c[r+(q<<5)+8>>2]=0;n=q+1|0;k=c[o>>2]|0;if((n|0)<(l|0)){q=n;r=k}else{g=l;h=p;j=k;break}}}}while(0);a[d+7|0]=h;c[d+20>>2]=j+(g<<5);i=f;return}function f7(a,b){a=a|0;b=b|0;var e=0,f=0;e=c[b+16>>2]|0;if((e|0)!=1656){f=e;e=32<<(d[b+7|0]|0);fu(a,f,e,0)|0}fu(a,c[b+12>>2]|0,c[b+28>>2]<<4,0)|0;fu(a,b,32,0)|0;return}function f8(a,b){a=a|0;b=b|0;var e=0,f=0,g=0.0,i=0,j=0.0,l=0,m=0,n=0,o=0;L640:do{switch(c[b+8>>2]|0){case 0:{e=1032;return e|0};case 1:{f=(c[a+16>>2]|0)+(((1<<(d[a+7|0]|0))-1&c[b>>2])<<5)|0;break};case 2:{f=(c[a+16>>2]|0)+((((c[b>>2]|0)>>>0)%(((1<<(d[a+7|0]|0))-1|1)>>>0)|0)<<5)|0;break};case 3:{g=+h[b>>3];i=~~g;j=+(i|0);if(j!=g){l=b|0;if(+h[l>>3]==0.0){f=c[a+16>>2]|0;break L640}else{f=(c[a+16>>2]|0)+(((((c[l+4>>2]|0)+(c[l>>2]|0)|0)>>>0)%(((1<<(d[a+7|0]|0))-1|1)>>>0)|0)<<5)|0;break L640}}l=i-1|0;if(l>>>0<(c[a+28>>2]|0)>>>0){e=(c[a+12>>2]|0)+(l<<4)|0;return e|0}if((i|0)==0){m=c[a+16>>2]|0}else{h[k>>3]=j;m=(c[a+16>>2]|0)+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[a+7|0]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[m+24>>2]|0)==3){if(+h[m+16>>3]==j){break}}i=c[m+28>>2]|0;if((i|0)==0){e=1032;n=514;break}else{m=i}}if((n|0)==514){return e|0}e=m|0;return e|0};case 4:{i=c[b>>2]|0;l=(c[a+16>>2]|0)+(((1<<(d[a+7|0]|0))-1&c[i+8>>2])<<5)|0;while(1){if((c[l+24>>2]|0)==4){if((c[l+16>>2]|0)==(i|0)){break}}o=c[l+28>>2]|0;if((o|0)==0){e=1032;n=511;break}else{l=o}}if((n|0)==511){return e|0}e=l|0;return e|0};default:{f=(c[a+16>>2]|0)+((((c[b>>2]|0)>>>0)%(((1<<(d[a+7|0]|0))-1|1)>>>0)|0)<<5)|0}}}while(0);while(1){if((fr(f+16|0,b)|0)!=0){break}a=c[f+28>>2]|0;if((a|0)==0){e=1032;n=510;break}else{f=a}}if((n|0)==510){return e|0}e=f|0;return e|0}function f9(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,j=0,k=0,l=0.0;f=i;g=f8(d,e)|0;a[d+6|0]=0;if((g|0)!=1032){j=g;i=f;return j|0}g=c[e+8>>2]|0;do{if((g|0)==0){es(b,8512,(k=i,i=i+1|0,i=i+7>>3<<3,c[k>>2]=0,k)|0);i=k}else if((g|0)==3){l=+h[e>>3];if(l==l&!(D=0.0,D!=D)){break}es(b,10016,(k=i,i=i+1|0,i=i+7>>3<<3,c[k>>2]=0,k)|0);i=k}}while(0);j=gb(b,d,e)|0;i=f;return j|0}function ga(a){a=a|0;var b=0,e=0,f=0,g=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;b=c[a+28>>2]|0;do{if((b|0)!=0){e=c[a+12>>2]|0;if((c[e+(b-1<<4)+8>>2]|0)!=0){break}if(b>>>0>1){f=b;g=0}else{i=0;return i|0}while(1){j=(g+f|0)>>>1;l=(c[e+(j-1<<4)+8>>2]|0)==0;m=l?j:f;n=l?g:j;if((m-n|0)>>>0>1){f=m;g=n}else{i=n;break}}return i|0}}while(0);g=c[a+16>>2]|0;if((g|0)==1656){i=b;return i|0}f=a+12|0;e=a+7|0;a=b;n=b+1|0;while(1){m=n-1|0;L710:do{if(m>>>0<b>>>0){o=(c[f>>2]|0)+(m<<4)|0}else{p=+(n|0);if((n|0)==0){q=g}else{h[k>>3]=p;q=g+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[e]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[q+24>>2]|0)==3){if(+h[q+16>>3]==p){break}}j=c[q+28>>2]|0;if((j|0)==0){o=1032;break L710}else{q=j}}o=q|0}}while(0);if((c[o+8>>2]|0)==0){break}m=n<<1;if(m>>>0>2147483645){r=1;s=542;break}else{a=n;n=m}}if((s|0)==542){while(1){s=0;o=r-1|0;L726:do{if(o>>>0<b>>>0){t=(c[f>>2]|0)+(o<<4)|0}else{p=+(r|0);if((r|0)==0){u=g}else{h[k>>3]=p;u=g+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[e]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[u+24>>2]|0)==3){if(+h[u+16>>3]==p){break}}q=c[u+28>>2]|0;if((q|0)==0){t=1032;break L726}else{u=q}}t=u|0}}while(0);if((c[t+8>>2]|0)==0){i=o;break}else{r=r+1|0;s=542}}return i|0}if((n-a|0)>>>0>1){v=n;w=a}else{i=a;return i|0}while(1){a=(v+w|0)>>>1;n=a-1|0;L744:do{if(n>>>0<b>>>0){x=(c[f>>2]|0)+(n<<4)|0}else{p=+(a|0);if((a|0)==0){y=g}else{h[k>>3]=p;y=g+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[e]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[y+24>>2]|0)==3){if(+h[y+16>>3]==p){break}}s=c[y+28>>2]|0;if((s|0)==0){x=1032;break L744}else{y=s}}x=y|0}}while(0);n=(c[x+8>>2]|0)==0;o=n?a:v;s=n?w:a;if((o-s|0)>>>0>1){v=o;w=s}else{i=s;break}}return i|0}function gb(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0;g=i;i=i+112|0;j=g|0;k=j;l=f+8|0;m=c[l>>2]|0;do{if((m|0)==2){n=c[e+16>>2]|0;o=n+((((c[f>>2]|0)>>>0)%(((1<<(d[e+7|0]|0))-1|1)>>>0)|0)<<5)|0;p=n}else if((m|0)==1){n=c[e+16>>2]|0;o=n+(((1<<(d[e+7|0]|0))-1&c[f>>2])<<5)|0;p=n}else if((m|0)==3){n=f|0;if(+h[n>>3]==0.0){q=c[e+16>>2]|0;o=q;p=q;break}else{q=c[e+16>>2]|0;o=q+(((((c[n+4>>2]|0)+(c[n>>2]|0)|0)>>>0)%(((1<<(d[e+7|0]|0))-1|1)>>>0)|0)<<5)|0;p=q;break}}else if((m|0)==4){q=c[e+16>>2]|0;o=q+(((1<<(d[e+7|0]|0))-1&c[(c[f>>2]|0)+8>>2])<<5)|0;p=q}else{q=c[e+16>>2]|0;o=q+((((c[f>>2]|0)>>>0)%(((1<<(d[e+7|0]|0))-1|1)>>>0)|0)<<5)|0;p=q}}while(0);m=o+8|0;L768:do{if((c[m>>2]|0)!=0|(o|0)==1656){q=e+20|0;n=e+16|0;r=c[q>>2]|0;while(1){s=r-32|0;c[q>>2]=s;if(r>>>0<=p>>>0){break}if((c[r-32+24>>2]|0)==0){t=579;break}else{r=s}}do{if((t|0)==579){if((s|0)==0){break}q=o+16|0;u=c[o+24>>2]|0;do{if((u|0)==4){v=p+(((1<<(d[e+7|0]|0))-1&c[(c[q>>2]|0)+8>>2])<<5)|0}else if((u|0)==1){v=p+(((1<<(d[e+7|0]|0))-1&c[q>>2])<<5)|0}else if((u|0)==2){v=p+((((c[q>>2]|0)>>>0)%(((1<<(d[e+7|0]|0))-1|1)>>>0)|0)<<5)|0}else if((u|0)==3){w=q|0;if(+h[w>>3]==0.0){v=p;break}v=p+(((((c[w+4>>2]|0)+(c[w>>2]|0)|0)>>>0)%(((1<<(d[e+7|0]|0))-1|1)>>>0)|0)<<5)|0}else{v=p+((((c[q>>2]|0)>>>0)%(((1<<(d[e+7|0]|0))-1|1)>>>0)|0)<<5)|0}}while(0);if((v|0)==(o|0)){q=o+28|0;c[r-32+28>>2]=c[q>>2];c[q>>2]=s;x=s;break L768}else{y=v}do{z=y+28|0;y=c[z>>2]|0;}while((y|0)!=(o|0));c[z>>2]=s;q=s;u=o;c[q>>2]=c[u>>2];c[q+4>>2]=c[u+4>>2];c[q+8>>2]=c[u+8>>2];c[q+12>>2]=c[u+12>>2];c[q+16>>2]=c[u+16>>2];c[q+20>>2]=c[u+20>>2];c[q+24>>2]=c[u+24>>2];c[q+28>>2]=c[u+28>>2];c[o+28>>2]=0;c[m>>2]=0;x=o;break L768}}while(0);j2(k|0,0,108);r=e+12|0;u=c[e+28>>2]|0;q=0;w=1;A=0;B=1;while(1){if((w|0)>(u|0)){if((B|0)>(u|0)){C=A;break}else{E=u}}else{E=w}if((B|0)>(E|0)){F=B;G=0}else{H=c[r>>2]|0;I=B;J=0;while(1){K=((c[H+(I-1<<4)+8>>2]|0)!=0)+J|0;L=I+1|0;if((L|0)>(E|0)){F=L;G=K;break}else{I=L;J=K}}}J=j+(q<<2)|0;c[J>>2]=(c[J>>2]|0)+G;J=G+A|0;I=q+1|0;if((I|0)<27){q=I;w=w<<1;A=J;B=F}else{C=J;break}}B=0;A=1<<(d[e+7|0]|0);w=0;L801:while(1){q=A;while(1){M=q-1|0;if((q|0)==0){break L801}N=c[n>>2]|0;if((c[N+(M<<5)+8>>2]|0)==0){q=M}else{break}}do{if((c[N+(M<<5)+24>>2]|0)==3){O=+h[N+(M<<5)+16>>3];q=~~O;r=q-1|0;if(!(+(q|0)==O&r>>>0<67108864)){P=0;break}q=j+((fq(r)|0)+1<<2)|0;c[q>>2]=(c[q>>2]|0)+1;P=1}else{P=0}}while(0);B=B+1|0;A=M;w=P+w|0}A=w+C|0;do{if((c[l>>2]|0)==3){O=+h[f>>3];n=~~O;q=n-1|0;if(!(+(n|0)==O&q>>>0<67108864)){Q=0;break}n=j+((fq(q)|0)+1<<2)|0;c[n>>2]=(c[n>>2]|0)+1;Q=1}else{Q=0}}while(0);w=A+Q|0;L816:do{if((w|0)>0){n=0;q=1;r=0;u=0;J=0;I=0;while(1){H=c[j+(n<<2)>>2]|0;if((H|0)>0){K=H+r|0;H=(K|0)>(I|0);R=H?q:J;S=H?K:u;T=K}else{R=J;S=u;T=r}if((T|0)==(w|0)){U=R;V=S;break L816}K=q<<1;H=(K|0)/2|0;if((H|0)<(w|0)){n=n+1|0;q=K;r=T;u=S;J=R;I=H}else{U=R;V=S;break}}}else{U=0;V=0}}while(0);f2(b,e,U,C+1+B-V|0);w=f8(e,f)|0;a[e+6|0]=0;if((w|0)!=1032){W=w;i=g;return W|0}w=c[l>>2]|0;do{if((w|0)==0){es(b,8512,(X=i,i=i+1|0,i=i+7>>3<<3,c[X>>2]=0,X)|0);i=X}else if((w|0)==3){O=+h[f>>3];if(O==O&!(D=0.0,D!=D)){break}es(b,10016,(X=i,i=i+1|0,i=i+7>>3<<3,c[X>>2]=0,X)|0);i=X}}while(0);W=gb(b,e,f)|0;i=g;return W|0}else{x=o}}while(0);o=f;X=x+16|0;V=c[o+4>>2]|0;c[X>>2]=c[o>>2];c[X+4>>2]=V;c[x+24>>2]=c[l>>2];do{if((c[l>>2]|0)>3){if((a[(c[f>>2]|0)+5|0]&3)==0){break}if((a[e+5|0]&4)==0){break}e2(b,e)}}while(0);W=x|0;i=g;return W|0}function gc(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,j=0,l=0,m=0,n=0.0,o=0,p=0,q=0.0,r=0;f=i;i=i+16|0;g=f|0;j=e-1|0;L841:do{if(j>>>0<(c[b+28>>2]|0)>>>0){l=(c[b+12>>2]|0)+(j<<4)|0;m=638}else{n=+(e|0);if((e|0)==0){o=c[b+16>>2]|0}else{h[k>>3]=n;o=(c[b+16>>2]|0)+(((((c[k+4>>2]|0)+(c[k>>2]|0)|0)>>>0)%(((1<<(d[b+7|0]|0))-1|1)>>>0)|0)<<5)|0}while(1){if((c[o+24>>2]|0)==3){if(+h[o+16>>3]==n){break}}p=c[o+28>>2]|0;if((p|0)==0){q=n;break L841}else{o=p}}l=o|0;m=638}}while(0);do{if((m|0)==638){if((l|0)==1032){q=+(e|0);break}else{r=l;i=f;return r|0}}}while(0);h[g>>3]=q;c[g+8>>2]=3;r=gb(a,b,g)|0;i=f;return r|0}function gd(a,b,e){a=a|0;b=b|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0;f=i;i=i+16|0;g=f|0;h=(c[b+16>>2]|0)+(((1<<(d[b+7|0]|0))-1&c[e+8>>2])<<5)|0;while(1){if((c[h+24>>2]|0)==4){if((c[h+16>>2]|0)==(e|0)){j=648;break}}k=c[h+28>>2]|0;if((k|0)==0){break}else{h=k}}do{if((j|0)==648){k=h|0;if((k|0)==1032){break}else{l=k}i=f;return l|0}}while(0);c[g>>2]=e;c[g+8>>2]=4;l=gb(a,b,g)|0;i=f;return l|0}function ge(b){b=b|0;var d=0,e=0,f=0,g=0;d=b+16|0;e=0;do{f=c[920+(e<<2)>>2]|0;g=f_(b,f,j_(f|0)|0)|0;c[(c[d>>2]|0)+188+(e<<2)>>2]=g;g=(c[(c[d>>2]|0)+188+(e<<2)>>2]|0)+5|0;a[g]=a[g]|32;e=e+1|0;}while((e|0)<17);return}function gf(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0;g=f4(b,f)|0;if((c[g+8>>2]|0)!=0){h=g;return h|0}g=b+6|0;a[g]=(d[g]|0|1<<e)&255;h=0;return h|0}function gg(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=c[b+8>>2]|0;if((e|0)==5){f=c[(c[b>>2]|0)+8>>2]|0}else if((e|0)==7){f=c[(c[b>>2]|0)+8>>2]|0}else{f=c[(c[a+16>>2]|0)+152+(e<<2)>>2]|0}if((f|0)==0){g=1032;return g|0}g=f4(f,c[(c[a+16>>2]|0)+188+(d<<2)>>2]|0)|0;return g|0}function gh(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;g=i;i=i+48|0;h=g|0;j=g+16|0;k=g+32|0;l=a[f]|0;if((l<<24>>24|0)==64|(l<<24>>24|0)==61){m=f+1|0;c[k+12>>2]=m;n=m}else if((l<<24>>24|0)==27){c[k+12>>2]=9800;n=9800}else{c[k+12>>2]=f;n=f}f=k|0;c[f>>2]=b;c[k+4>>2]=d;c[k+8>>2]=e;e=h;l=j|0;c[h>>2]=1635077147;a[h+4|0]=81;a[e+5|0]=0;a[e+6|0]=1;a[e+7|0]=4;a[h+8|0]=4;a[e+9|0]=4;a[e+10|0]=8;a[e+11|0]=0;if((gw(d,l,12)|0)!=0){fy(b,2512,(o=i,i=i+16|0,c[o>>2]=n,c[o+8>>2]=3968,o)|0)|0;i=o;eC(c[f>>2]|0,3)}if((j5(e|0,l|0,12)|0)==0){p=f_(b,7888,2)|0;q=gi(k,p)|0;i=g;return q|0}fy(c[f>>2]|0,2512,(o=i,i=i+16|0,c[o>>2]=c[k+12>>2],c[o+8>>2]=2232,o)|0)|0;i=o;eC(c[f>>2]|0,3);p=f_(b,7888,2)|0;q=gi(k,p)|0;i=g;return q|0}function gi(d,e){d=d|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0;f=i;i=i+168|0;g=f|0;j=f+8|0;k=f+16|0;l=f+24|0;m=f+32|0;n=f+40|0;o=f+48|0;p=f+56|0;q=f+64|0;r=f+72|0;s=f+80|0;t=f+88|0;u=f+96|0;v=f+104|0;w=f+112|0;x=f+120|0;y=f+128|0;z=f+136|0;A=f+144|0;B=f+152|0;C=f+160|0;D=d|0;E=(c[D>>2]|0)+52|0;F=(b[E>>1]|0)+1&65535;b[E>>1]=F;if((F&65535)>200){F=c[D>>2]|0;E=c[d+12>>2]|0;fy(F,2512,(G=i,i=i+16|0,c[G>>2]=E,c[G+8>>2]=6088,G)|0)|0;i=G;eC(c[D>>2]|0,3)}E=eV(c[D>>2]|0)|0;F=c[(c[D>>2]|0)+8>>2]|0;c[F>>2]=E;c[F+8>>2]=9;F=c[D>>2]|0;H=c[F+8>>2]|0;if(((c[F+28>>2]|0)-H|0)<17){eA(F,1);I=c[D>>2]|0;J=I;K=c[I+8>>2]|0}else{J=F;K=H}c[J+8>>2]=K+16;K=d+4|0;if((gw(c[K>>2]|0,C,4)|0)!=0){J=c[D>>2]|0;H=c[d+12>>2]|0;fy(J,2512,(G=i,i=i+16|0,c[G>>2]=H,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}H=c[C>>2]|0;if((H|0)==0){L=0}else{J=gx(c[D>>2]|0,c[d+8>>2]|0,H)|0;if((gw(c[K>>2]|0,J,c[C>>2]|0)|0)!=0){H=c[D>>2]|0;F=c[d+12>>2]|0;fy(H,2512,(G=i,i=i+16|0,c[G>>2]=F,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}L=f_(c[D>>2]|0,J,(c[C>>2]|0)-1|0)|0}C=E+32|0;c[C>>2]=(L|0)==0?e:L;if((gw(c[K>>2]|0,B,4)|0)!=0){L=c[D>>2]|0;e=c[d+12>>2]|0;fy(L,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}e=c[B>>2]|0;if((e|0)<0){L=c[D>>2]|0;J=c[d+12>>2]|0;fy(L,2512,(G=i,i=i+16|0,c[G>>2]=J,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);M=c[B>>2]|0}else{M=e}c[E+60>>2]=M;if((gw(c[K>>2]|0,A,4)|0)!=0){M=c[D>>2]|0;e=c[d+12>>2]|0;fy(M,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}e=c[A>>2]|0;if((e|0)<0){M=c[D>>2]|0;B=c[d+12>>2]|0;fy(M,2512,(G=i,i=i+16|0,c[G>>2]=B,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);N=c[A>>2]|0}else{N=e}c[E+64>>2]=N;if((gw(c[K>>2]|0,z,1)|0)!=0){N=c[D>>2]|0;e=c[d+12>>2]|0;fy(N,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}a[E+72|0]=a[z]|0;if((gw(c[K>>2]|0,y,1)|0)!=0){z=c[D>>2]|0;e=c[d+12>>2]|0;fy(z,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}a[E+73|0]=a[y]|0;if((gw(c[K>>2]|0,x,1)|0)!=0){y=c[D>>2]|0;e=c[d+12>>2]|0;fy(y,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}a[E+74|0]=a[x]|0;if((gw(c[K>>2]|0,w,1)|0)!=0){x=c[D>>2]|0;e=c[d+12>>2]|0;fy(x,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}a[E+75|0]=a[w]|0;if((gw(c[K>>2]|0,v,4)|0)!=0){w=c[D>>2]|0;e=c[d+12>>2]|0;fy(w,2512,(G=i,i=i+16|0,c[G>>2]=e,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}e=c[v>>2]|0;if((e|0)<0){w=c[D>>2]|0;x=c[d+12>>2]|0;fy(w,2512,(G=i,i=i+16|0,c[G>>2]=x,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);O=c[v>>2]|0}else{O=e}e=c[D>>2]|0;if((O+1|0)>>>0<1073741824){v=O<<2;P=fu(e,0,0,v)|0;Q=v}else{P=fv(e)|0;Q=O<<2}c[E+12>>2]=P;c[E+44>>2]=O;if((gw(c[K>>2]|0,P,Q)|0)!=0){Q=c[D>>2]|0;P=c[d+12>>2]|0;fy(Q,2512,(G=i,i=i+16|0,c[G>>2]=P,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}if((gw(c[K>>2]|0,n,4)|0)!=0){P=c[D>>2]|0;Q=c[d+12>>2]|0;fy(P,2512,(G=i,i=i+16|0,c[G>>2]=Q,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}Q=c[n>>2]|0;if((Q|0)<0){P=c[D>>2]|0;O=c[d+12>>2]|0;fy(P,2512,(G=i,i=i+16|0,c[G>>2]=O,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);R=c[n>>2]|0}else{R=Q}Q=c[D>>2]|0;if((R+1|0)>>>0<268435456){S=fu(Q,0,0,R<<4)|0}else{S=fv(Q)|0}Q=S;S=E+8|0;c[S>>2]=Q;c[E+40>>2]=R;n=(R|0)>0;do{if(n){O=0;P=Q;while(1){c[P+(O<<4)+8>>2]=0;e=O+1|0;if((e|0)>=(R|0)){break}O=e;P=c[S>>2]|0}if(!n){break}P=d+12|0;O=k;e=j;v=d+8|0;x=0;do{w=c[S>>2]|0;y=w+(x<<4)|0;if((gw(c[K>>2]|0,m,1)|0)!=0){z=c[D>>2]|0;N=c[P>>2]|0;fy(z,2512,(G=i,i=i+16|0,c[G>>2]=N,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}N=a[m]|0;if((N|0)==0){c[w+(x<<4)+8>>2]=0}else if((N|0)==1){if((gw(c[K>>2]|0,l,1)|0)!=0){z=c[D>>2]|0;A=c[P>>2]|0;fy(z,2512,(G=i,i=i+16|0,c[G>>2]=A,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}c[y>>2]=(a[l]|0)!=0;c[w+(x<<4)+8>>2]=1}else if((N|0)==3){if((gw(c[K>>2]|0,O,8)|0)!=0){A=c[D>>2]|0;z=c[P>>2]|0;fy(A,2512,(G=i,i=i+16|0,c[G>>2]=z,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}h[y>>3]=+h[k>>3];c[w+(x<<4)+8>>2]=3}else if((N|0)==4){if((gw(c[K>>2]|0,e,4)|0)!=0){N=c[D>>2]|0;z=c[P>>2]|0;fy(N,2512,(G=i,i=i+16|0,c[G>>2]=z,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}z=c[j>>2]|0;if((z|0)==0){T=0}else{N=gx(c[D>>2]|0,c[v>>2]|0,z)|0;if((gw(c[K>>2]|0,N,c[j>>2]|0)|0)!=0){z=c[D>>2]|0;A=c[P>>2]|0;fy(z,2512,(G=i,i=i+16|0,c[G>>2]=A,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}T=f_(c[D>>2]|0,N,(c[j>>2]|0)-1|0)|0}c[y>>2]=T;c[w+(x<<4)+8>>2]=4}else{fy(c[D>>2]|0,2512,(G=i,i=i+16|0,c[G>>2]=c[P>>2],c[G+8>>2]=3416,G)|0)|0;i=G;eC(c[D>>2]|0,3)}x=x+1|0;}while((x|0)<(R|0))}}while(0);if((gw(c[K>>2]|0,g,4)|0)!=0){R=c[D>>2]|0;T=c[d+12>>2]|0;fy(R,2512,(G=i,i=i+16|0,c[G>>2]=T,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}T=c[g>>2]|0;if((T|0)<0){R=c[D>>2]|0;j=c[d+12>>2]|0;fy(R,2512,(G=i,i=i+16|0,c[G>>2]=j,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);U=c[g>>2]|0}else{U=T}T=c[D>>2]|0;if((U+1|0)>>>0<1073741824){V=fu(T,0,0,U<<2)|0}else{V=fv(T)|0}T=V;V=E+16|0;c[V>>2]=T;c[E+52>>2]=U;g=(U|0)>0;do{if(g){j=0;R=T;while(1){c[R+(j<<2)>>2]=0;k=j+1|0;if((k|0)>=(U|0)){break}j=k;R=c[V>>2]|0}if(g){W=0}else{break}do{R=gi(d,c[C>>2]|0)|0;c[(c[V>>2]|0)+(W<<2)>>2]=R;W=W+1|0;}while((W|0)<(U|0))}}while(0);if((gw(c[K>>2]|0,u,4)|0)!=0){U=c[D>>2]|0;W=c[d+12>>2]|0;fy(U,2512,(G=i,i=i+16|0,c[G>>2]=W,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}W=c[u>>2]|0;if((W|0)<0){U=c[D>>2]|0;V=c[d+12>>2]|0;fy(U,2512,(G=i,i=i+16|0,c[G>>2]=V,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);X=c[u>>2]|0}else{X=W}W=c[D>>2]|0;if((X+1|0)>>>0<1073741824){u=X<<2;Y=fu(W,0,0,u)|0;Z=u}else{Y=fv(W)|0;Z=X<<2}c[E+20>>2]=Y;c[E+48>>2]=X;if((gw(c[K>>2]|0,Y,Z)|0)!=0){Z=c[D>>2]|0;Y=c[d+12>>2]|0;fy(Z,2512,(G=i,i=i+16|0,c[G>>2]=Y,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}if((gw(c[K>>2]|0,t,4)|0)!=0){Y=c[D>>2]|0;Z=c[d+12>>2]|0;fy(Y,2512,(G=i,i=i+16|0,c[G>>2]=Z,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}Z=c[t>>2]|0;if((Z|0)<0){Y=c[D>>2]|0;X=c[d+12>>2]|0;fy(Y,2512,(G=i,i=i+16|0,c[G>>2]=X,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);_=c[t>>2]|0}else{_=Z}Z=c[D>>2]|0;if((_+1|0)>>>0<357913942){$=fu(Z,0,0,_*12|0)|0}else{$=fv(Z)|0}Z=E+24|0;c[Z>>2]=$;c[E+56>>2]=_;if((_|0)>0){c[$>>2]=0;if((_|0)>1){$=1;do{c[(c[Z>>2]|0)+($*12|0)>>2]=0;$=$+1|0;}while(($|0)<(_|0))}$=s;t=r;X=d+12|0;Y=q;W=d+8|0;u=0;do{if((gw(c[K>>2]|0,$,4)|0)!=0){V=c[D>>2]|0;U=c[X>>2]|0;fy(V,2512,(G=i,i=i+16|0,c[G>>2]=U,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}U=c[s>>2]|0;if((U|0)==0){aa=0}else{V=gx(c[D>>2]|0,c[W>>2]|0,U)|0;if((gw(c[K>>2]|0,V,c[s>>2]|0)|0)!=0){U=c[D>>2]|0;C=c[X>>2]|0;fy(U,2512,(G=i,i=i+16|0,c[G>>2]=C,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}aa=f_(c[D>>2]|0,V,(c[s>>2]|0)-1|0)|0}c[(c[Z>>2]|0)+(u*12|0)>>2]=aa;if((gw(c[K>>2]|0,t,4)|0)!=0){V=c[D>>2]|0;C=c[X>>2]|0;fy(V,2512,(G=i,i=i+16|0,c[G>>2]=C,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}C=c[r>>2]|0;if((C|0)<0){V=c[D>>2]|0;U=c[X>>2]|0;fy(V,2512,(G=i,i=i+16|0,c[G>>2]=U,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);ab=c[r>>2]|0}else{ab=C}c[(c[Z>>2]|0)+(u*12|0)+4>>2]=ab;if((gw(c[K>>2]|0,Y,4)|0)!=0){C=c[D>>2]|0;U=c[X>>2]|0;fy(C,2512,(G=i,i=i+16|0,c[G>>2]=U,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}U=c[q>>2]|0;if((U|0)<0){C=c[D>>2]|0;V=c[X>>2]|0;fy(C,2512,(G=i,i=i+16|0,c[G>>2]=V,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);ac=c[q>>2]|0}else{ac=U}c[(c[Z>>2]|0)+(u*12|0)+8>>2]=ac;u=u+1|0;}while((u|0)<(_|0))}if((gw(c[K>>2]|0,p,4)|0)!=0){_=c[D>>2]|0;u=c[d+12>>2]|0;fy(_,2512,(G=i,i=i+16|0,c[G>>2]=u,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}u=c[p>>2]|0;if((u|0)<0){_=c[D>>2]|0;ac=c[d+12>>2]|0;fy(_,2512,(G=i,i=i+16|0,c[G>>2]=ac,c[G+8>>2]=2872,G)|0)|0;i=G;eC(c[D>>2]|0,3);ad=c[p>>2]|0}else{ad=u}u=c[D>>2]|0;if((ad+1|0)>>>0<1073741824){ae=fu(u,0,0,ad<<2)|0}else{ae=fv(u)|0}u=ae;ae=E+28|0;c[ae>>2]=u;c[E+36>>2]=ad;if((ad|0)>0){c[u>>2]=0;if((ad|0)>1){u=1;do{c[(c[ae>>2]|0)+(u<<2)>>2]=0;u=u+1|0;}while((u|0)<(ad|0))}u=o;p=d+8|0;ac=d+12|0;_=0;do{if((gw(c[K>>2]|0,u,4)|0)!=0){Z=c[D>>2]|0;q=c[ac>>2]|0;fy(Z,2512,(G=i,i=i+16|0,c[G>>2]=q,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}q=c[o>>2]|0;if((q|0)==0){af=0}else{Z=gx(c[D>>2]|0,c[p>>2]|0,q)|0;if((gw(c[K>>2]|0,Z,c[o>>2]|0)|0)!=0){q=c[D>>2]|0;X=c[ac>>2]|0;fy(q,2512,(G=i,i=i+16|0,c[G>>2]=X,c[G+8>>2]=3968,G)|0)|0;i=G;eC(c[D>>2]|0,3)}af=f_(c[D>>2]|0,Z,(c[o>>2]|0)-1|0)|0}c[(c[ae>>2]|0)+(_<<2)>>2]=af;_=_+1|0;}while((_|0)<(ad|0))}if((eo(E)|0)!=0){ag=c[D>>2]|0;ah=ag+8|0;ai=c[ah>>2]|0;aj=ai-16|0;c[ah>>2]=aj;ak=c[D>>2]|0;al=ak+52|0;am=b[al>>1]|0;an=am-1&65535;b[al>>1]=an;i=f;return E|0}fy(c[D>>2]|0,2512,(G=i,i=i+16|0,c[G>>2]=c[d+12>>2],c[G+8>>2]=4736,G)|0)|0;i=G;eC(c[D>>2]|0,3);ag=c[D>>2]|0;ah=ag+8|0;ai=c[ah>>2]|0;aj=ai-16|0;c[ah>>2]=aj;ak=c[D>>2]|0;al=ak+52|0;am=b[al>>1]|0;an=am-1&65535;b[al>>1]=an;i=f;return E|0}function gj(b){b=b|0;var c=0;c=b;w=1635077147;a[c]=w&255;w=w>>8;a[c+1|0]=w&255;w=w>>8;a[c+2|0]=w&255;w=w>>8;a[c+3|0]=w&255;a[b+4|0]=81;a[b+5|0]=0;a[b+6|0]=1;a[b+7|0]=4;a[b+8|0]=4;a[b+9|0]=4;a[b+10|0]=8;a[b+11|0]=0;return}function gk(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,j=0;d=i;i=i+8|0;e=d|0;f=c[a+8>>2]|0;do{if((f|0)==3){g=a}else if((f|0)==4){if((fw((c[a>>2]|0)+16|0,e)|0)==0){j=821;break}h[b>>3]=+h[e>>3];c[b+8>>2]=3;g=b}else{j=821}}while(0);if((j|0)==821){g=0}i=d;return g|0}function gl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,j=0;d=i;i=i+32|0;e=b+8|0;if((c[e>>2]|0)!=3){f=0;i=d;return f|0}g=d|0;a$(g|0,6992,(j=i,i=i+8|0,h[j>>3]=+h[b>>3],j)|0)|0;i=j;c[b>>2]=f_(a,g,j_(g|0)|0)|0;c[e>>2]=4;f=1;i=d;return f|0}function gm(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;g=i;h=b+16|0;j=d;d=0;L1117:while(1){if((d|0)>=100){k=842;break}l=j+8|0;do{if((c[l>>2]|0)==5){m=c[j>>2]|0;n=f8(m,e)|0;o=n+8|0;if((c[o>>2]|0)!=0){k=835;break L1117}p=c[m+8>>2]|0;m=p;if((p|0)==0){k=835;break L1117}if((a[m+6|0]&1)!=0){k=835;break L1117}p=gf(m,0,c[(c[h>>2]|0)+188>>2]|0)|0;if((p|0)==0){k=835;break L1117}else{q=p}}else{p=gg(b,j,0)|0;if((c[p+8>>2]|0)!=0){q=p;break}eq(b,j,9752);q=p}}while(0);r=q+8|0;if((c[r>>2]|0)==6){k=839;break}else{j=q;d=d+1|0}}if((k|0)==839){d=b+32|0;h=f-(c[d>>2]|0)|0;p=b+8|0;m=c[p>>2]|0;s=q;q=m;t=c[s+4>>2]|0;c[q>>2]=c[s>>2];c[q+4>>2]=t;c[m+8>>2]=c[r>>2];r=c[p>>2]|0;m=j;j=r+16|0;t=c[m+4>>2]|0;c[j>>2]=c[m>>2];c[j+4>>2]=t;c[r+24>>2]=c[l>>2];l=c[p>>2]|0;r=e;t=l+32|0;j=c[r+4>>2]|0;c[t>>2]=c[r>>2];c[t+4>>2]=j;c[l+40>>2]=c[e+8>>2];e=c[p>>2]|0;if(((c[b+28>>2]|0)-e|0)<49){eA(b,3);u=c[p>>2]|0}else{u=e}c[p>>2]=u+48;eG(b,u,1);u=c[d>>2]|0;d=c[p>>2]|0;e=d-16|0;c[p>>2]=e;p=e;e=u+h|0;l=c[p+4>>2]|0;c[e>>2]=c[p>>2];c[e+4>>2]=l;c[u+(h+8)>>2]=c[d-16+8>>2];i=g;return}else if((k|0)==842){es(b,7816,(b=i,i=i+1|0,i=i+7>>3<<3,c[b>>2]=0,b)|0);i=b;i=g;return}else if((k|0)==835){k=n;n=f;b=c[k+4>>2]|0;c[n>>2]=c[k>>2];c[n+4>>2]=b;c[f+8>>2]=c[o>>2];i=g;return}}function gn(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;g=i;i=i+16|0;h=g|0;j=b+16|0;k=h;l=h+8|0;m=0;n=d;o=c[d+8>>2]|0;L1139:while(1){p=n+8|0;do{if((o|0)==5){q=c[n>>2]|0;r=q;s=f9(b,r,e)|0;t=s+8|0;if((c[t>>2]|0)!=0){u=853;break L1139}d=c[q+8>>2]|0;v=d;if((d|0)==0){u=853;break L1139}if((a[v+6|0]&2)!=0){u=853;break L1139}d=gf(v,1,c[(c[j>>2]|0)+192>>2]|0)|0;if((d|0)==0){u=853;break L1139}else{w=d}}else{d=gg(b,n,1)|0;if((c[d+8>>2]|0)!=0){w=d;break}eq(b,n,9752);w=d}}while(0);x=w+8|0;if((c[x>>2]|0)==6){u=860;break}d=w;v=c[d+4>>2]|0;c[k>>2]=c[d>>2];c[k+4>>2]=v;v=c[x>>2]|0;c[l>>2]=v;d=m+1|0;if((d|0)<100){m=d;n=h;o=v}else{u=864;break}}if((u|0)==853){o=f;h=s;s=c[o+4>>2]|0;c[h>>2]=c[o>>2];c[h+4>>2]=s;s=f+8|0;c[t>>2]=c[s>>2];a[q+6|0]=0;if((c[s>>2]|0)<=3){i=g;return}if((a[(c[f>>2]|0)+5|0]&3)==0){i=g;return}if((a[q+5|0]&4)==0){i=g;return}e2(b,r);i=g;return}else if((u|0)==860){r=b+8|0;q=c[r>>2]|0;s=w;w=q;t=c[s+4>>2]|0;c[w>>2]=c[s>>2];c[w+4>>2]=t;c[q+8>>2]=c[x>>2];x=c[r>>2]|0;q=n;n=x+16|0;t=c[q+4>>2]|0;c[n>>2]=c[q>>2];c[n+4>>2]=t;c[x+24>>2]=c[p>>2];p=c[r>>2]|0;x=e;t=p+32|0;n=c[x+4>>2]|0;c[t>>2]=c[x>>2];c[t+4>>2]=n;c[p+40>>2]=c[e+8>>2];e=c[r>>2]|0;p=f;n=e+48|0;t=c[p+4>>2]|0;c[n>>2]=c[p>>2];c[n+4>>2]=t;c[e+56>>2]=c[f+8>>2];f=c[r>>2]|0;if(((c[b+28>>2]|0)-f|0)<65){eA(b,4);y=c[r>>2]|0}else{y=f}c[r>>2]=y+64;eG(b,y,0);i=g;return}else if((u|0)==864){es(b,5976,(b=i,i=i+1|0,i=i+7>>3<<3,c[b>>2]=0,b)|0);i=b;i=g;return}}function go(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=b+8|0;f=c[e>>2]|0;g=d+8|0;if((f|0)!=(c[g>>2]|0)){i=ev(a,b,d)|0;return i|0}if((f|0)==4){j=c[b>>2]|0;k=c[d>>2]|0;l=j+16|0;m=k+16|0;n=aL(l|0,m|0)|0;L1192:do{if((n|0)==0){o=l;p=c[j+12>>2]|0;q=m;r=c[k+12>>2]|0;while(1){s=j_(o|0)|0;t=(s|0)==(p|0);if((s|0)==(r|0)){break}if(t){u=-1;break L1192}v=s+1|0;s=o+v|0;w=q+v|0;x=aL(s|0,w|0)|0;if((x|0)==0){o=s;p=p-v|0;q=w;r=r-v|0}else{u=x;break L1192}}u=t&1^1}else{u=n}}while(0);i=u>>>31;return i|0}else if((f|0)==3){i=+h[b>>3]<+h[d>>3]|0;return i|0}else{f=gg(a,b,13)|0;u=f+8|0;do{if((c[u>>2]|0)!=0){if((fr(f,gg(a,d,13)|0)|0)==0){break}n=a+8|0;t=c[n>>2]|0;k=a+32|0;m=t-(c[k>>2]|0)|0;j=f;l=t;r=c[j+4>>2]|0;c[l>>2]=c[j>>2];c[l+4>>2]=r;c[t+8>>2]=c[u>>2];t=c[n>>2]|0;r=b;l=t+16|0;j=c[r+4>>2]|0;c[l>>2]=c[r>>2];c[l+4>>2]=j;c[t+24>>2]=c[e>>2];t=c[n>>2]|0;j=d;l=t+32|0;r=c[j+4>>2]|0;c[l>>2]=c[j>>2];c[l+4>>2]=r;c[t+40>>2]=c[g>>2];t=c[n>>2]|0;if(((c[a+28>>2]|0)-t|0)<49){eA(a,3);y=c[n>>2]|0}else{y=t}c[n>>2]=y+48;eG(a,y,1);t=c[k>>2]|0;k=c[n>>2]|0;r=k-16|0;c[n>>2]=r;l=r;r=t+m|0;j=c[l+4>>2]|0;c[r>>2]=c[l>>2];c[r+4>>2]=j;c[t+(m+8)>>2]=c[k-16+8>>2];k=c[n>>2]|0;n=c[k+8>>2]|0;if((n|0)==0){i=0;return i|0}if((n|0)!=1){i=1;return i|0}i=(c[k>>2]|0)!=0|0;return i|0}}while(0);i=ev(a,b,d)|0;return i|0}return 0}function gp(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;f=d+8|0;L1204:do{switch(c[f>>2]|0){case 0:{g=1;return g|0};case 3:{g=+h[d>>3]==+h[e>>3]|0;return g|0};case 1:{g=(c[d>>2]|0)==(c[e>>2]|0)|0;return g|0};case 7:{i=c[d>>2]|0;j=c[e>>2]|0;if((i|0)==(j|0)){g=1;return g|0}k=c[i+8>>2]|0;i=k;l=c[j+8>>2]|0;j=l;if((k|0)==0){g=0;return g|0}if((a[i+6|0]&16)!=0){g=0;return g|0}m=b+16|0;n=gf(i,4,c[(c[m>>2]|0)+204>>2]|0)|0;if((n|0)==0){g=0;return g|0}if((k|0)==(l|0)){o=n;break L1204}if((l|0)==0){g=0;return g|0}if((a[j+6|0]&16)!=0){g=0;return g|0}l=gf(j,4,c[(c[m>>2]|0)+204>>2]|0)|0;if((l|0)==0){g=0;return g|0}else{p=(fr(n,l)|0)==0?0:n;q=922;break L1204}break};case 2:{g=(c[d>>2]|0)==(c[e>>2]|0)|0;return g|0};case 5:{n=c[d>>2]|0;l=c[e>>2]|0;if((n|0)==(l|0)){g=1;return g|0}m=c[n+8>>2]|0;n=m;j=c[l+8>>2]|0;l=j;if((m|0)==0){g=0;return g|0}if((a[n+6|0]&16)!=0){g=0;return g|0}k=b+16|0;i=gf(n,4,c[(c[k>>2]|0)+204>>2]|0)|0;if((i|0)==0){g=0;return g|0}if((m|0)==(j|0)){o=i;break L1204}if((j|0)==0){g=0;return g|0}if((a[l+6|0]&16)!=0){g=0;return g|0}j=gf(l,4,c[(c[k>>2]|0)+204>>2]|0)|0;if((j|0)==0){g=0;return g|0}else{p=(fr(i,j)|0)==0?0:i;q=922;break L1204}break};default:{g=(c[d>>2]|0)==(c[e>>2]|0)|0;return g|0}}}while(0);do{if((q|0)==922){if((p|0)==0){g=0}else{o=p;break}return g|0}}while(0);p=b+8|0;q=c[p>>2]|0;i=b+32|0;j=q-(c[i>>2]|0)|0;k=o;l=q;m=c[k+4>>2]|0;c[l>>2]=c[k>>2];c[l+4>>2]=m;c[q+8>>2]=c[o+8>>2];o=c[p>>2]|0;q=d;d=o+16|0;m=c[q+4>>2]|0;c[d>>2]=c[q>>2];c[d+4>>2]=m;c[o+24>>2]=c[f>>2];f=c[p>>2]|0;o=e;m=f+32|0;d=c[o+4>>2]|0;c[m>>2]=c[o>>2];c[m+4>>2]=d;c[f+40>>2]=c[e+8>>2];e=c[p>>2]|0;if(((c[b+28>>2]|0)-e|0)<49){eA(b,3);r=c[p>>2]|0}else{r=e}c[p>>2]=r+48;eG(b,r,1);r=c[i>>2]|0;i=c[p>>2]|0;b=i-16|0;c[p>>2]=b;e=b;b=r+j|0;f=c[e+4>>2]|0;c[b>>2]=c[e>>2];c[b+4>>2]=f;c[r+(j+8)>>2]=c[i-16+8>>2];i=c[p>>2]|0;p=c[i+8>>2]|0;if((p|0)==0){g=0;return g|0}if((p|0)!=1){g=1;return g|0}g=(c[i>>2]|0)!=0|0;return g|0}function gq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0;e=i;i=i+32|0;f=a+12|0;g=e|0;j=a+16|0;k=a+32|0;l=a+8|0;m=a+28|0;n=b;b=d;while(1){d=c[f>>2]|0;o=b+1|0;p=b-1|0;q=d+(p<<4)|0;r=d+(p<<4)+8|0;p=d+(b<<4)|0;do{if(((c[r>>2]|0)-3|0)>>>0<2){s=d+(b<<4)+8|0;t=c[s>>2]|0;if((t|0)==4){u=p}else{if((t|0)!=3){v=958;break}w=+h[p>>3];a$(g|0,6992,(x=i,i=i+8|0,h[x>>3]=w,x)|0)|0;i=x;t=p;c[t>>2]=f_(a,g,j_(g|0)|0)|0;c[s>>2]=4;u=t}t=c[(c[u>>2]|0)+12>>2]|0;if((t|0)==0){s=c[r>>2]|0;if((s|0)==4){y=2;break}if((s|0)!=3){y=2;break}w=+h[q>>3];a$(g|0,6992,(x=i,i=i+8|0,h[x>>3]=w,x)|0)|0;i=x;c[q>>2]=f_(a,g,j_(g|0)|0)|0;c[r>>2]=4;y=2;break}L1289:do{if((n|0)>1){s=t;z=1;while(1){A=o-z-1|0;B=d+(A<<4)|0;C=d+(A<<4)+8|0;A=c[C>>2]|0;if((A|0)==4){D=B}else{if((A|0)!=3){E=s;F=z;break L1289}w=+h[B>>3];a$(g|0,6992,(x=i,i=i+8|0,h[x>>3]=w,x)|0)|0;i=x;A=B;c[A>>2]=f_(a,g,j_(g|0)|0)|0;c[C>>2]=4;D=A}A=c[(c[D>>2]|0)+12>>2]|0;if(A>>>0>=(-3-s|0)>>>0){es(a,4688,(x=i,i=i+1|0,i=i+7>>3<<3,c[x>>2]=0,x)|0);i=x}C=A+s|0;A=z+1|0;if((A|0)<(n|0)){s=C;z=A}else{E=C;F=A;break}}}else{E=t;F=1}}while(0);t=gx(a,(c[j>>2]|0)+52|0,E)|0;if((F|0)>0){z=0;s=F;while(1){A=c[d+(o-s<<4)>>2]|0;C=c[A+12>>2]|0;B=t+z|0;G=A+16|0;j$(B|0,G|0,C)|0;G=C+z|0;C=s-1|0;if((C|0)>0){z=G;s=C}else{H=G;break}}}else{H=0}s=o-F|0;c[d+(s<<4)>>2]=f_(a,t,H)|0;c[d+(s<<4)+8>>2]=4;y=F}else{v=958}}while(0);L1305:do{if((v|0)==958){v=0;o=gg(a,q,15)|0;do{if((c[o+8>>2]|0)==0){s=gg(a,p,15)|0;if((c[s+8>>2]|0)!=0){I=s;break}et(a,q,p);y=2;break L1305}else{I=o}}while(0);o=q-(c[k>>2]|0)|0;t=c[l>>2]|0;s=I;z=t;G=c[s+4>>2]|0;c[z>>2]=c[s>>2];c[z+4>>2]=G;c[t+8>>2]=c[I+8>>2];t=c[l>>2]|0;G=q;z=t+16|0;s=c[G+4>>2]|0;c[z>>2]=c[G>>2];c[z+4>>2]=s;c[t+24>>2]=c[r>>2];t=c[l>>2]|0;s=p;z=t+32|0;G=c[s+4>>2]|0;c[z>>2]=c[s>>2];c[z+4>>2]=G;c[t+40>>2]=c[d+(b<<4)+8>>2];t=c[l>>2]|0;if(((c[m>>2]|0)-t|0)<49){eA(a,3);J=c[l>>2]|0}else{J=t}c[l>>2]=J+48;eG(a,J,1);t=c[k>>2]|0;G=c[l>>2]|0;z=G-16|0;c[l>>2]=z;s=z;z=t+o|0;C=c[s+4>>2]|0;c[z>>2]=c[s>>2];c[z+4>>2]=C;c[t+(o+8)>>2]=c[G-16+8>>2];y=2}}while(0);d=y-1|0;p=n-d|0;if((p|0)<=1){break}n=p;b=b-d|0}i=e;return}function gr(b,e){b=b|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,P=0,Q=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0,aM=0,aN=0,aO=0,aP=0,aQ=0,aR=0,aS=0,aT=0,aU=0,aV=0.0,aW=0,aX=0,aY=0,aZ=0,a_=0,a$=0.0,a0=0,a1=0,a2=0,a3=0,a4=0,a5=0.0,a6=0,a7=0,a8=0,a9=0,ba=0,bb=0.0,bc=0,bd=0,be=0,bf=0,bg=0.0,bh=0.0,bi=0,bj=0.0,bk=0,bl=0,bm=0,bn=0,bo=0,bp=0.0,bq=0,br=0,bs=0,bt=0,bu=0,bv=0,bw=0,bx=0,by=0,bz=0,bA=0,bB=0,bC=0,bD=0,bE=0,bF=0,bG=0,bH=0,bI=0,bJ=0,bK=0,bL=0,bM=0,bN=0,bO=0,bP=0,bQ=0,bR=0,bS=0,bT=0,bU=0,bV=0,bW=0,bX=0,bY=0.0,bZ=0,b_=0,b$=0,b0=0,b1=0,b2=0,b3=0,b4=0,b5=0,b6=0,b7=0;f=i;i=i+280|0;g=f|0;j=f+8|0;k=f+16|0;l=f+24|0;m=f+32|0;n=f+40|0;o=f+48|0;p=f+56|0;q=f+64|0;r=f+72|0;s=f+80|0;t=f+88|0;u=f+96|0;v=f+104|0;w=f+112|0;x=f+120|0;y=f+128|0;z=f+136|0;A=f+152|0;B=f+168|0;C=f+184|0;D=f+200|0;E=f+216|0;F=f+232|0;G=f+248|0;H=f+264|0;I=b+24|0;J=b+20|0;K=b+12|0;L=b+56|0;M=G;N=G+8|0;P=H;Q=H+8|0;S=b+16|0;T=b+32|0;U=b+8|0;V=b+28|0;W=F|0;X=F+8|0;Y=E|0;Z=E+8|0;_=D|0;$=D+8|0;aa=C|0;ab=C+8|0;ac=B|0;ad=B+8|0;ae=A|0;af=A+8|0;ag=z|0;ah=z+8|0;ai=c[260]|0;aj=b+64|0;ak=b+6|0;al=b+60|0;am=b+104|0;an=e;L1318:while(1){e=c[J>>2]|0;L1320:while(1){ao=c[c[e+4>>2]>>2]|0;ap=ao+16|0;aq=c[(c[ap>>2]|0)+8>>2]|0;ar=ao+20|0;as=ao+12|0;ao=c[K>>2]|0;at=c[I>>2]|0;L1322:while(1){au=at+4|0;av=c[at>>2]|0;aw=a[L]|0;do{if((aw&12)==0){ax=ao}else{ay=(c[aj>>2]|0)-1|0;c[aj>>2]=ay;az=(ay|0)==0;if(!az){if((aw&4)==0){ax=ao;break}}ay=c[I>>2]|0;c[I>>2]=au;aA=aw&255;if(!((aA&8|0)==0|az^1)){c[aj>>2]=c[al>>2];eB(b,3,-1)}do{if((aA&4|0)!=0){az=c[(c[c[(c[J>>2]|0)+4>>2]>>2]|0)+16>>2]|0;aB=c[az+12>>2]|0;aC=(au-aB>>2)-1|0;aD=c[az+20>>2]|0;az=(aD|0)==0;if(az){aE=0}else{aE=c[aD+(aC<<2)>>2]|0}if((aC|0)!=0&ay>>>0<au>>>0){if(az){aF=0}else{aF=c[aD+((ay-aB>>2)-1<<2)>>2]|0}if((aE|0)==(aF|0)){break}}eB(b,2,aE)}}while(0);if((a[ak]|0)==1){aG=999;break L1318}ax=c[K>>2]|0}}while(0);aH=av>>>6&255;aI=ax+(aH<<4)|0;switch(av&63|0){case 18:{aw=av>>>23;ay=ax+(aw<<4)|0;aA=ax+(aw<<4)+8|0;if((c[aA>>2]|0)==3){h[aI>>3]=-0.0- +h[ay>>3];c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}c[I>>2]=au;aw=c[aA>>2]|0;do{if((aw|0)==3){if((ay|0)==0){aG=1198}else{aJ=ay;aG=1194}}else if((aw|0)==4){if((fw((c[ay>>2]|0)+16|0,j)|0)==0){aG=1198;break}h[ag>>3]=+h[j>>3];c[ah>>2]=3;aJ=z;aG=1194}else{aG=1198}}while(0);do{if((aG|0)==1194){aG=0;aw=c[aA>>2]|0;if((aw|0)==4){if((fw((c[ay>>2]|0)+16|0,g)|0)==0){aG=1198;break}}else if((aw|0)==3){if((ay|0)==0){aG=1198;break}}else{aG=1198;break}h[aI>>3]=-0.0- +h[aJ>>3];c[ax+(aH<<4)+8>>2]=3}}while(0);L1361:do{if((aG|0)==1198){aG=0;aw=gg(b,ay,11)|0;do{if((c[aw+8>>2]|0)==0){aB=gg(b,ay,11)|0;if((c[aB+8>>2]|0)!=0){aK=aB;break}eu(b,ay,ay);break L1361}else{aK=aw}}while(0);aw=aI-(c[T>>2]|0)|0;aB=c[U>>2]|0;aD=aK;az=aB;aC=c[aD+4>>2]|0;c[az>>2]=c[aD>>2];c[az+4>>2]=aC;c[aB+8>>2]=c[aK+8>>2];aB=c[U>>2]|0;aC=ay;az=aB+16|0;aD=c[aC+4>>2]|0;c[az>>2]=c[aC>>2];c[az+4>>2]=aD;c[aB+24>>2]=c[aA>>2];aB=c[U>>2]|0;aD=aB+32|0;az=c[aC+4>>2]|0;c[aD>>2]=c[aC>>2];c[aD+4>>2]=az;c[aB+40>>2]=c[aA>>2];aB=c[U>>2]|0;if(((c[V>>2]|0)-aB|0)<49){eA(b,3);aM=c[U>>2]|0}else{aM=aB}c[U>>2]=aM+48;eG(b,aM,1);aB=c[T>>2]|0;az=c[U>>2]|0;aD=az-16|0;c[U>>2]=aD;aC=aD;aD=aB+aw|0;aN=c[aC+4>>2]|0;c[aD>>2]=c[aC>>2];c[aD+4>>2]=aN;c[aB+(aw+8)>>2]=c[az-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 0:{aA=av>>>23;ay=ax+(aA<<4)|0;az=aI;aw=c[ay+4>>2]|0;c[az>>2]=c[ay>>2];c[az+4>>2]=aw;c[ax+(aH<<4)+8>>2]=c[ax+(aA<<4)+8>>2];ao=ax;at=au;continue L1322;break};case 1:{aA=av>>>14;aw=aq+(aA<<4)|0;az=aI;ay=c[aw+4>>2]|0;c[az>>2]=c[aw>>2];c[az+4>>2]=ay;c[ax+(aH<<4)+8>>2]=c[aq+(aA<<4)+8>>2];ao=ax;at=au;continue L1322;break};case 2:{c[aI>>2]=av>>>23;c[ax+(aH<<4)+8>>2]=1;ao=ax;at=(av&8372224|0)==0?au:at+8|0;continue L1322;break};case 3:{aA=ax+(av>>>23<<4)|0;while(1){ay=aA-16|0;c[aA+8>>2]=0;if(ay>>>0<aI>>>0){ao=ax;at=au;continue L1322}else{aA=ay}}break};case 4:{aA=c[(c[ar+(av>>>23<<2)>>2]|0)+8>>2]|0;ay=aA;az=aI;aw=c[ay+4>>2]|0;c[az>>2]=c[ay>>2];c[az+4>>2]=aw;c[ax+(aH<<4)+8>>2]=c[aA+8>>2];ao=ax;at=au;continue L1322;break};case 5:{c[M>>2]=c[as>>2];c[N>>2]=5;c[I>>2]=au;gm(b,G,aq+(av>>>14<<4)|0,aI);ao=c[K>>2]|0;at=au;continue L1322;break};case 6:{c[I>>2]=au;aA=av>>>14;if((aA&256|0)==0){aO=ax+((aA&511)<<4)|0}else{aO=aq+((aA&255)<<4)|0}gm(b,ax+(av>>>23<<4)|0,aO,aI);ao=c[K>>2]|0;at=au;continue L1322;break};case 7:{c[P>>2]=c[as>>2];c[Q>>2]=5;c[I>>2]=au;gn(b,H,aq+(av>>>14<<4)|0,aI);ao=c[K>>2]|0;at=au;continue L1322;break};case 8:{aA=c[ar+(av>>>23<<2)>>2]|0;aw=c[aA+8>>2]|0;az=aI;ay=aw;aB=c[az+4>>2]|0;c[ay>>2]=c[az>>2];c[ay+4>>2]=aB;aB=ax+(aH<<4)+8|0;c[aw+8>>2]=c[aB>>2];if((c[aB>>2]|0)<=3){ao=ax;at=au;continue L1322}aB=c[aI>>2]|0;if((a[aB+5|0]&3)==0){ao=ax;at=au;continue L1322}if((a[aA+5|0]&4)==0){ao=ax;at=au;continue L1322}e7(b,aA,aB);ao=ax;at=au;continue L1322;break};case 9:{c[I>>2]=au;aB=av>>>23;if((aB&256|0)==0){aP=ax+(aB<<4)|0}else{aP=aq+((aB&255)<<4)|0}aB=av>>>14;if((aB&256|0)==0){aQ=ax+((aB&511)<<4)|0}else{aQ=aq+((aB&255)<<4)|0}gn(b,aI,aP,aQ);ao=c[K>>2]|0;at=au;continue L1322;break};case 10:{aB=fp(av>>>23)|0;c[aI>>2]=f5(b,aB,fp(av>>>14&511)|0)|0;c[ax+(aH<<4)+8>>2]=5;c[I>>2]=au;aB=c[S>>2]|0;if((c[aB+68>>2]|0)>>>0>=(c[aB+64>>2]|0)>>>0){e1(b)}ao=c[K>>2]|0;at=au;continue L1322;break};case 11:{aB=av>>>23;aA=ax+(aB<<4)|0;aw=aH+1|0;ay=aA;az=ax+(aw<<4)|0;aN=c[ay+4>>2]|0;c[az>>2]=c[ay>>2];c[az+4>>2]=aN;c[ax+(aw<<4)+8>>2]=c[ax+(aB<<4)+8>>2];c[I>>2]=au;aB=av>>>14;if((aB&256|0)==0){aR=ax+((aB&511)<<4)|0}else{aR=aq+((aB&255)<<4)|0}gm(b,aA,aR,aI);ao=c[K>>2]|0;at=au;continue L1322;break};case 12:{aA=av>>>23;if((aA&256|0)==0){aS=ax+(aA<<4)|0}else{aS=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){aT=ax+((aA&511)<<4)|0}else{aT=aq+((aA&255)<<4)|0}aA=aS+8|0;do{if((c[aA>>2]|0)==3){if((c[aT+8>>2]|0)!=3){break}h[aI>>3]=+h[aS>>3]+ +h[aT>>3];c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}}while(0);c[I>>2]=au;aB=c[aA>>2]|0;do{if((aB|0)==4){if((fw((c[aS>>2]|0)+16|0,v)|0)==0){aG=1051;break}h[W>>3]=+h[v>>3];c[X>>2]=3;aU=F;aG=1045}else if((aB|0)==3){if((aS|0)==0){aG=1051}else{aU=aS;aG=1045}}else{aG=1051}}while(0);do{if((aG|0)==1045){aG=0;aB=c[aT+8>>2]|0;if((aB|0)==4){if((fw((c[aT>>2]|0)+16|0,u)|0)==0){aG=1051;break}aV=+h[u>>3]}else if((aB|0)==3){if((aT|0)==0){aG=1051;break}aV=+h[aT>>3]}else{aG=1051;break}h[aI>>3]=+h[aU>>3]+aV;c[ax+(aH<<4)+8>>2]=3}}while(0);L1432:do{if((aG|0)==1051){aG=0;aB=gg(b,aS,5)|0;do{if((c[aB+8>>2]|0)==0){aw=gg(b,aT,5)|0;if((c[aw+8>>2]|0)!=0){aW=aw;break}eu(b,aS,aT);break L1432}else{aW=aB}}while(0);aB=aI-(c[T>>2]|0)|0;aw=c[U>>2]|0;aN=aW;az=aw;ay=c[aN+4>>2]|0;c[az>>2]=c[aN>>2];c[az+4>>2]=ay;c[aw+8>>2]=c[aW+8>>2];aw=c[U>>2]|0;ay=aS;az=aw+16|0;aN=c[ay+4>>2]|0;c[az>>2]=c[ay>>2];c[az+4>>2]=aN;c[aw+24>>2]=c[aA>>2];aw=c[U>>2]|0;aN=aT;az=aw+32|0;ay=c[aN+4>>2]|0;c[az>>2]=c[aN>>2];c[az+4>>2]=ay;c[aw+40>>2]=c[aT+8>>2];aw=c[U>>2]|0;if(((c[V>>2]|0)-aw|0)<49){eA(b,3);aX=c[U>>2]|0}else{aX=aw}c[U>>2]=aX+48;eG(b,aX,1);aw=c[T>>2]|0;ay=c[U>>2]|0;az=ay-16|0;c[U>>2]=az;aN=az;az=aw+aB|0;aD=c[aN+4>>2]|0;c[az>>2]=c[aN>>2];c[az+4>>2]=aD;c[aw+(aB+8)>>2]=c[ay-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 13:{aA=av>>>23;if((aA&256|0)==0){aY=ax+(aA<<4)|0}else{aY=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){aZ=ax+((aA&511)<<4)|0}else{aZ=aq+((aA&255)<<4)|0}aA=aY+8|0;do{if((c[aA>>2]|0)==3){if((c[aZ+8>>2]|0)!=3){break}h[aI>>3]=+h[aY>>3]- +h[aZ>>3];c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}}while(0);c[I>>2]=au;ay=c[aA>>2]|0;do{if((ay|0)==4){if((fw((c[aY>>2]|0)+16|0,t)|0)==0){aG=1077;break}h[Y>>3]=+h[t>>3];c[Z>>2]=3;a_=E;aG=1071}else if((ay|0)==3){if((aY|0)==0){aG=1077}else{a_=aY;aG=1071}}else{aG=1077}}while(0);do{if((aG|0)==1071){aG=0;ay=c[aZ+8>>2]|0;if((ay|0)==4){if((fw((c[aZ>>2]|0)+16|0,s)|0)==0){aG=1077;break}a$=+h[s>>3]}else if((ay|0)==3){if((aZ|0)==0){aG=1077;break}a$=+h[aZ>>3]}else{aG=1077;break}h[aI>>3]=+h[a_>>3]-a$;c[ax+(aH<<4)+8>>2]=3}}while(0);L1467:do{if((aG|0)==1077){aG=0;ay=gg(b,aY,6)|0;do{if((c[ay+8>>2]|0)==0){aB=gg(b,aZ,6)|0;if((c[aB+8>>2]|0)!=0){a0=aB;break}eu(b,aY,aZ);break L1467}else{a0=ay}}while(0);ay=aI-(c[T>>2]|0)|0;aB=c[U>>2]|0;aw=a0;aD=aB;az=c[aw+4>>2]|0;c[aD>>2]=c[aw>>2];c[aD+4>>2]=az;c[aB+8>>2]=c[a0+8>>2];aB=c[U>>2]|0;az=aY;aD=aB+16|0;aw=c[az+4>>2]|0;c[aD>>2]=c[az>>2];c[aD+4>>2]=aw;c[aB+24>>2]=c[aA>>2];aB=c[U>>2]|0;aw=aZ;aD=aB+32|0;az=c[aw+4>>2]|0;c[aD>>2]=c[aw>>2];c[aD+4>>2]=az;c[aB+40>>2]=c[aZ+8>>2];aB=c[U>>2]|0;if(((c[V>>2]|0)-aB|0)<49){eA(b,3);a1=c[U>>2]|0}else{a1=aB}c[U>>2]=a1+48;eG(b,a1,1);aB=c[T>>2]|0;az=c[U>>2]|0;aD=az-16|0;c[U>>2]=aD;aw=aD;aD=aB+ay|0;aN=c[aw+4>>2]|0;c[aD>>2]=c[aw>>2];c[aD+4>>2]=aN;c[aB+(ay+8)>>2]=c[az-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 14:{aA=av>>>23;if((aA&256|0)==0){a2=ax+(aA<<4)|0}else{a2=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){a3=ax+((aA&511)<<4)|0}else{a3=aq+((aA&255)<<4)|0}aA=a2+8|0;do{if((c[aA>>2]|0)==3){if((c[a3+8>>2]|0)!=3){break}h[aI>>3]=+h[a2>>3]*+h[a3>>3];c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}}while(0);c[I>>2]=au;az=c[aA>>2]|0;do{if((az|0)==4){if((fw((c[a2>>2]|0)+16|0,r)|0)==0){aG=1103;break}h[_>>3]=+h[r>>3];c[$>>2]=3;a4=D;aG=1097}else if((az|0)==3){if((a2|0)==0){aG=1103}else{a4=a2;aG=1097}}else{aG=1103}}while(0);do{if((aG|0)==1097){aG=0;az=c[a3+8>>2]|0;if((az|0)==4){if((fw((c[a3>>2]|0)+16|0,q)|0)==0){aG=1103;break}a5=+h[q>>3]}else if((az|0)==3){if((a3|0)==0){aG=1103;break}a5=+h[a3>>3]}else{aG=1103;break}h[aI>>3]=+h[a4>>3]*a5;c[ax+(aH<<4)+8>>2]=3}}while(0);L1502:do{if((aG|0)==1103){aG=0;az=gg(b,a2,7)|0;do{if((c[az+8>>2]|0)==0){ay=gg(b,a3,7)|0;if((c[ay+8>>2]|0)!=0){a6=ay;break}eu(b,a2,a3);break L1502}else{a6=az}}while(0);az=aI-(c[T>>2]|0)|0;ay=c[U>>2]|0;aB=a6;aN=ay;aD=c[aB+4>>2]|0;c[aN>>2]=c[aB>>2];c[aN+4>>2]=aD;c[ay+8>>2]=c[a6+8>>2];ay=c[U>>2]|0;aD=a2;aN=ay+16|0;aB=c[aD+4>>2]|0;c[aN>>2]=c[aD>>2];c[aN+4>>2]=aB;c[ay+24>>2]=c[aA>>2];ay=c[U>>2]|0;aB=a3;aN=ay+32|0;aD=c[aB+4>>2]|0;c[aN>>2]=c[aB>>2];c[aN+4>>2]=aD;c[ay+40>>2]=c[a3+8>>2];ay=c[U>>2]|0;if(((c[V>>2]|0)-ay|0)<49){eA(b,3);a7=c[U>>2]|0}else{a7=ay}c[U>>2]=a7+48;eG(b,a7,1);ay=c[T>>2]|0;aD=c[U>>2]|0;aN=aD-16|0;c[U>>2]=aN;aB=aN;aN=ay+az|0;aw=c[aB+4>>2]|0;c[aN>>2]=c[aB>>2];c[aN+4>>2]=aw;c[ay+(az+8)>>2]=c[aD-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 15:{aA=av>>>23;if((aA&256|0)==0){a8=ax+(aA<<4)|0}else{a8=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){a9=ax+((aA&511)<<4)|0}else{a9=aq+((aA&255)<<4)|0}aA=a8+8|0;do{if((c[aA>>2]|0)==3){if((c[a9+8>>2]|0)!=3){break}h[aI>>3]=+h[a8>>3]/+h[a9>>3];c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}}while(0);c[I>>2]=au;aD=c[aA>>2]|0;do{if((aD|0)==4){if((fw((c[a8>>2]|0)+16|0,p)|0)==0){aG=1129;break}h[aa>>3]=+h[p>>3];c[ab>>2]=3;ba=C;aG=1123}else if((aD|0)==3){if((a8|0)==0){aG=1129}else{ba=a8;aG=1123}}else{aG=1129}}while(0);do{if((aG|0)==1123){aG=0;aD=c[a9+8>>2]|0;if((aD|0)==4){if((fw((c[a9>>2]|0)+16|0,o)|0)==0){aG=1129;break}bb=+h[o>>3]}else if((aD|0)==3){if((a9|0)==0){aG=1129;break}bb=+h[a9>>3]}else{aG=1129;break}h[aI>>3]=+h[ba>>3]/bb;c[ax+(aH<<4)+8>>2]=3}}while(0);L1537:do{if((aG|0)==1129){aG=0;aD=gg(b,a8,8)|0;do{if((c[aD+8>>2]|0)==0){az=gg(b,a9,8)|0;if((c[az+8>>2]|0)!=0){bc=az;break}eu(b,a8,a9);break L1537}else{bc=aD}}while(0);aD=aI-(c[T>>2]|0)|0;az=c[U>>2]|0;ay=bc;aw=az;aN=c[ay+4>>2]|0;c[aw>>2]=c[ay>>2];c[aw+4>>2]=aN;c[az+8>>2]=c[bc+8>>2];az=c[U>>2]|0;aN=a8;aw=az+16|0;ay=c[aN+4>>2]|0;c[aw>>2]=c[aN>>2];c[aw+4>>2]=ay;c[az+24>>2]=c[aA>>2];az=c[U>>2]|0;ay=a9;aw=az+32|0;aN=c[ay+4>>2]|0;c[aw>>2]=c[ay>>2];c[aw+4>>2]=aN;c[az+40>>2]=c[a9+8>>2];az=c[U>>2]|0;if(((c[V>>2]|0)-az|0)<49){eA(b,3);bd=c[U>>2]|0}else{bd=az}c[U>>2]=bd+48;eG(b,bd,1);az=c[T>>2]|0;aN=c[U>>2]|0;aw=aN-16|0;c[U>>2]=aw;ay=aw;aw=az+aD|0;aB=c[ay+4>>2]|0;c[aw>>2]=c[ay>>2];c[aw+4>>2]=aB;c[az+(aD+8)>>2]=c[aN-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 16:{aA=av>>>23;if((aA&256|0)==0){be=ax+(aA<<4)|0}else{be=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){bf=ax+((aA&511)<<4)|0}else{bf=aq+((aA&255)<<4)|0}aA=be+8|0;do{if((c[aA>>2]|0)==3){if((c[bf+8>>2]|0)!=3){break}bg=+h[be>>3];bh=+h[bf>>3];h[aI>>3]=bg-bh*+O(+(bg/bh));c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}}while(0);c[I>>2]=au;aN=c[aA>>2]|0;do{if((aN|0)==4){if((fw((c[be>>2]|0)+16|0,n)|0)==0){aG=1155;break}h[ac>>3]=+h[n>>3];c[ad>>2]=3;bi=B;aG=1149}else if((aN|0)==3){if((be|0)==0){aG=1155}else{bi=be;aG=1149}}else{aG=1155}}while(0);do{if((aG|0)==1149){aG=0;aN=c[bf+8>>2]|0;if((aN|0)==4){if((fw((c[bf>>2]|0)+16|0,m)|0)==0){aG=1155;break}bj=+h[m>>3]}else if((aN|0)==3){if((bf|0)==0){aG=1155;break}bj=+h[bf>>3]}else{aG=1155;break}bh=+h[bi>>3];h[aI>>3]=bh-bj*+O(+(bh/bj));c[ax+(aH<<4)+8>>2]=3}}while(0);L1572:do{if((aG|0)==1155){aG=0;aN=gg(b,be,9)|0;do{if((c[aN+8>>2]|0)==0){aD=gg(b,bf,9)|0;if((c[aD+8>>2]|0)!=0){bk=aD;break}eu(b,be,bf);break L1572}else{bk=aN}}while(0);aN=aI-(c[T>>2]|0)|0;aD=c[U>>2]|0;az=bk;aB=aD;aw=c[az+4>>2]|0;c[aB>>2]=c[az>>2];c[aB+4>>2]=aw;c[aD+8>>2]=c[bk+8>>2];aD=c[U>>2]|0;aw=be;aB=aD+16|0;az=c[aw+4>>2]|0;c[aB>>2]=c[aw>>2];c[aB+4>>2]=az;c[aD+24>>2]=c[aA>>2];aD=c[U>>2]|0;az=bf;aB=aD+32|0;aw=c[az+4>>2]|0;c[aB>>2]=c[az>>2];c[aB+4>>2]=aw;c[aD+40>>2]=c[bf+8>>2];aD=c[U>>2]|0;if(((c[V>>2]|0)-aD|0)<49){eA(b,3);bl=c[U>>2]|0}else{bl=aD}c[U>>2]=bl+48;eG(b,bl,1);aD=c[T>>2]|0;aw=c[U>>2]|0;aB=aw-16|0;c[U>>2]=aB;az=aB;aB=aD+aN|0;ay=c[az+4>>2]|0;c[aB>>2]=c[az>>2];c[aB+4>>2]=ay;c[aD+(aN+8)>>2]=c[aw-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 17:{aA=av>>>23;if((aA&256|0)==0){bm=ax+(aA<<4)|0}else{bm=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){bn=ax+((aA&511)<<4)|0}else{bn=aq+((aA&255)<<4)|0}aA=bm+8|0;do{if((c[aA>>2]|0)==3){if((c[bn+8>>2]|0)!=3){break}h[aI>>3]=+R(+(+h[bm>>3]),+(+h[bn>>3]));c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}}while(0);c[I>>2]=au;aw=c[aA>>2]|0;do{if((aw|0)==4){if((fw((c[bm>>2]|0)+16|0,l)|0)==0){aG=1181;break}h[ae>>3]=+h[l>>3];c[af>>2]=3;bo=A;aG=1175}else if((aw|0)==3){if((bm|0)==0){aG=1181}else{bo=bm;aG=1175}}else{aG=1181}}while(0);do{if((aG|0)==1175){aG=0;aw=c[bn+8>>2]|0;if((aw|0)==4){if((fw((c[bn>>2]|0)+16|0,k)|0)==0){aG=1181;break}bp=+h[k>>3]}else if((aw|0)==3){if((bn|0)==0){aG=1181;break}bp=+h[bn>>3]}else{aG=1181;break}h[aI>>3]=+R(+(+h[bo>>3]),+bp);c[ax+(aH<<4)+8>>2]=3}}while(0);L1607:do{if((aG|0)==1181){aG=0;aw=gg(b,bm,10)|0;do{if((c[aw+8>>2]|0)==0){aN=gg(b,bn,10)|0;if((c[aN+8>>2]|0)!=0){bq=aN;break}eu(b,bm,bn);break L1607}else{bq=aw}}while(0);aw=aI-(c[T>>2]|0)|0;aN=c[U>>2]|0;aD=bq;ay=aN;aB=c[aD+4>>2]|0;c[ay>>2]=c[aD>>2];c[ay+4>>2]=aB;c[aN+8>>2]=c[bq+8>>2];aN=c[U>>2]|0;aB=bm;ay=aN+16|0;aD=c[aB+4>>2]|0;c[ay>>2]=c[aB>>2];c[ay+4>>2]=aD;c[aN+24>>2]=c[aA>>2];aN=c[U>>2]|0;aD=bn;ay=aN+32|0;aB=c[aD+4>>2]|0;c[ay>>2]=c[aD>>2];c[ay+4>>2]=aB;c[aN+40>>2]=c[bn+8>>2];aN=c[U>>2]|0;if(((c[V>>2]|0)-aN|0)<49){eA(b,3);br=c[U>>2]|0}else{br=aN}c[U>>2]=br+48;eG(b,br,1);aN=c[T>>2]|0;aB=c[U>>2]|0;ay=aB-16|0;c[U>>2]=ay;aD=ay;ay=aN+aw|0;az=c[aD+4>>2]|0;c[ay>>2]=c[aD>>2];c[ay+4>>2]=az;c[aN+(aw+8)>>2]=c[aB-16+8>>2]}}while(0);ao=c[K>>2]|0;at=au;continue L1322;break};case 19:{aA=av>>>23;aB=c[ax+(aA<<4)+8>>2]|0;do{if((aB|0)==0){bs=1}else{if((aB|0)!=1){bs=0;break}bs=(c[ax+(aA<<4)>>2]|0)==0|0}}while(0);c[aI>>2]=bs;c[ax+(aH<<4)+8>>2]=1;ao=ax;at=au;continue L1322;break};case 20:{aA=av>>>23;aB=ax+(aA<<4)|0;aw=ax+(aA<<4)+8|0;aA=c[aw>>2]|0;if((aA|0)==5){h[aI>>3]=+(ga(c[aB>>2]|0)|0);c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}else if((aA|0)==4){h[aI>>3]=+((c[(c[aB>>2]|0)+12>>2]|0)>>>0>>>0);c[ax+(aH<<4)+8>>2]=3;ao=ax;at=au;continue L1322}else{c[I>>2]=au;aA=gg(b,aB,12)|0;do{if((c[aA+8>>2]|0)==0){aN=gg(b,1032,12)|0;if((c[aN+8>>2]|0)!=0){bt=aN;aG=1214;break}eq(b,aB,3952)}else{bt=aA;aG=1214}}while(0);if((aG|0)==1214){aG=0;aA=aI-(c[T>>2]|0)|0;aN=c[U>>2]|0;az=bt;ay=aN;aD=c[az+4>>2]|0;c[ay>>2]=c[az>>2];c[ay+4>>2]=aD;c[aN+8>>2]=c[bt+8>>2];aN=c[U>>2]|0;aD=aB;ay=aN+16|0;az=c[aD+4>>2]|0;c[ay>>2]=c[aD>>2];c[ay+4>>2]=az;c[aN+24>>2]=c[aw>>2];aN=c[U>>2]|0;az=aN+32|0;ay=1032;aD=c[ay+4>>2]|0;c[az>>2]=c[ay>>2];c[az+4>>2]=aD;c[aN+40>>2]=ai;aN=c[U>>2]|0;if(((c[V>>2]|0)-aN|0)<49){eA(b,3);bu=c[U>>2]|0}else{bu=aN}c[U>>2]=bu+48;eG(b,bu,1);aN=c[T>>2]|0;aD=c[U>>2]|0;az=aD-16|0;c[U>>2]=az;ay=az;az=aN+aA|0;aC=c[ay+4>>2]|0;c[az>>2]=c[ay>>2];c[az+4>>2]=aC;c[aN+(aA+8)>>2]=c[aD-16+8>>2]}ao=c[K>>2]|0;at=au;continue L1322}break};case 21:{aD=av>>>23;aA=av>>>14&511;c[I>>2]=au;gq(b,1-aD+aA|0,aA);aA=c[S>>2]|0;if((c[aA+68>>2]|0)>>>0>=(c[aA+64>>2]|0)>>>0){e1(b)}aA=c[K>>2]|0;aN=aA+(aD<<4)|0;aC=aA+(aH<<4)|0;az=c[aN+4>>2]|0;c[aC>>2]=c[aN>>2];c[aC+4>>2]=az;c[aA+(aH<<4)+8>>2]=c[aA+(aD<<4)+8>>2];ao=aA;at=au;continue L1322;break};case 22:{ao=ax;at=at+((av>>>14)-131070<<2)|0;continue L1322;break};case 23:{aA=av>>>23;if((aA&256|0)==0){bv=ax+(aA<<4)|0}else{bv=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){bw=ax+((aA&511)<<4)|0}else{bw=aq+((aA&255)<<4)|0}c[I>>2]=au;if((c[bv+8>>2]|0)==(c[bw+8>>2]|0)){bx=(gp(b,bv,bw)|0)!=0|0}else{bx=0}if((bx|0)==(aH|0)){by=at+(((c[au>>2]|0)>>>14)-131070<<2)|0}else{by=au}ao=c[K>>2]|0;at=by+4|0;continue L1322;break};case 24:{c[I>>2]=au;aA=av>>>23;if((aA&256|0)==0){bz=ax+(aA<<4)|0}else{bz=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){bA=ax+((aA&511)<<4)|0}else{bA=aq+((aA&255)<<4)|0}if((go(b,bz,bA)|0)==(aH|0)){bB=at+(((c[au>>2]|0)>>>14)-131070<<2)|0}else{bB=au}ao=c[K>>2]|0;at=bB+4|0;continue L1322;break};case 25:{c[I>>2]=au;aA=av>>>23;if((aA&256|0)==0){bC=ax+(aA<<4)|0}else{bC=aq+((aA&255)<<4)|0}aA=av>>>14;if((aA&256|0)==0){bD=ax+((aA&511)<<4)|0}else{bD=aq+((aA&255)<<4)|0}aA=bC+8|0;aD=c[aA>>2]|0;az=bD+8|0;L1677:do{if((aD|0)==(c[az>>2]|0)){if((aD|0)==3){bE=+h[bC>>3]<=+h[bD>>3]|0;break}else if((aD|0)==4){aC=c[bC>>2]|0;aN=c[bD>>2]|0;ay=aC+16|0;bF=aN+16|0;bG=aL(ay|0,bF|0)|0;L1683:do{if((bG|0)==0){bH=ay;bI=c[aC+12>>2]|0;bJ=bF;bK=c[aN+12>>2]|0;while(1){bL=j_(bH|0)|0;bM=(bL|0)==(bI|0);if((bL|0)==(bK|0)){break}if(bM){bN=-1;break L1683}bO=bL+1|0;bL=bH+bO|0;bP=bJ+bO|0;bQ=aL(bL|0,bP|0)|0;if((bQ|0)==0){bH=bL;bI=bI-bO|0;bJ=bP;bK=bK-bO|0}else{bN=bQ;break L1683}}bN=bM&1^1}else{bN=bG}}while(0);bE=(bN|0)<1|0;break}else{bG=gg(b,bC,14)|0;aN=bG+8|0;do{if((c[aN>>2]|0)!=0){if((fr(bG,gg(b,bD,14)|0)|0)==0){break}bF=c[U>>2]|0;aC=bF-(c[T>>2]|0)|0;ay=bG;bK=bF;bJ=c[ay+4>>2]|0;c[bK>>2]=c[ay>>2];c[bK+4>>2]=bJ;c[bF+8>>2]=c[aN>>2];bF=c[U>>2]|0;bJ=bC;bK=bF+16|0;ay=c[bJ+4>>2]|0;c[bK>>2]=c[bJ>>2];c[bK+4>>2]=ay;c[bF+24>>2]=c[aA>>2];bF=c[U>>2]|0;ay=bD;bK=bF+32|0;bJ=c[ay+4>>2]|0;c[bK>>2]=c[ay>>2];c[bK+4>>2]=bJ;c[bF+40>>2]=c[az>>2];bF=c[U>>2]|0;if(((c[V>>2]|0)-bF|0)<49){eA(b,3);bR=c[U>>2]|0}else{bR=bF}c[U>>2]=bR+48;eG(b,bR,1);bF=c[T>>2]|0;bJ=c[U>>2]|0;bK=bJ-16|0;c[U>>2]=bK;ay=bK;bK=bF+aC|0;bI=c[ay+4>>2]|0;c[bK>>2]=c[ay>>2];c[bK+4>>2]=bI;c[bF+(aC+8)>>2]=c[bJ-16+8>>2];bJ=c[U>>2]|0;aC=c[bJ+8>>2]|0;if((aC|0)==0){bE=0;break L1677}if((aC|0)!=1){bE=1;break L1677}bE=(c[bJ>>2]|0)!=0|0;break L1677}}while(0);aN=gg(b,bD,13)|0;bG=aN+8|0;do{if((c[bG>>2]|0)!=0){if((fr(aN,gg(b,bC,13)|0)|0)==0){break}bJ=c[U>>2]|0;aC=bJ-(c[T>>2]|0)|0;bF=aN;bI=bJ;bK=c[bF+4>>2]|0;c[bI>>2]=c[bF>>2];c[bI+4>>2]=bK;c[bJ+8>>2]=c[bG>>2];bJ=c[U>>2]|0;bK=bD;bI=bJ+16|0;bF=c[bK+4>>2]|0;c[bI>>2]=c[bK>>2];c[bI+4>>2]=bF;c[bJ+24>>2]=c[az>>2];bJ=c[U>>2]|0;bF=bC;bI=bJ+32|0;bK=c[bF+4>>2]|0;c[bI>>2]=c[bF>>2];c[bI+4>>2]=bK;c[bJ+40>>2]=c[aA>>2];bJ=c[U>>2]|0;if(((c[V>>2]|0)-bJ|0)<49){eA(b,3);bS=c[U>>2]|0}else{bS=bJ}c[U>>2]=bS+48;eG(b,bS,1);bJ=c[T>>2]|0;bK=c[U>>2]|0;bI=bK-16|0;c[U>>2]=bI;bF=bI;bI=bJ+aC|0;ay=c[bF+4>>2]|0;c[bI>>2]=c[bF>>2];c[bI+4>>2]=ay;c[bJ+(aC+8)>>2]=c[bK-16+8>>2];bK=c[U>>2]|0;aC=c[bK+8>>2]|0;if((aC|0)==0){bE=1;break L1677}if((aC|0)!=1){bE=0;break L1677}bE=(c[bK>>2]|0)==0|0;break L1677}}while(0);bE=ev(b,bC,bD)|0;break}}else{bE=ev(b,bC,bD)|0}}while(0);if((bE|0)==(aH|0)){bT=at+(((c[au>>2]|0)>>>14)-131070<<2)|0}else{bT=au}ao=c[K>>2]|0;at=bT+4|0;continue L1322;break};case 26:{aA=c[ax+(aH<<4)+8>>2]|0;do{if((aA|0)==0){bU=1}else{if((aA|0)!=1){bU=0;break}bU=(c[aI>>2]|0)==0|0}}while(0);if((bU|0)==(av>>>14&511|0)){bV=au}else{bV=at+(((c[au>>2]|0)>>>14)-131070<<2)|0}ao=ax;at=bV+4|0;continue L1322;break};case 27:{aA=av>>>23;az=ax+(aA<<4)|0;aD=c[ax+(aA<<4)+8>>2]|0;do{if((aD|0)==0){bW=1}else{if((aD|0)!=1){bW=0;break}bW=(c[az>>2]|0)==0|0}}while(0);if((bW|0)==(av>>>14&511|0)){bX=au}else{aA=az;aw=aI;aB=c[aA+4>>2]|0;c[aw>>2]=c[aA>>2];c[aw+4>>2]=aB;c[ax+(aH<<4)+8>>2]=aD;bX=at+(((c[au>>2]|0)>>>14)-131070<<2)|0}ao=ax;at=bX+4|0;continue L1322;break};case 28:{aB=av>>>23;aw=av>>>14&511;if((aB|0)!=0){c[U>>2]=ax+(aH+aB<<4)}c[I>>2]=au;aB=eF(b,aI,aw-1|0)|0;if((aB|0)==0){aG=1293;break L1320}else if((aB|0)!=1){aG=1376;break L1318}if((aw|0)!=0){c[U>>2]=c[(c[J>>2]|0)+8>>2]}ao=c[K>>2]|0;at=au;continue L1322;break};case 29:{aw=av>>>23;if((aw|0)!=0){c[U>>2]=ax+(aH+aw<<4)}c[I>>2]=au;aw=eF(b,aI,-1)|0;if((aw|0)==0){break L1322}else if((aw|0)!=1){aG=1377;break L1318}ao=c[K>>2]|0;at=au;continue L1322;break};case 30:{break L1320;break};case 31:{bh=+h[ax+(aH+2<<4)>>3];aw=aI|0;bg=bh+ +h[aw>>3];bY=+h[ax+(aH+1<<4)>>3];if(bh>0.0){if(bg>bY){ao=ax;at=au;continue L1322}}else{if(bY>bg){ao=ax;at=au;continue L1322}}h[aw>>3]=bg;c[ax+(aH<<4)+8>>2]=3;aw=aH+3|0;h[ax+(aw<<4)>>3]=bg;c[ax+(aw<<4)+8>>2]=3;ao=ax;at=at+((av>>>14)-131070<<2)|0;continue L1322;break};case 32:{aw=aH+1|0;aB=ax+(aw<<4)|0;aA=aH+2|0;bG=ax+(aA<<4)|0;c[I>>2]=au;aN=ax+(aH<<4)+8|0;bK=c[aN>>2]|0;L1749:do{if((bK|0)==3){aG=1322}else{do{if((bK|0)==4){if((fw((c[aI>>2]|0)+16|0,y)|0)==0){break}h[aI>>3]=+h[y>>3];c[aN>>2]=3;if((aI|0)!=0){aG=1322;break L1749}}}while(0);es(b,3360,(bZ=i,i=i+1|0,i=i+7>>3<<3,c[bZ>>2]=0,bZ)|0);i=bZ}}while(0);L1755:do{if((aG|0)==1322){aG=0;bK=ax+(aw<<4)+8|0;aD=c[bK>>2]|0;L1757:do{if((aD|0)!=3){do{if((aD|0)==4){if((fw((c[aB>>2]|0)+16|0,x)|0)==0){break}h[aB>>3]=+h[x>>3];c[bK>>2]=3;if((aB|0)!=0){break L1757}}}while(0);es(b,2832,(bZ=i,i=i+1|0,i=i+7>>3<<3,c[bZ>>2]=0,bZ)|0);i=bZ;break L1755}}while(0);bK=ax+(aA<<4)+8|0;aD=c[bK>>2]|0;if((aD|0)==3){break}if((aD|0)!=4){aG=1372;break L1318}if((fw((c[bG>>2]|0)+16|0,w)|0)==0){aG=1373;break L1318}h[bG>>3]=+h[w>>3];c[bK>>2]=3;if((bG|0)==0){aG=1374;break L1318}}}while(0);aA=aI|0;h[aA>>3]=+h[aA>>3]- +h[bG>>3];c[aN>>2]=3;ao=ax;at=at+((av>>>14)-131070<<2)|0;continue L1322;break};case 33:{aA=aH+3|0;aB=ax+(aA<<4)|0;aw=aH+2|0;bK=aH+5|0;aD=ax+(aw<<4)|0;az=ax+(bK<<4)|0;aC=c[aD+4>>2]|0;c[az>>2]=c[aD>>2];c[az+4>>2]=aC;c[ax+(bK<<4)+8>>2]=c[ax+(aw<<4)+8>>2];bK=aH+1|0;aC=aH+4|0;az=ax+(bK<<4)|0;aD=ax+(aC<<4)|0;bJ=c[az+4>>2]|0;c[aD>>2]=c[az>>2];c[aD+4>>2]=bJ;c[ax+(aC<<4)+8>>2]=c[ax+(bK<<4)+8>>2];bK=aI;aC=aB;bJ=c[bK+4>>2]|0;c[aC>>2]=c[bK>>2];c[aC+4>>2]=bJ;c[ax+(aA<<4)+8>>2]=c[ax+(aH<<4)+8>>2];c[U>>2]=ax+(aH+6<<4);c[I>>2]=au;eG(b,aB,av>>>14&511);aB=c[K>>2]|0;c[U>>2]=c[(c[J>>2]|0)+8>>2];bJ=c[aB+(aA<<4)+8>>2]|0;if((bJ|0)==0){b_=au}else{aC=aB+(aA<<4)|0;aA=aB+(aw<<4)|0;bK=c[aC+4>>2]|0;c[aA>>2]=c[aC>>2];c[aA+4>>2]=bK;c[aB+(aw<<4)+8>>2]=bJ;b_=at+(((c[au>>2]|0)>>>14)-131070<<2)|0}ao=aB;at=b_+4|0;continue L1322;break};case 34:{aB=av>>>23;bJ=av>>>14&511;if((aB|0)==0){aw=((c[U>>2]|0)-aI>>4)-1|0;c[U>>2]=c[(c[J>>2]|0)+8>>2];b$=aw}else{b$=aB}if((bJ|0)==0){b0=at+8|0;b1=c[au>>2]|0}else{b0=au;b1=bJ}if((c[ax+(aH<<4)+8>>2]|0)!=5){ao=ax;at=b0;continue L1322}bJ=c[aI>>2]|0;aB=bJ;aw=b$-50+(b1*50|0)|0;if((aw|0)>(c[bJ+28>>2]|0)){f1(b,aB,aw)}if((b$|0)<=0){ao=ax;at=b0;continue L1322}bK=bJ+5|0;bJ=aw;aw=b$;while(1){aA=aw+aH|0;aC=ax+(aA<<4)|0;aD=bJ-1|0;az=gc(b,aB,bJ)|0;ay=aC;bI=az;bF=c[ay+4>>2]|0;c[bI>>2]=c[ay>>2];c[bI+4>>2]=bF;bF=ax+(aA<<4)+8|0;c[az+8>>2]=c[bF>>2];do{if((c[bF>>2]|0)>3){if((a[(c[aC>>2]|0)+5|0]&3)==0){break}if((a[bK]&4)==0){break}e2(b,aB)}}while(0);aC=aw-1|0;if((aC|0)>0){bJ=aD;aw=aC}else{ao=ax;at=b0;continue L1322}}break};case 35:{eU(b,aI);ao=ax;at=au;continue L1322;break};case 36:{aw=c[(c[(c[ap>>2]|0)+16>>2]|0)+(av>>>14<<2)>>2]|0;bJ=a[aw+72|0]|0;aB=bJ&255;bK=eP(b,aB,c[as>>2]|0)|0;aN=bK;c[bK+16>>2]=aw;if(bJ<<24>>24==0){b2=au}else{aw=(bJ&255)>1;bJ=0;bG=au;while(1){aC=c[bG>>2]|0;bF=aC>>>23;if((aC&63|0)==4){c[aN+20+(bJ<<2)>>2]=c[ar+(bF<<2)>>2]}else{c[aN+20+(bJ<<2)>>2]=eR(b,ax+(bF<<4)|0)|0}bF=bJ+1|0;if((bF|0)<(aB|0)){bJ=bF;bG=bG+4|0}else{break}}b2=at+((aw?aB+1|0:2)<<2)|0}c[aI>>2]=bK;c[ax+(aH<<4)+8>>2]=6;c[I>>2]=b2;bG=c[S>>2]|0;if((c[bG+68>>2]|0)>>>0>=(c[bG+64>>2]|0)>>>0){e1(b)}ao=c[K>>2]|0;at=b2;continue L1322;break};case 37:{bG=av>>>23;bJ=bG-1|0;aN=c[J>>2]|0;bF=aN|0;aC=((c[bF>>2]|0)-(c[aN+4>>2]|0)>>4)-(d[(c[ap>>2]|0)+73|0]|0)|0;aN=aC-1|0;if((bG|0)==0){c[I>>2]=au;if(((c[V>>2]|0)-(c[U>>2]|0)|0)<=(aN<<4|0)){eA(b,aN)}bG=c[K>>2]|0;c[U>>2]=bG+(aN+aH<<4);b3=bG;b4=bG+(aH<<4)|0;b5=aN}else{b3=ax;b4=aI;b5=bJ}if((b5|0)<=0){ao=b3;at=au;continue L1322}bJ=1-aC|0;aC=0;while(1){if((aC|0)<(aN|0)){bG=c[bF>>2]|0;az=aC+bJ|0;aA=bG+(az<<4)|0;bI=b4+(aC<<4)|0;ay=c[aA+4>>2]|0;c[bI>>2]=c[aA>>2];c[bI+4>>2]=ay;c[b4+(aC<<4)+8>>2]=c[bG+(az<<4)+8>>2]}else{c[b4+(aC<<4)+8>>2]=0}az=aC+1|0;if((az|0)<(b5|0)){aC=az}else{ao=b3;at=au;continue L1322}}break};default:{ao=ax;at=au;continue L1322}}}ao=c[J>>2]|0;ap=ao-24+4|0;ar=c[ap>>2]|0;as=c[ao+4>>2]|0;aq=ao-24|0;if((c[am>>2]|0)==0){b6=ar}else{eU(b,c[aq>>2]|0);b6=c[ap>>2]|0}ap=b6+((c[ao>>2]|0)-as>>4<<4)|0;c[aq>>2]=ap;c[K>>2]=ap;if(as>>>0<(c[U>>2]|0)>>>0){ap=0;aq=as;aC=ar;while(1){bJ=aq;bF=aC;aN=c[bJ+4>>2]|0;c[bF>>2]=c[bJ>>2];c[bF+4>>2]=aN;c[ar+(ap<<4)+8>>2]=c[as+(ap<<4)+8>>2];aN=ap+1|0;bF=as+(aN<<4)|0;bJ=ar+(aN<<4)|0;if(bF>>>0<(c[U>>2]|0)>>>0){ap=aN;aq=bF;aC=bJ}else{b7=bJ;break}}}else{b7=ar}c[U>>2]=b7;c[ao-24+8>>2]=b7;c[ao-24+12>>2]=c[I>>2];aC=ao-24+20|0;c[aC>>2]=(c[aC>>2]|0)+1;aC=(c[J>>2]|0)-24|0;c[J>>2]=aC;e=aC}if((aG|0)==1293){aG=0;an=an+1|0;continue}e=av>>>23;if((e|0)!=0){c[U>>2]=ax+(e-1+aH<<4)}if((c[am>>2]|0)!=0){eU(b,ax)}c[I>>2]=au;e=eD(b,aI)|0;aC=an-1|0;if((aC|0)==0){aG=1378;break}if((e|0)==0){an=aC;continue}c[U>>2]=c[(c[J>>2]|0)+8>>2];an=aC}if((aG|0)==999){c[I>>2]=at;i=f;return}else if((aG|0)==1372){es(b,2480,(bZ=i,i=i+1|0,i=i+7>>3<<3,c[bZ>>2]=0,bZ)|0);i=bZ}else if((aG|0)==1373){es(b,2480,(bZ=i,i=i+1|0,i=i+7>>3<<3,c[bZ>>2]=0,bZ)|0);i=bZ}else if((aG|0)==1374){es(b,2480,(bZ=i,i=i+1|0,i=i+7>>3<<3,c[bZ>>2]=0,bZ)|0);i=bZ}else if((aG|0)==1376){i=f;return}else if((aG|0)==1377){i=f;return}else if((aG|0)==1378){i=f;return}}function gs(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;c[b+16>>2]=a;c[b+8>>2]=d;c[b+12>>2]=e;c[b>>2]=0;c[b+4>>2]=0;return}function gt(a,b){a=a|0;b=b|0;c[b+8>>2]=a;c[b>>2]=b+12;c[b+4>>2]=0;return}function gu(a){a=a|0;var b=0,e=0,f=0,g=0,h=0;b=i;i=i+8|0;e=b|0;f=ch[c[a+8>>2]&511](c[a+16>>2]|0,c[a+12>>2]|0,e)|0;if((f|0)==0){g=-1;i=b;return g|0}h=c[e>>2]|0;if((h|0)==0){g=-1;i=b;return g|0}c[a>>2]=h-1;c[a+4>>2]=f+1;g=d[f]|0;i=b;return g|0}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7840 function gv(a){a=a|0;var b=0,e=0,f=0,g=0,h=0,j=0,k=0;b=i;i=i+8|0;e=b|0;f=a|0;do{if((c[f>>2]|0)==0){g=ch[c[a+8>>2]&511](c[a+16>>2]|0,c[a+12>>2]|0,e)|0;if((g|0)==0){h=-1;i=b;return h|0}j=c[e>>2]|0;if((j|0)==0){h=-1;i=b;return h|0}else{c[f>>2]=j;c[a+4>>2]=g;k=g;break}}else{k=c[a+4>>2]|0}}while(0);h=d[k]|0;i=b;return h|0}function gw(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=i;i=i+8|0;f=e|0;if((d|0)==0){g=0;i=e;return g|0}h=a|0;j=a+16|0;k=a+8|0;l=a+12|0;m=a+4|0;a=b;b=d;d=c[h>>2]|0;while(1){if((d|0)==0){n=ch[c[k>>2]&511](c[j>>2]|0,c[l>>2]|0,f)|0;if((n|0)==0){g=b;o=1410;break}p=c[f>>2]|0;if((p|0)==0){g=b;o=1409;break}c[h>>2]=p;c[m>>2]=n;q=p;r=n}else{q=d;r=c[m>>2]|0}n=b>>>0>q>>>0?q:b;j$(a|0,r|0,n)|0;p=(c[h>>2]|0)-n|0;c[h>>2]=p;c[m>>2]=(c[m>>2]|0)+n;if((b|0)==(n|0)){g=0;o=1408;break}else{a=a+n|0;b=b-n|0;d=p}}if((o|0)==1409){i=e;return g|0}else if((o|0)==1408){i=e;return g|0}else if((o|0)==1410){i=e;return g|0}return 0}function gx(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=b+8|0;f=c[e>>2]|0;if(f>>>0>=d>>>0){g=c[b>>2]|0;return g|0}h=d>>>0<32?32:d;if((h+1|0)>>>0<4294967294){d=b|0;i=fu(a,c[d>>2]|0,f,h)|0;j=d}else{i=fv(a)|0;j=b|0}c[j>>2]=i;c[e>>2]=h;g=i;return g|0}function gy(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;i=i+104|0;f=e|0;if((ej(a,0,f)|0)==0){g=gz(a,6560,(h=i,i=i+16|0,c[h>>2]=b,c[h+8>>2]=d,h)|0)|0;i=h;j=g;i=e;return j|0}en(a,9736,f)|0;do{if((aL(c[f+8>>2]|0,7800)|0)==0){g=b-1|0;if((g|0)!=0){k=g;break}g=gz(a,5928,(h=i,i=i+16|0,c[h>>2]=c[f+4>>2],c[h+8>>2]=d,h)|0)|0;i=h;j=g;i=e;return j|0}else{k=b}}while(0);b=f+4|0;f=c[b>>2]|0;if((f|0)==0){c[b>>2]=4656;l=4656}else{l=f}f=gz(a,3912,(h=i,i=i+24|0,c[h>>2]=k,c[h+8>>2]=l,c[h+16>>2]=d,h)|0)|0;i=h;j=f;i=e;return j|0}function gz(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;i=i+120|0;f=e|0;g=e+104|0;h=g|0;j=g;c[j>>2]=d;c[j+4>>2]=0;do{if((ej(a,1,f)|0)!=0){en(a,2816,f)|0;j=c[f+20>>2]|0;if((j|0)<=0){break}d=f+36|0;dc(a,2464,(g=i,i=i+16|0,c[g>>2]=d,c[g+8>>2]=j,g)|0)|0;i=g;k=db(a,b,h)|0;dG(a,2);l=dE(a)|0;i=e;return l|0}}while(0);c9(a,10520,0);k=db(a,b,h)|0;dG(a,2);l=dE(a)|0;i=e;return l|0}function gA(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=i;f=cL(a,cK(a,b)|0)|0;g=dc(a,3328,(h=i,i=i+16|0,c[h>>2]=d,c[h+8>>2]=f,h)|0)|0;i=h;h=gy(a,b,g)|0;i=e;return h|0}function gB(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=i;i=i+104|0;e=d|0;do{if((ej(a,b,e)|0)!=0){en(a,2816,e)|0;f=c[e+20>>2]|0;if((f|0)<=0){break}g=e+36|0;dc(a,2464,(h=i,i=i+16|0,c[h>>2]=g,c[h+8>>2]=f,h)|0)|0;i=h;i=d;return}}while(0);c9(a,10520,0);i=d;return}function gC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;f=i;do{if((d|0)==0){g=c0(a,b,0)|0;if((g|0)!=0){h=g;break}g=cL(a,4)|0;j=cL(a,cK(a,b)|0)|0;k=dc(a,3328,(l=i,i=i+16|0,c[l>>2]=g,c[l+8>>2]=j,l)|0)|0;i=l;gy(a,b,k)|0;h=0}else{h=gD(a,b,d,0)|0}}while(0);d=0;while(1){k=c[e+(d<<2)>>2]|0;if((k|0)==0){break}if((aL(k|0,h|0)|0)==0){m=d;n=1457;break}else{d=d+1|0}}if((n|0)==1457){i=f;return m|0}n=dc(a,10352,(l=i,i=i+8|0,c[l>>2]=h,l)|0)|0;i=l;m=gy(a,b,n)|0;i=f;return m|0}function gD(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0;f=i;if((cK(a,b)|0)>=1){g=c0(a,b,e)|0;if((g|0)!=0){h=g;i=f;return h|0}g=cL(a,4)|0;j=cL(a,cK(a,b)|0)|0;k=dc(a,3328,(l=i,i=i+16|0,c[l>>2]=g,c[l+8>>2]=j,l)|0)|0;i=l;gy(a,b,k)|0;h=0;i=f;return h|0}if((e|0)==0){h=d;i=f;return h|0}if((d|0)==0){m=0}else{m=j_(d|0)|0}c[e>>2]=m;h=d;i=f;return h|0}function gE(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;e=i;f=c0(a,b,d)|0;if((f|0)!=0){i=e;return f|0}d=cL(a,4)|0;g=cL(a,cK(a,b)|0)|0;h=dc(a,3328,(j=i,i=i+16|0,c[j>>2]=d,c[j+8>>2]=g,j)|0)|0;i=j;gy(a,b,h)|0;i=e;return f|0}function gF(a,b){a=a|0;b=b|0;var c=0;df(a,-1e4,b);if((cK(a,-1)|0)!=0){c=0;return c|0}cG(a,-2);di(a,0,0);cJ(a,-1);dm(a,-1e4,b);c=1;return c|0}function gG(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;e=i;f=cZ(a,b)|0;do{if((f|0)!=0){if((dj(a,b)|0)==0){break}df(a,-1e4,d);if((cT(a,-1,-2)|0)==0){break}cG(a,-3);g=f;i=e;return g|0}}while(0);f=cL(a,cK(a,b)|0)|0;h=dc(a,3328,(j=i,i=i+16|0,c[j>>2]=d,c[j+8>>2]=f,j)|0)|0;i=j;gy(a,b,h)|0;g=0;i=e;return g|0}function gH(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;e=i;if((cN(a,b)|0)!=0){i=e;return}gz(a,10176,(a=i,i=i+8|0,c[a>>2]=d,a)|0)|0;i=a;i=e;return}function gI(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0;e=i;if((cK(a,b)|0)==(d|0)){i=e;return}f=cL(a,d)|0;d=cL(a,cK(a,b)|0)|0;g=dc(a,3328,(h=i,i=i+16|0,c[h>>2]=f,c[h+8>>2]=d,h)|0)|0;i=h;gy(a,b,g)|0;i=e;return}function gJ(a,b){a=a|0;b=b|0;if((cK(a,b)|0)!=-1){return}gy(a,b,9896)|0;return}function gK(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0,g=0,h=0,j=0;d=i;e=+cW(a,b);if(e!=0.0){i=d;return+e}if((cS(a,b)|0)!=0){i=d;return+e}f=cL(a,3)|0;g=cL(a,cK(a,b)|0)|0;h=dc(a,3328,(j=i,i=i+16|0,c[j>>2]=f,c[j+8>>2]=g,j)|0)|0;i=j;gy(a,b,h)|0;i=d;return+e}function gL(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;if((cK(a,b)|0)<1){d=c;return+d}d=+gK(a,b);return+d}function gM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0;d=i;e=c$(a,b)|0;if((e|0)!=0){i=d;return e|0}if((cS(a,b)|0)!=0){i=d;return e|0}f=cL(a,3)|0;g=cL(a,cK(a,b)|0)|0;h=dc(a,3328,(j=i,i=i+16|0,c[j>>2]=f,c[j+8>>2]=g,j)|0)|0;i=j;gy(a,b,h)|0;i=d;return e|0}function gN(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((cK(a,b)|0)<1){d=c;return d|0}d=gM(a,b)|0;return d|0}function gO(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((dj(a,b)|0)==0){d=0;return d|0}da(a,c);dg(a,-2);if((cK(a,-1)|0)==0){cG(a,-3);d=0;return d|0}else{cH(a,-2);d=1;return d|0}return 0}function gP(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0;if((b+9999|0)>>>0>9999){d=b}else{d=b+1+(cF(a)|0)|0}if((dj(a,d)|0)==0){e=0;return e|0}da(a,c);dg(a,-2);if((cK(a,-1)|0)==0){cG(a,-3);e=0;return e|0}else{cH(a,-2);cJ(a,d);dw(a,1,1);e=1;return e|0}return 0}function gQ(a,b,c){a=a|0;b=b|0;c=c|0;gR(a,b,c,0);return}function gR(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;f=i;g=d|0;if((b|0)!=0){if((c[g>>2]|0)==0){h=0}else{j=d;d=0;while(1){k=d+1|0;l=j+8|0;if((c[l>>2]|0)==0){h=k;break}else{j=l;d=k}}}gS(a,-1e4,9680,1)|0;df(a,-1,b);if((cK(a,-1)|0)!=5){cG(a,-2);if((gS(a,-10002,b,h)|0)!=0){gz(a,9464,(h=i,i=i+8|0,c[h>>2]=b,h)|0)|0;i=h}cJ(a,-1);dm(a,-3,b)}cH(a,-2);cI(a,~e)}if((c[g>>2]|0)==0){m=~e;cG(a,m);i=f;return}b=-2-e|0;h=-e|0;if((e|0)>0){n=g}else{d=g;do{dd(a,c[d+4>>2]|0,e);dm(a,b,c[d>>2]|0);d=d+8|0;}while((c[d>>2]|0)!=0);m=~e;cG(a,m);i=f;return}do{d=0;do{cJ(a,h);d=d+1|0;}while((d|0)<(e|0));dd(a,c[n+4>>2]|0,e);dm(a,b,c[n>>2]|0);n=n+8|0;}while((c[n>>2]|0)!=0);m=~e;cG(a,m);i=f;return}function gS(b,c,d,e){b=b|0;c=c|0;d=d|0;e=e|0;var f=0,g=0,h=0;cJ(b,c);c=d;while(1){d=aU(c|0,46)|0;if((d|0)==0){f=c+(j_(c|0)|0)|0}else{f=d}d=f-c|0;c9(b,c,d);dg(b,-2);if((cK(b,-1)|0)==0){cG(b,-2);di(b,0,(a[f]|0)==46?1:e);c9(b,c,d);cJ(b,-2);dl(b,-4)}else{if((cK(b,-1)|0)!=5){break}}cH(b,-2);if((a[f]|0)==46){c=f+1|0}else{g=0;h=1573;break}}if((h|0)==1573){return g|0}cG(b,-3);g=c;return g|0}function gT(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;g=i;i=i+1040|0;h=g|0;j=j_(e|0)|0;k=h+8|0;c[k>>2]=b;l=h+12|0;m=h|0;c[m>>2]=l;n=h+4|0;c[n>>2]=0;o=aF(d|0,e|0)|0;if((o|0)==0){p=d}else{q=h+1036|0;r=d;d=o;while(1){L2080:do{if((d|0)!=(r|0)){o=r;s=d-r|0;while(1){t=s-1|0;u=c[m>>2]|0;if(u>>>0<q>>>0){v=u}else{gY(h)|0;v=c[m>>2]|0}u=a[o]|0;c[m>>2]=v+1;a[v]=u;if((t|0)==0){break L2080}o=o+1|0;s=t}}}while(0);s=j_(f|0)|0;L2089:do{if((s|0)!=0){o=f;t=s;while(1){u=t-1|0;w=c[m>>2]|0;if(w>>>0<q>>>0){x=w}else{gY(h)|0;x=c[m>>2]|0}w=a[o]|0;c[m>>2]=x+1;a[x]=w;if((u|0)==0){break L2089}o=o+1|0;t=u}}}while(0);s=d+j|0;t=aF(s|0,e|0)|0;if((t|0)==0){p=s;break}else{r=s;d=t}}}d=j_(p|0)|0;L2098:do{if((d|0)!=0){r=h+1036|0;e=p;j=d;while(1){x=j-1|0;q=c[m>>2]|0;if(q>>>0<r>>>0){y=q}else{gY(h)|0;y=c[m>>2]|0}q=a[e]|0;c[m>>2]=y+1;a[y]=q;if((x|0)==0){break L2098}e=e+1|0;j=x}}}while(0);y=c[m>>2]|0;if((y|0)==(l|0)){z=c[n>>2]|0;A=c[k>>2]|0;dG(A,z);c[n>>2]=1;B=c0(b,-1,0)|0;i=g;return B|0}else{c9(c[k>>2]|0,l,y-l|0);c[m>>2]=l;l=(c[n>>2]|0)+1|0;c[n>>2]=l;z=l;A=c[k>>2]|0;dG(A,z);c[n>>2]=1;B=c0(b,-1,0)|0;i=g;return B|0}return 0}function gU(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;a=b+4|0;e=c[a>>2]|0;if((e|0)==0){f=0;return f|0}c[d>>2]=e;c[a>>2]=0;f=c[b>>2]|0;return f|0}function gV(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0;if((e|0)==0){return}f=b|0;g=b+1036|0;h=d;d=e;while(1){e=d-1|0;i=c[f>>2]|0;if(i>>>0<g>>>0){j=i}else{gY(b)|0;j=c[f>>2]|0}i=a[h]|0;c[f>>2]=j+1;a[j]=i;if((e|0)==0){break}else{h=h+1|0;d=e}}return}function gW(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;e=j_(d|0)|0;if((e|0)==0){return}f=b|0;g=b+1036|0;h=d;d=e;while(1){e=d-1|0;i=c[f>>2]|0;if(i>>>0<g>>>0){j=i}else{gY(b)|0;j=c[f>>2]|0}i=a[h]|0;c[f>>2]=j+1;a[j]=i;if((e|0)==0){break}else{h=h+1|0;d=e}}return}function gX(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=a|0;d=c[b>>2]|0;e=a+12|0;if((d|0)==(e|0)){f=c[a+4>>2]|0;g=a+8|0}else{h=a+8|0;c9(c[h>>2]|0,e,d-e|0);c[b>>2]=e;e=a+4|0;b=(c[e>>2]|0)+1|0;c[e>>2]=b;f=b;g=h}dG(c[g>>2]|0,f);c[a+4>>2]=1;return}function gY(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=a|0;d=c[b>>2]|0;e=a+12|0;if((d|0)==(e|0)){return e|0}f=a+8|0;c9(c[f>>2]|0,e,d-e|0);c[b>>2]=e;b=a+4|0;a=c[b>>2]|0;c[b>>2]=a+1;if((a|0)<=0){return e|0}a=c[f>>2]|0;f=1;d=c1(a,-1)|0;while(1){g=f+1|0;h=c1(a,~f)|0;i=c[b>>2]|0;if(!((1-f+i|0)>9|d>>>0>h>>>0)){j=f;break}if((g|0)<(i|0)){f=g;d=h+d|0}else{j=g;break}}dG(a,j);c[b>>2]=1-j+(c[b>>2]|0);return e|0}function gZ(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;b=i;i=i+8|0;d=b|0;e=a+8|0;f=c[e>>2]|0;g=c0(f,-1,d)|0;h=c[d>>2]|0;j=a|0;k=c[j>>2]|0;l=a+12|0;m=k;n=l;if(h>>>0<=(n+1024-m|0)>>>0){j$(k|0,g|0,h)|0;c[j>>2]=(c[j>>2]|0)+(c[d>>2]|0);cG(f,-2);i=b;return}if((k|0)==(l|0)){o=a+4|0}else{c9(c[e>>2]|0,l,m-n|0);c[j>>2]=l;l=a+4|0;c[l>>2]=(c[l>>2]|0)+1;cI(f,-2);o=l}l=c[o>>2]|0;c[o>>2]=l+1;if((l|0)<=0){i=b;return}l=c[e>>2]|0;e=1;f=c1(l,-1)|0;while(1){a=e+1|0;j=c1(l,~e)|0;n=c[o>>2]|0;if(!((1-e+n|0)>9|f>>>0>j>>>0)){p=e;break}if((a|0)<(n|0)){e=a;f=j+f|0}else{p=a;break}}dG(l,p);c[o>>2]=1-p+(c[o>>2]|0);i=b;return}function g_(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;if((b+9999|0)>>>0>9999){c=b}else{c=b+1+(cF(a)|0)|0}if((cK(a,-1)|0)==0){cG(a,-2);d=-1;return d|0}dh(a,c,0);b=c$(a,-1)|0;cG(a,-2);if((b|0)==0){e=(c1(a,c)|0)+1|0}else{dh(a,c,b);dp(a,c,0);e=b}dp(a,c,e);d=e;return d|0}function g$(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((c|0)<=-1){return}if((b+9999|0)>>>0>9999){d=b}else{d=b+1+(cF(a)|0)|0}dh(a,d,0);dp(a,d,c);c5(a,c);dp(a,d,0);return}function g0(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0;d=i;i=i+1032|0;e=d|0;f=(cF(a)|0)+1|0;g=e|0;c[g>>2]=0;h=(b|0)==0;do{if(h){c9(a,9256,6);j=c[m>>2]|0;c[e+4>>2]=j;k=j}else{dc(a,9128,(l=i,i=i+8|0,c[l>>2]=b,l)|0)|0;i=l;j=bl(b|0,8984)|0;c[e+4>>2]=j;if((j|0)!=0){k=j;break}j=bF(c[(bE()|0)>>2]|0)|0;n=(c0(a,f,0)|0)+1|0;dc(a,7280,(l=i,i=i+24|0,c[l>>2]=8824,c[l+8>>2]=n,c[l+16>>2]=j,l)|0)|0;i=l;cH(a,f);o=6;i=d;return o|0}}while(0);j=e+4|0;n=aQ(k|0)|0;L2199:do{if((n|0)==35){c[g>>2]=1;while(1){k=aQ(c[j>>2]|0)|0;if((k|0)==10){break}else if((k|0)==(-1|0)){p=-1;break L2199}}q=aQ(c[j>>2]|0)|0;r=1676}else{q=n;r=1676}}while(0);do{if((r|0)==1676){if((q|0)!=27|h){p=q;break}n=a1(b|0,8440,c[j>>2]|0)|0;c[j>>2]=n;if((n|0)==0){k=bF(c[(bE()|0)>>2]|0)|0;s=(c0(a,f,0)|0)+1|0;dc(a,7280,(l=i,i=i+24|0,c[l>>2]=8224,c[l+8>>2]=s,c[l+16>>2]=k,l)|0)|0;i=l;cH(a,f);o=6;i=d;return o|0}else{t=n}while(1){u=aQ(t|0)|0;if((u|0)==(-1|0)|(u|0)==27){break}t=c[j>>2]|0}c[g>>2]=0;p=u}}while(0);bI(p|0,c[j>>2]|0)|0;p=dB(a,254,e,c0(a,-1,0)|0)|0;e=c[j>>2]|0;j=a4(e|0)|0;if(!h){ar(e|0)|0}if((j|0)==0){cH(a,f);o=p;i=d;return o|0}else{cG(a,f);p=bF(c[(bE()|0)>>2]|0)|0;j=(c0(a,f,0)|0)+1|0;dc(a,7280,(l=i,i=i+24|0,c[l>>2]=7960,c[l+8>>2]=j,c[l+16>>2]=p,l)|0)|0;i=l;cH(a,f);o=6;i=d;return o|0}return 0}function g1(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;a=b;if((c[a>>2]|0)!=0){c[a>>2]=0;c[d>>2]=1;e=7520;return e|0}a=b+4|0;if((bQ(c[a>>2]|0)|0)!=0){e=0;return e|0}f=b+8|0;b=bw(f|0,1,1024,c[a>>2]|0)|0;c[d>>2]=b;e=(b|0)==0?0:f;return e|0}function g2(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0;f=i;i=i+8|0;g=f|0;c[g>>2]=b;c[g+4>>2]=d;d=dB(a,256,g,e)|0;i=f;return d|0}function g3(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;f=j_(b|0)|0;c[e>>2]=b;c[e+4>>2]=f;f=dB(a,256,e,b)|0;i=d;return f|0}function g4(){var a=0;a=fV(254,0)|0;if((a|0)==0){return a|0}cE(a,332)|0;return a|0}function g5(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0;if((d|0)==0){jV(b);e=0}else{e=jW(b,d)|0}return e|0}function g6(a){a=a|0;var b=0,d=0,e=0;b=i;d=c[n>>2]|0;e=c0(a,-1,0)|0;bN(d|0,7712|0,(d=i,i=i+8|0,c[d>>2]=e,d)|0)|0;i=d;i=b;return 0}function g7(a){a=a|0;cJ(a,-10002);dm(a,-10002,9248);gQ(a,9248,1864);c9(a,9120,7);dm(a,-10002,8968);dd(a,404,0);dd(a,502,1);dm(a,-2,8816);dd(a,264,0);dd(a,254,1);dm(a,-2,8616);di(a,0,1);cJ(a,-1);dq(a,-2)|0;c9(a,8432,2);dm(a,-2,8216);dd(a,352,1);dm(a,-10002,7944);gQ(a,6064,1808);return 2}function g8(a){a=a|0;var b=0,c=0;b=cO(a)|0;if((cK(a,1)|0)==6){if((cM(a,1)|0)!=0){c=1715}}else{c=1715}if((c|0)==1715){gy(a,1,9440)|0}cJ(a,1);cC(a,b,1);return 1}function g9(a){a=a|0;var b=0,c=0,d=0;b=c_(a,1)|0;if((b|0)==0){gy(a,1,9656)|0}c=hf(a,b,(cF(a)|0)-1|0)|0;if((c|0)<0){c6(a,0);cI(a,-2);d=2;return d|0}else{c6(a,1);cI(a,~c);d=c+1|0;return d|0}return 0}function ha(a){a=a|0;if((c8(a)|0)!=0){c3(a)}return 1}function hb(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;i=i+104|0;d=b|0;e=c_(a,1)|0;if((e|0)==0){gy(a,1,9656)|0}do{if((e|0)==(a|0)){f=0}else{g=dr(e)|0;if((g|0)==1){f=1;break}else if((g|0)!=0){f=3;break}if((ej(e,0,d)|0)>0){f=2;break}f=(cF(e)|0)==0?3:1}}while(0);da(a,c[312+(f<<2)>>2]|0);i=b;return 1}function hc(a){a=a|0;var b=0,c=0;b=cO(a)|0;if((cK(a,1)|0)==6){if((cM(a,1)|0)!=0){c=1738}}else{c=1738}if((c|0)==1738){gy(a,1,9440)|0}cJ(a,1);cC(a,b,1);dd(a,316,1);return 1}function hd(a){a=a|0;return eI(a,cF(a)|0)|0}function he(a){a=a|0;var b=0,c=0;b=c_(a,-10003)|0;c=hf(a,b,cF(a)|0)|0;if((c|0)>=0){return c|0}if((cQ(a,-1)|0)!=0){gB(a,1);cI(a,-2);dG(a,2)}dE(a)|0;return c|0}function hf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0;e=i;i=i+104|0;f=e|0;do{if((a|0)==(b|0)){g=0}else{h=dr(b)|0;if((h|0)==1){g=1;break}else if((h|0)!=0){g=3;break}if((ej(b,0,f)|0)>0){g=2;break}g=(cF(b)|0)==0?3:1}}while(0);if((cN(b,d)|0)==0){gz(a,2784,(j=i,i=i+1|0,i=i+7>>3<<3,c[j>>2]=0,j)|0)|0;i=j}if((g|0)!=1){f=c[312+(g<<2)>>2]|0;dc(a,2432,(j=i,i=i+8|0,c[j>>2]=f,j)|0)|0;i=j;k=-1;i=e;return k|0}cC(a,b,d);cD(a,b);if((eE(b,d)|0)>>>0>=2){cC(b,a,1);k=-1;i=e;return k|0}d=cF(b)|0;if((cN(a,d+1|0)|0)==0){gz(a,2200,(j=i,i=i+1|0,i=i+7>>3<<3,c[j>>2]=0,j)|0)|0;i=j}cC(b,a,d);k=d;i=e;return k|0}function hg(a){a=a|0;gI(a,1,5);cJ(a,-10003);cJ(a,1);c5(a,0);return 3}function hh(a){a=a|0;var b=0,c=0;b=gM(a,2)|0;gI(a,1,5);c=b+1|0;c5(a,c);dh(a,1,c);return((cK(a,-1)|0)==0?0:2)|0}function hi(a){a=a|0;gI(a,1,5);cJ(a,-10003);cJ(a,1);c3(a);return 3}function hj(a){a=a|0;var b=0;gI(a,1,5);cG(a,2);if((dF(a,1)|0)!=0){b=2;return b|0}c3(a);b=1;return b|0}function hk(a){a=a|0;var b=0,c=0;cG(a,1);dH(a,0)|0;if((cX(a,1)|0)==0){return 1}if((cK(a,1)|0)==1){di(a,0,0);cJ(a,-1);c6(a,1);dn(a,-10003)}else{if((dj(a,1)|0)==0){b=1779}else{dg(a,-10003);c=cX(a,-1)|0;cG(a,-2);if((c|0)==0){b=1779}}if((b|0)==1779){gy(a,1,7680)|0}dj(a,1)|0}dq(a,2)|0;return 1}function hl(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;gJ(a,1);if((cX(a,1)|0)==0){d=gD(a,2,2632,0)|0;e=gz(a,2664,(f=i,i=i+8|0,c[f>>2]=d,f)|0)|0;i=f;g=e;i=b;return g|0}else{g=cF(a)|0;i=b;return g|0}return 0}function hm(a){a=a|0;var b=0,d=0,e=0;b=gC(a,1,2896,1336)|0;d=gN(a,2,0)|0;e=c[1304+(b<<2)>>2]|0;b=dD(a,e,d)|0;if((e|0)==3){c4(a,+(b|0)+ +(dD(a,4,0)|0)*.0009765625);return 1}else if((e|0)==5){c6(a,b);return 1}else{c4(a,+(b|0));return 1}return 0}function hn(a){a=a|0;var b=0,c=0;b=gD(a,1,0,0)|0;c=cF(a)|0;if((g0(a,b)|0)!=0){dE(a)|0}dw(a,0,-1);return(cF(a)|0)-c|0}function ho(a){a=a|0;var b=0,c=0;b=gN(a,2,1)|0;cG(a,1);if(!((cQ(a,1)|0)!=0&(b|0)>0)){c=dE(a)|0;return c|0}gB(a,b);cJ(a,1);dG(a,2);c=dE(a)|0;return c|0}function hp(a){a=a|0;c5(a,dD(a,3,0)|0);return 1}function hq(a){a=a|0;hI(a,1);if((cM(a,-1)|0)==0){dk(a,-1);return 1}else{cJ(a,-10002);return 1}return 0}function hr(a){a=a|0;gJ(a,1);if((dj(a,1)|0)==0){c3(a);return 1}else{gO(a,1,3752)|0;return 1}return 0}function hs(a){a=a|0;var b=0;if((g0(a,gD(a,1,0,0)|0)|0)==0){b=1;return b|0}c3(a);cI(a,-2);b=2;return b|0}function ht(a){a=a|0;var b=0,c=0;b=gD(a,2,3024,0)|0;gI(a,1,6);cG(a,3);if((dB(a,252,0,b)|0)==0){c=1;return c|0}c3(a);cI(a,-2);c=2;return c|0}function hu(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;i=i+8|0;d=b|0;e=gE(a,1,d)|0;f=gD(a,2,e,0)|0;if((g2(a,e,c[d>>2]|0,f)|0)==0){g=1;i=b;return g|0}c3(a);cI(a,-2);g=2;i=b;return g|0}function hv(a){a=a|0;gJ(a,1);c6(a,(dx(a,(cF(a)|0)-1|0,-1,0)|0)==0|0);cI(a,1);return cF(a)|0}function hw(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=cF(a)|0;df(a,-10002,4536);L2389:do{if((d|0)>=1){e=1;while(1){cJ(a,-1);cJ(a,e);dw(a,1,1);f=c0(a,-1,0)|0;if((f|0)==0){break}if((e|0)>1){g=c[o>>2]|0;av(9,g|0)|0}az(f|0,c[o>>2]|0)|0;cG(a,-2);e=e+1|0;if((e|0)>(d|0)){break L2389}}e=gz(a,3232,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;h=e;i=b;return h|0}}while(0);av(10,c[o>>2]|0)|0;h=0;i=b;return h|0}function hx(a){a=a|0;gJ(a,1);gJ(a,2);c6(a,cT(a,1,2)|0);return 1}function hy(a){a=a|0;gI(a,1,5);gJ(a,2);cG(a,2);dg(a,1);return 1}function hz(a){a=a|0;gI(a,1,5);gJ(a,2);gJ(a,3);cG(a,3);dn(a,1);return 1}function hA(b){b=b|0;var c=0,d=0,e=0,f=0;c=cF(b)|0;do{if((cK(b,1)|0)==4){if((a[c0(b,1,0)|0]|0)!=35){break}c5(b,c-1|0);d=1;return d|0}}while(0);e=gM(b,1)|0;if((e|0)<0){f=e+c|0}else{f=(e|0)>(c|0)?c:e}if((f|0)<=0){gy(b,1,3296)|0}d=c-f|0;return d|0}function hB(a){a=a|0;var b=0,d=0;b=i;gI(a,2,5);hI(a,0);cJ(a,2);do{if((cS(a,1)|0)!=0){if(+cW(a,1)!=0.0){break}c8(a)|0;cI(a,-2);dv(a,-2)|0;d=0;i=b;return d|0}}while(0);do{if((cM(a,-2)|0)==0){if((dv(a,-2)|0)==0){break}else{d=1}i=b;return d|0}}while(0);gz(a,3640,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0)|0;i=a;d=1;i=b;return d|0}function hC(a){a=a|0;var b=0,d=0,e=0;b=i;d=cK(a,2)|0;gI(a,1,5);if(!((d|0)==5|(d|0)==0)){gy(a,2,3816)|0}if((gO(a,1,3752)|0)==0){cG(a,2);e=dq(a,1)|0;i=b;return 1}gz(a,3696,(d=i,i=i+1|0,i=i+7>>3<<3,c[d>>2]=0,d)|0)|0;i=d;cG(a,2);e=dq(a,1)|0;i=b;return 1}function hD(b){b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;i=i+8|0;f=e|0;g=gN(b,2,10)|0;do{if((g|0)==10){gJ(b,1);if((cS(b,1)|0)==0){break}c4(b,+cW(b,1));i=e;return 1}else{h=gE(b,1,0)|0;if((g-2|0)>>>0>=35){gy(b,2,3856)|0}j=as(h|0,f|0,g|0)|0;k=c[f>>2]|0;if((h|0)==(k|0)){break}if((aB(d[k]|0)|0)==0){l=k}else{h=k;do{h=h+1|0;}while((aB(d[h]|0)|0)!=0);c[f>>2]=h;l=h}if((a[l]|0)!=0){break}c4(b,+(j>>>0>>>0));i=e;return 1}}while(0);c3(b);i=e;return 1}function hE(a){a=a|0;var b=0,d=0,e=0,f=0;b=i;gJ(a,1);do{if((gP(a,1,4160)|0)==0){d=cK(a,1)|0;if((d|0)==1){da(a,(cX(a,1)|0)!=0?4096:4056);break}else if((d|0)==4){cJ(a,1);break}else if((d|0)==3){da(a,c0(a,1,0)|0);break}else if((d|0)==0){c9(a,4016,3);break}else{d=cL(a,cK(a,1)|0)|0;e=c2(a,1)|0;dc(a,3944,(f=i,i=i+16|0,c[f>>2]=d,c[f+8>>2]=e,f)|0)|0;i=f;break}}}while(0);i=b;return 1}function hF(a){a=a|0;gJ(a,1);da(a,cL(a,cK(a,1)|0)|0);return 1}function hG(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;b=i;gI(a,1,5);d=gN(a,2,1)|0;if((cK(a,3)|0)<1){e=c1(a,1)|0}else{e=gM(a,3)|0}if((d|0)>(e|0)){f=0;i=b;return f|0}g=e-d|0;h=g+1|0;do{if((g|0)>=0){if((cN(a,h)|0)==0){break}dh(a,1,d);if((d|0)<(e|0)){j=d}else{f=h;i=b;return f|0}while(1){k=j+1|0;dh(a,1,k);if((k|0)<(e|0)){j=k}else{f=h;break}}i=b;return f|0}}while(0);h=gz(a,4192,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0)|0;i=a;f=h;i=b;return f|0}function hH(a){a=a|0;gJ(a,2);cG(a,2);cI(a,1);c6(a,(dx(a,0,-1,1)|0)==0|0);cP(a,1);return cF(a)|0}function hI(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;i=i+104|0;e=d|0;if((cK(a,1)|0)==6){cJ(a,1);i=d;return}if((b|0)==0){f=gM(a,1)|0}else{f=gN(a,1,1)|0}if((f|0)<=-1){gy(a,1,3608)|0}if((ej(a,f,e)|0)==0){gy(a,1,3560)|0}en(a,3552,e)|0;if((cK(a,-1)|0)!=0){i=d;return}gz(a,3448,(a=i,i=i+8|0,c[a>>2]=f,a)|0)|0;i=a;i=d;return}function hJ(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;b=i;gH(a,2,2992);cJ(a,1);dw(a,0,1);if((cK(a,-1)|0)==0){c[d>>2]=0;e=0;i=b;return e|0}if((cQ(a,-1)|0)==0){gz(a,2952,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;e=0;i=b;return e|0}else{cP(a,3);e=c0(a,3,d)|0;i=b;return e|0}return 0}function hK(a){a=a|0;gQ(a,5440,1688);return 1}function hL(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;i=i+256|0;aw(4080,11,1,c[n>>2]|0)|0;d=b|0;if((aS(d|0,250,c[m>>2]|0)|0)==0){i=b;return 0}while(1){if((aL(d|0,4040)|0)==0){e=1950;break}if((g2(a,d,j_(d|0)|0,3984)|0)==0){if((dx(a,0,0,0)|0)!=0){e=1948}}else{e=1948}if((e|0)==1948){e=0;f=c0(a,-1,0)|0;g=c[n>>2]|0;az(f|0,g|0)|0;g=c[n>>2]|0;av(10,g|0)|0}cG(a,0);aw(4080,11,1,c[n>>2]|0)|0;if((aS(d|0,250,c[m>>2]|0)|0)==0){e=1951;break}}if((e|0)==1951){i=b;return 0}else if((e|0)==1950){i=b;return 0}return 0}function hM(a){a=a|0;gJ(a,1);dk(a,1);return 1}function hN(b){b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;c=i;i=i+8|0;d=c|0;if((cK(b,1)|0)==8){e=c_(b,1)|0}else{e=b}f=eh(e)|0;g=eg(e)|0;if((g|0)!=0&(g|0)!=262){c9(b,4144,13)}else{h$(b);c7(b,e);dg(b,-2);cH(b,-2)}g=d|0;if((f&1|0)==0){h=0}else{a[g]=99;h=1}if((f&2|0)==0){j=h}else{a[d+h|0]=114;j=h+1|0}if((f&4|0)==0){k=j;l=d+k|0;a[l]=0;da(b,g);m=ei(e)|0;c5(b,m);i=c;return 3}a[d+j|0]=108;k=j+1|0;l=d+k|0;a[l]=0;da(b,g);m=ei(e)|0;c5(b,m);i=c;return 3}function hO(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0;b=i;i=i+104|0;d=b|0;if((cK(a,1)|0)==8){e=c_(a,1)|0;f=1}else{e=a;f=0}g=f|2;h=gD(a,g,5744,0)|0;j=f+1|0;do{if((cS(a,j)|0)==0){if((cK(a,j)|0)==6){dc(a,5648,(f=i,i=i+8|0,c[f>>2]=h,f)|0)|0;i=f;f=c0(a,-1,0)|0;cJ(a,j);cC(a,e,1);k=f;break}l=gy(a,j,5560)|0;i=b;return l|0}else{if((ej(e,c$(a,j)|0,d)|0)!=0){k=h;break}c3(a);l=1;i=b;return l|0}}while(0);if((en(e,k,d)|0)==0){l=gy(a,g,5424)|0;i=b;return l|0}di(a,0,2);if((aU(k|0,83)|0)!=0){da(a,c[d+16>>2]|0);dm(a,-2,5320);da(a,d+36|0);dm(a,-2,5208);c5(a,c[d+28>>2]|0);dm(a,-2,5072);c5(a,c[d+32>>2]|0);dm(a,-2,4920);da(a,c[d+12>>2]|0);dm(a,-2,4816)}if((aU(k|0,108)|0)!=0){c5(a,c[d+20>>2]|0);dm(a,-2,4616)}if((aU(k|0,117)|0)!=0){c5(a,c[d+24>>2]|0);dm(a,-2,4528)}if((aU(k|0,110)|0)!=0){da(a,c[d+4>>2]|0);dm(a,-2,4448);da(a,c[d+8>>2]|0);dm(a,-2,4320)}if((aU(k|0,76)|0)!=0){if((e|0)==(a|0)){cJ(a,-2);cH(a,-3)}else{cC(e,a,1)}dm(a,-2,4232)}if((aU(k|0,102)|0)==0){l=1;i=b;return l|0}if((e|0)==(a|0)){cJ(a,-2);cH(a,-3)}else{cC(e,a,1)}dm(a,-2,4184);l=1;i=b;return l|0}function hP(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;b=i;i=i+104|0;c=b|0;if((cK(a,1)|0)==8){d=c_(a,1)|0;e=1}else{d=a;e=0}f=e+1|0;if((ej(d,gM(a,f)|0,c)|0)==0){g=gy(a,f,6880)|0;i=b;return g|0}f=el(d,c,gM(a,e|2)|0)|0;if((f|0)==0){c3(a);g=1;i=b;return g|0}else{cC(d,a,1);da(a,f);cJ(a,-2);g=2;i=b;return g|0}return 0}function hQ(a){a=a|0;cJ(a,-1e4);return 1}function hR(a){a=a|0;gJ(a,1);if((dj(a,1)|0)!=0){return 1}c3(a);return 1}function hS(a){a=a|0;return hZ(a,1)|0}function hT(a){a=a|0;var b=0;b=i;gI(a,2,5);cG(a,2);if((dv(a,1)|0)!=0){i=b;return 1}gz(a,5848,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0)|0;i=a;i=b;return 1}function hU(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;if((cK(a,1)|0)==8){b=c_(a,1)|0;c=1}else{b=a;c=0}d=c+1|0;if((cK(a,d)|0)<1){cG(a,d);e=0;f=0;g=0}else{h=gE(a,c|2,0)|0;gI(a,d,6);i=gN(a,c+3|0,0)|0;c=(aU(h|0,99)|0)!=0|0;j=(aU(h|0,114)|0)==0?c:c|2;c=(aU(h|0,108)|0)==0?j:j|4;e=(i|0)>0?c|8:c;f=i;g=262}h$(a);c7(a,b);cJ(a,d);dn(a,-3);cG(a,-2);ef(b,g,e,f)|0;return 0}function hV(a){a=a|0;var b=0,c=0,d=0,e=0,f=0,g=0;b=i;i=i+104|0;c=b|0;if((cK(a,1)|0)==8){d=c_(a,1)|0;e=1}else{d=a;e=0}f=e+1|0;if((ej(d,gM(a,f)|0,c)|0)==0){g=gy(a,f,6880)|0;i=b;return g|0}else{f=e+3|0;gJ(a,f);cG(a,f);cC(a,d,1);da(a,em(d,c,gM(a,e|2)|0)|0);g=1;i=b;return g|0}return 0}function hW(a){a=a|0;var b=0;b=cK(a,2)|0;if(!((b|0)==5|(b|0)==0)){gy(a,2,7072)|0}cG(a,2);c6(a,dq(a,1)|0);return 1}function hX(a){a=a|0;gJ(a,3);return hZ(a,0)|0}function hY(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=i;i=i+104|0;e=d|0;if((cK(b,1)|0)==8){f=c_(b,1)|0;g=1}else{f=b;g=0}h=g|2;if((cS(b,h)|0)==0){j=(f|0)==(b|0)|0}else{k=c$(b,h)|0;cG(b,-2);j=k}do{if((cF(b)|0)==(g|0)){c9(b,10568,0)}else{if((cQ(b,g+1|0)|0)==0){i=d;return 1}else{c9(b,9240,1);break}}}while(0);c9(b,9096,16);k=e+36|0;h=e+20|0;l=e+8|0;m=e+12|0;n=e+28|0;o=e+4|0;p=1;q=j;L2655:while(1){j=q+1|0;r=q+11|0;L2657:do{if((j|0)<13){if((ej(f,q,e)|0)==0){break L2655}else{s=p}}else{t=p;while(1){if((ej(f,q,e)|0)==0){break L2655}if((t|0)==0){s=0;break L2657}if((ej(f,r,e)|0)==0){t=0}else{break}}c9(b,8960,5);t=j;while(1){if((ej(f,t+10|0,e)|0)==0){p=0;q=t;continue L2655}else{t=t+1|0}}}}while(0);c9(b,8808,2);en(f,8608,e)|0;dc(b,8424,(r=i,i=i+8|0,c[r>>2]=k,r)|0)|0;i=r;t=c[h>>2]|0;if((t|0)>0){dc(b,8208,(r=i,i=i+8|0,c[r>>2]=t,r)|0)|0;i=r}do{if((a[c[l>>2]|0]|0)==0){t=a[c[m>>2]|0]|0;if((t<<24>>24|0)==109){dc(b,7664,(r=i,i=i+1|0,i=i+7>>3<<3,c[r>>2]=0,r)|0)|0;i=r;break}else if((t<<24>>24|0)==67|(t<<24>>24|0)==116){c9(b,7504,2);break}else{t=c[n>>2]|0;dc(b,7240,(r=i,i=i+16|0,c[r>>2]=k,c[r+8>>2]=t,r)|0)|0;i=r;break}}else{t=c[o>>2]|0;dc(b,7920,(r=i,i=i+8|0,c[r>>2]=t,r)|0)|0;i=r}}while(0);dG(b,(cF(b)|0)-g|0);p=s;q=j}dG(b,(cF(b)|0)-g|0);i=d;return 1}function hZ(a,b){a=a|0;b=b|0;var c=0,d=0,e=0;c=gM(a,2)|0;gI(a,1,6);if((cM(a,1)|0)!=0){d=0;return d|0}if((b|0)==0){e=dJ(a,1,c)|0}else{e=du(a,1,c)|0}if((e|0)==0){d=0;return d|0}da(a,e);cI(a,~b);d=b+1|0;return d|0}function h_(a,b){a=a|0;b=b|0;var d=0;c7(a,10472);dg(a,-1e4);c7(a,a);dg(a,-2);if((cK(a,-1)|0)!=6){return}da(a,c[1488+(c[b>>2]<<2)>>2]|0);d=c[b+20>>2]|0;if((d|0)>-1){c5(a,d)}else{c3(a)}dw(a,2,0);return}function h$(a){a=a|0;c7(a,10472);dg(a,-1e4);if((cK(a,-1)|0)==5){return}cG(a,-2);di(a,0,1);c7(a,10472);cJ(a,-2);dn(a,-1e4);return}function h0(a){a=a|0;var b=0,d=0;gF(a,3848)|0;cJ(a,-1);dm(a,-2,5840);gQ(a,0,1512);di(a,0,1);dd(a,550,0);dm(a,-2,6128);cP(a,-10001);gQ(a,4712,1392);di(a,0,1);dd(a,402,0);dm(a,-2,6128);b=c[m>>2]|0;d=dH(a,4)|0;c[d>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;c[d>>2]=b;cJ(a,-1);dp(a,-10001,1);cJ(a,-2);dv(a,-2)|0;dm(a,-3,9496);b=c[o>>2]|0;d=dH(a,4)|0;c[d>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;c[d>>2]=b;cJ(a,-1);dp(a,-10001,2);cJ(a,-2);dv(a,-2)|0;dm(a,-3,7528);b=c[n>>2]|0;d=dH(a,4)|0;c[d>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;c[d>>2]=b;cJ(a,-2);dv(a,-2)|0;dm(a,-3,5760);cG(a,-2);df(a,-1,4552);di(a,0,1);dd(a,538,0);dm(a,-2,6128);dv(a,-2)|0;cG(a,-2);return 1}function h1(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=gG(a,1,3848)|0;e=(ar(c[d>>2]|0)|0)==0;c[d>>2]=0;d=c[(bE()|0)>>2]|0;if(e){c6(a,1);f=1;i=b;return f|0}else{c3(a);e=bF(d|0)|0;dc(a,2752,(g=i,i=i+8|0,c[g>>2]=e,g)|0)|0;i=g;c5(a,d);f=3;i=b;return f|0}return 0}function h2(a){a=a|0;c3(a);c9(a,2392,26);return 2}function h3(a){a=a|0;var b=0,d=0,e=0,f=0;b=i;c[(gG(a,1,3848)|0)>>2]=0;d=c[(bE()|0)>>2]|0;c3(a);e=bF(d|0)|0;dc(a,2752,(f=i,i=i+8|0,c[f>>2]=e,f)|0)|0;i=f;c5(a,d);i=b;return 3}function h4(a){a=a|0;var b=0,d=0;b=i;if((cK(a,1)|0)==-1){dh(a,-10001,2)}if((c[(gG(a,1,3848)|0)>>2]|0)==0){gz(a,6504,(d=i,i=i+1|0,i=i+7>>3<<3,c[d>>2]=0,d)|0)|0;i=d}dk(a,1);df(a,-1,6128);d=cd[(cY(a,-1)|0)&1023](a)|0;i=b;return d|0}function h5(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;dh(a,-10001,2);d=c[(cZ(a,-1)|0)>>2]|0;if((d|0)==0){gz(a,8576,(e=i,i=i+8|0,c[e>>2]=9432,e)|0)|0;i=e}f=(au(d|0)|0)==0;d=c[(bE()|0)>>2]|0;if(f){c6(a,1);g=1;i=b;return g|0}else{c3(a);f=bF(d|0)|0;dc(a,2752,(e=i,i=i+8|0,c[e>>2]=f,e)|0)|0;i=e;c5(a,d);g=3;i=b;return g|0}return 0}function h6(a){a=a|0;ik(a,1,6872);return 1}function h7(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;if((cK(a,1)|0)<1){dh(a,-10001,1);if((c[(gG(a,1,3848)|0)>>2]|0)==0){gz(a,6504,(d=i,i=i+1|0,i=i+7>>3<<3,c[d>>2]=0,d)|0)|0;i=d}cJ(a,1);c6(a,0);dd(a,396,2);i=b;return 1}else{e=gE(a,1,0)|0;f=dH(a,4)|0;c[f>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;g=bl(e|0,6872)|0;c[f>>2]=g;if((g|0)==0){g=bF(c[(bE()|0)>>2]|0)|0;dc(a,3224,(d=i,i=i+16|0,c[d>>2]=e,c[d+8>>2]=g,d)|0)|0;i=d;d=c0(a,-1,0)|0;gy(a,1,d)|0}cJ(a,cF(a)|0);c6(a,1);dd(a,396,2);i=b;return 1}return 0}function h8(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0;b=i;d=gE(a,1,0)|0;e=gD(a,2,6872,0)|0;f=dH(a,4)|0;c[f>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;g=bl(d|0,e|0)|0;c[f>>2]=g;if((g|0)!=0){h=1;i=b;return h|0}g=c[(bE()|0)>>2]|0;c3(a);f=bF(g|0)|0;if((d|0)==0){dc(a,2752,(j=i,i=i+8|0,c[j>>2]=f,j)|0)|0;i=j}else{dc(a,3224,(j=i,i=i+16|0,c[j>>2]=d,c[j+8>>2]=f,j)|0)|0;i=j}c5(a,g);h=3;i=b;return h|0}function h9(a){a=a|0;ik(a,2,6664);return 1}function ia(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=gE(a,1,0)|0;gD(a,2,6872,0)|0;e=dH(a,4)|0;c[e>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;gz(a,6768,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;c[e>>2]=0;e=c[(bE()|0)>>2]|0;c3(a);g=bF(e|0)|0;if((d|0)==0){dc(a,2752,(f=i,i=i+8|0,c[f>>2]=g,f)|0)|0;i=f;c5(a,e);i=b;return 3}else{dc(a,3224,(f=i,i=i+16|0,c[f>>2]=d,c[f+8>>2]=g,f)|0)|0;i=f;c5(a,e);i=b;return 3}return 0}function ib(a){a=a|0;var b=0,d=0,e=0,f=0;b=i;dh(a,-10001,1);d=c[(cZ(a,-1)|0)>>2]|0;if((d|0)!=0){e=ih(a,d,1)|0;i=b;return e|0}gz(a,8576,(f=i,i=i+8|0,c[f>>2]=10144,f)|0)|0;i=f;e=ih(a,d,1)|0;i=b;return e|0}function ic(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=dH(a,4)|0;c[d>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;e=aO()|0;c[d>>2]=e;if((e|0)!=0){f=1;i=b;return f|0}e=c[(bE()|0)>>2]|0;c3(a);d=bF(e|0)|0;dc(a,2752,(g=i,i=i+8|0,c[g>>2]=d,g)|0)|0;i=g;c5(a,e);f=3;i=b;return f|0}function id(a){a=a|0;var b=0;gJ(a,1);b=cZ(a,1)|0;df(a,-1e4,3848);do{if((b|0)!=0){if((dj(a,1)|0)==0){break}if((cT(a,-2,-1)|0)==0){break}if((c[b>>2]|0)==0){c9(a,8192,11);return 1}else{c9(a,7912,4);return 1}}}while(0);c3(a);return 1}function ie(a){a=a|0;var b=0,d=0,e=0,f=0;b=i;dh(a,-10001,2);d=c[(cZ(a,-1)|0)>>2]|0;if((d|0)!=0){e=ig(a,d,1)|0;i=b;return e|0}gz(a,8576,(f=i,i=i+8|0,c[f>>2]=9432,f)|0)|0;i=f;e=ig(a,d,1)|0;i=b;return e|0}function ig(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0,q=0,r=0;e=i;i=i+8|0;f=e|0;g=(cF(a)|0)-1|0;do{if((g|0)==0){bE()|0}else{j=1;k=d;l=g;while(1){do{if((cK(a,k)|0)==3){if((j|0)==0){m=0;break}n=+cW(a,k);o=bN(b|0,8416,(p=i,i=i+8|0,h[p>>3]=n,p)|0)|0;i=p;m=(o|0)>0|0}else{o=gE(a,k,f)|0;if((j|0)==0){m=0;break}q=aw(o|0,1,c[f>>2]|0,b|0)|0;m=(q|0)==(c[f>>2]|0)|0}}while(0);q=l-1|0;if((q|0)==0){break}else{j=m;k=k+1|0;l=q}}l=c[(bE()|0)>>2]|0;if((m|0)!=0){break}c3(a);k=bF(l|0)|0;dc(a,2752,(p=i,i=i+8|0,c[p>>2]=k,p)|0)|0;i=p;c5(a,l);r=3;i=e;return r|0}}while(0);c6(a,1);r=1;i=e;return r|0}function ih(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;f=i;i=i+8|0;g=f|0;j=cF(b)|0;bV(d|0);L2804:do{if((j|0)==1){k=e+1|0;l=ii(b,d)|0}else{gH(b,j+19|0,7640);m=e;n=j-2|0;L2806:while(1){do{if((cK(b,m)|0)==3){o=c$(b,m)|0;if((o|0)==0){p=aQ(d|0)|0;bI(p|0,d|0)|0;c9(b,0,0);q=(p|0)!=-1|0;break}else{q=ij(b,d,o)|0;break}}else{o=c0(b,m,0)|0;if((o|0)==0){r=2193}else{if((a[o]|0)!=42){r=2193}}if((r|0)==2193){r=0;gy(b,m,7488)|0}p=a[o+1|0]|0;if((p|0)==108){q=ii(b,d)|0;break}else if((p|0)==97){ij(b,d,-1)|0;q=1;break}else if((p|0)==110){p=aH(d|0,7056,(s=i,i=i+8|0,c[s>>2]=g,s)|0)|0;i=s;if((p|0)!=1){r=2197;break L2806}c4(b,+h[g>>3]);q=1;break}else{break L2806}}}while(0);p=m+1|0;if((n|0)==0|(q|0)==0){k=p;l=q;break L2804}else{m=p;n=n-1|0}}if((r|0)==2197){c3(b);k=m+1|0;l=0;break}t=gy(b,m,7216)|0;i=f;return t|0}}while(0);if((a4(d|0)|0)!=0){d=c[(bE()|0)>>2]|0;c3(b);r=bF(d|0)|0;dc(b,2752,(s=i,i=i+8|0,c[s>>2]=r,s)|0)|0;i=s;c5(b,d);t=3;i=f;return t|0}if((l|0)==0){cG(b,-2);c3(b)}t=k-e|0;i=f;return t|0}function ii(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;e=i;i=i+1040|0;f=e|0;gt(b,f);g=gY(f)|0;L2840:do{if((aS(g|0,1024,d|0)|0)!=0){h=f|0;j=g;while(1){k=j_(j|0)|0;if((k|0)!=0){l=k-1|0;if((a[j+l|0]|0)==10){break}}c[h>>2]=(c[h>>2]|0)+k;j=gY(f)|0;if((aS(j|0,1024,d|0)|0)==0){break L2840}}c[h>>2]=(c[h>>2]|0)+l;gX(f);m=1;i=e;return m|0}}while(0);gX(f);m=(c1(b,-1)|0)!=0|0;i=e;return m|0}function ij(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;e=i;i=i+1040|0;f=e|0;gt(a,f);g=f|0;h=d;d=1024;while(1){j=d>>>0>h>>>0?h:d;k=bw(gY(f)|0,1,j|0,b|0)|0;c[g>>2]=(c[g>>2]|0)+k;if((h|0)==(k|0)){l=2223;break}if((k|0)==(j|0)){h=h-k|0;d=j}else{l=2225;break}}if((l|0)==2225){gX(f);m=(c1(a,-1)|0)!=0|0;i=e;return m|0}else if((l|0)==2223){gX(f);m=1;i=e;return m|0}return 0}function ik(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;e=i;if((cK(a,1)|0)<1){dh(a,-10001,b);i=e;return}f=c0(a,1,0)|0;do{if((f|0)==0){if((c[(gG(a,1,3848)|0)>>2]|0)==0){gz(a,6504,(g=i,i=i+1|0,i=i+7>>3<<3,c[g>>2]=0,g)|0)|0;i=g}cJ(a,1)}else{h=dH(a,4)|0;c[h>>2]=0;df(a,-1e4,3848);dq(a,-2)|0;j=bl(f|0,d|0)|0;c[h>>2]=j;if((j|0)!=0){break}j=bF(c[(bE()|0)>>2]|0)|0;dc(a,3224,(g=i,i=i+16|0,c[g>>2]=f,c[g+8>>2]=j,g)|0)|0;i=g;j=c0(a,-1,0)|0;gy(a,1,j)|0}}while(0);dp(a,-10001,b);dh(a,-10001,b);i=e;return}function il(a){a=a|0;var b=0,d=0;b=i;if((c[(gG(a,1,3848)|0)>>2]|0)==0){gz(a,6504,(d=i,i=i+1|0,i=i+7>>3<<3,c[d>>2]=0,d)|0)|0;i=d}cJ(a,1);c6(a,0);dd(a,396,2);i=b;return 1}function im(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=c[(cZ(a,-10003)|0)>>2]|0;if((d|0)==0){gz(a,6344,(e=i,i=i+1|0,i=i+7>>3<<3,c[e>>2]=0,e)|0)|0;i=e}f=ii(a,d)|0;if((a4(d|0)|0)!=0){d=bF(c[(bE()|0)>>2]|0)|0;g=gz(a,2752,(e=i,i=i+8|0,c[e>>2]=d,e)|0)|0;i=e;h=g;i=b;return h|0}if((f|0)!=0){h=1;i=b;return h|0}if((cX(a,-10004)|0)==0){h=0;i=b;return h|0}cG(a,0);cJ(a,-10003);dk(a,1);df(a,-1,6128);cd[(cY(a,-1)|0)&1023](a)|0;h=0;i=b;return h|0}function io(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=gG(a,1,3848)|0;e=c[d>>2]|0;if((e|0)==0){gz(a,6504,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;g=c[d>>2]|0}else{g=e}e=(au(g|0)|0)==0;g=c[(bE()|0)>>2]|0;if(e){c6(a,1);h=1;i=b;return h|0}else{c3(a);e=bF(g|0)|0;dc(a,2752,(f=i,i=i+8|0,c[f>>2]=e,f)|0)|0;i=f;c5(a,g);h=3;i=b;return h|0}return 0}function ip(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=gG(a,1,3848)|0;e=c[d>>2]|0;if((e|0)!=0){f=e;g=ih(a,f,2)|0;i=b;return g|0}gz(a,6504,(e=i,i=i+1|0,i=i+7>>3<<3,c[e>>2]=0,e)|0)|0;i=e;f=c[d>>2]|0;g=ih(a,f,2)|0;i=b;return g|0}function iq(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=gG(a,1,3848)|0;e=c[d>>2]|0;if((e|0)==0){gz(a,6504,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;g=c[d>>2]|0}else{g=e}e=gC(a,2,4520,1624)|0;d=gN(a,3,0)|0;if((bY(g|0,d|0,c[1640+(e<<2)>>2]|0)|0)==0){c5(a,aZ(g|0)|0);h=1;i=b;return h|0}else{g=c[(bE()|0)>>2]|0;c3(a);e=bF(g|0)|0;dc(a,2752,(f=i,i=i+8|0,c[f>>2]=e,f)|0)|0;i=f;c5(a,g);h=3;i=b;return h|0}return 0}function ir(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0;b=i;d=gG(a,1,3848)|0;e=c[d>>2]|0;if((e|0)==0){gz(a,6504,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;g=c[d>>2]|0}else{g=e}e=gC(a,2,0,1592)|0;d=gN(a,3,1024)|0;h=(cc(g|0,0,c[1608+(e<<2)>>2]|0,d|0)|0)==0;d=c[(bE()|0)>>2]|0;if(h){c6(a,1);j=1;i=b;return j|0}else{c3(a);h=bF(d|0)|0;dc(a,2752,(f=i,i=i+8|0,c[f>>2]=h,f)|0)|0;i=f;c5(a,d);j=3;i=b;return j|0}return 0}function is(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=gG(a,1,3848)|0;e=c[d>>2]|0;if((e|0)!=0){f=e;g=ig(a,f,2)|0;i=b;return g|0}gz(a,6504,(e=i,i=i+1|0,i=i+7>>3<<3,c[e>>2]=0,e)|0)|0;i=e;f=c[d>>2]|0;g=ig(a,f,2)|0;i=b;return g|0}function it(a){a=a|0;if((c[(gG(a,1,3848)|0)>>2]|0)==0){return 0}dk(a,1);df(a,-1,6128);cd[(cY(a,-1)|0)&1023](a)|0;return 0}function iu(a){a=a|0;var b=0,d=0;b=i;d=c[(gG(a,1,3848)|0)>>2]|0;if((d|0)==0){c9(a,5304,13);i=b;return 1}else{dc(a,5192,(a=i,i=i+8|0,c[a>>2]=d,a)|0)|0;i=a;i=b;return 1}return 0}function iv(a){a=a|0;gQ(a,4248,512);c4(a,3.141592653589793);dm(a,-2,9336);c4(a,+q);dm(a,-2,7384);df(a,-1,5712);dm(a,-2,4512);return 1}function iw(a){a=a|0;c4(a,+P(+(+gK(a,1))));return 1}function ix(a){a=a|0;c4(a,+V(+(+gK(a,1))));return 1}function iy(a){a=a|0;c4(a,+W(+(+gK(a,1))));return 1}function iz(a){a=a|0;var b=0.0;b=+gK(a,1);c4(a,+Y(+b,+(+gK(a,2))));return 1}function iA(a){a=a|0;c4(a,+X(+(+gK(a,1))));return 1}function iB(a){a=a|0;c4(a,+$(+(+gK(a,1))));return 1}function iC(a){a=a|0;c4(a,+aR(+(+gK(a,1))));return 1}function iD(a){a=a|0;c4(a,+S(+(+gK(a,1))));return 1}function iE(a){a=a|0;c4(a,+gK(a,1)/.017453292519943295);return 1}function iF(a){a=a|0;c4(a,+Z(+(+gK(a,1))));return 1}function iG(a){a=a|0;c4(a,+O(+(+gK(a,1))));return 1}function iH(a){a=a|0;var b=0.0;b=+gK(a,1);c4(a,+aI(+b,+(+gK(a,2))));return 1}function iI(a){a=a|0;var b=0,d=0;b=i;i=i+8|0;d=b|0;c4(a,+bn(+(+gK(a,1)),d|0));c5(a,c[d>>2]|0);i=b;return 2}function iJ(a){a=a|0;var b=0.0;b=+gK(a,1);c4(a,+bi(+b,gM(a,2)|0));return 1}function iK(a){a=a|0;c4(a,+bv(+(+gK(a,1))));return 1}function iL(a){a=a|0;c4(a,+_(+(+gK(a,1))));return 1}function iM(a){a=a|0;var b=0,c=0.0,d=0.0,e=0,f=0.0,g=0.0,h=0;b=cF(a)|0;c=+gK(a,1);if((b|0)<2){d=c}else{e=2;f=c;while(1){c=+gK(a,e);g=c>f?c:f;h=e+1|0;if((h|0)>(b|0)){d=g;break}else{e=h;f=g}}}c4(a,d);return 1}function iN(a){a=a|0;var b=0,c=0.0,d=0.0,e=0,f=0.0,g=0.0,h=0;b=cF(a)|0;c=+gK(a,1);if((b|0)<2){d=c}else{e=2;f=c;while(1){c=+gK(a,e);g=c<f?c:f;h=e+1|0;if((h|0)>(b|0)){d=g;break}else{e=h;f=g}}}c4(a,d);return 1}function iO(a){a=a|0;var b=0,c=0,d=0.0;b=i;i=i+8|0;c=b|0;d=+aK(+(+gK(a,1)),c|0);c4(a,+h[c>>3]);c4(a,d);i=b;return 2}function iP(a){a=a|0;var b=0.0;b=+gK(a,1);c4(a,+R(+b,+(+gK(a,2))));return 1}function iQ(a){a=a|0;c4(a,+gK(a,1)*.017453292519943295);return 1}function iR(a){a=a|0;var b=0,d=0.0,e=0,f=0,g=0,h=0;b=i;d=+((bf()|0)%2147483647|0|0)/2147483647.0;e=cF(a)|0;if((e|0)==1){f=gM(a,1)|0;if((f|0)<=0){gy(a,1,6104)|0}c4(a,+O(+(d*+(f|0)))+1.0);g=1;i=b;return g|0}else if((e|0)==2){f=gM(a,1)|0;h=gM(a,2)|0;if((f|0)>(h|0)){gy(a,2,6104)|0}c4(a,+(f|0)+ +O(+(d*+(1-f+h|0))));g=1;i=b;return g|0}else if((e|0)==0){c4(a,d);g=1;i=b;return g|0}else{e=gz(a,5808,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0)|0;i=a;g=e;i=b;return g|0}return 0}function iS(a){a=a|0;bL(gM(a,1)|0);return 0}function iT(a){a=a|0;c4(a,+a7(+(+gK(a,1))));return 1}function iU(a){a=a|0;c4(a,+T(+(+gK(a,1))));return 1}function iV(a){a=a|0;c4(a,+Q(+(+gK(a,1))));return 1}function iW(a){a=a|0;c4(a,+bC(+(+gK(a,1))));return 1}function iX(a){a=a|0;c4(a,+U(+(+gK(a,1))));return 1}function iY(a){a=a|0;gQ(a,4064,88);return 1}function iZ(a){a=a|0;c4(a,+((aW()|0)>>>0>>>0)/1.0e3);return 1}function i_(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;d=i;i=i+1256|0;e=d|0;f=d+8|0;g=d+16|0;h=d+1056|0;j=gD(b,1,6856,0)|0;if((cK(b,2)|0)<1){k=cb(0)|0}else{k=~~+gK(b,2)}c[e>>2]=k;if((a[j]|0)==33){l=j+1|0;m=a5(e|0)|0}else{l=j;m=aC(e|0)|0}if((m|0)==0){c3(b);i=d;return 1}if((aL(l|0,6752)|0)==0){di(b,0,9);c5(b,c[m>>2]|0);dm(b,-2,9616);c5(b,c[m+4>>2]|0);dm(b,-2,9416);c5(b,c[m+8>>2]|0);dm(b,-2,9192);c5(b,c[m+12>>2]|0);dm(b,-2,9056);c5(b,(c[m+16>>2]|0)+1|0);dm(b,-2,8936);c5(b,(c[m+20>>2]|0)+1900|0);dm(b,-2,8760);c5(b,(c[m+24>>2]|0)+1|0);dm(b,-2,6648);c5(b,(c[m+28>>2]|0)+1|0);dm(b,-2,6488);e=c[m+32>>2]|0;if((e|0)<0){i=d;return 1}c6(b,e);dm(b,-2,8560);i=d;return 1}e=f|0;a[e]=37;a[f+2|0]=0;gt(b,g);b=g|0;j=g+1036|0;k=f+1|0;f=h|0;h=l;L3014:while(1){l=a[h]|0;do{if((l<<24>>24|0)==0){break L3014}else if((l<<24>>24|0)==37){n=h+1|0;o=a[n]|0;if(o<<24>>24==0){p=2362;break}a[k]=o;gV(g,f,be(f|0,200,e|0,m|0)|0);q=n}else{p=2362}}while(0);if((p|0)==2362){p=0;n=c[b>>2]|0;if(n>>>0<j>>>0){r=l;s=n}else{gY(g)|0;r=a[h]|0;s=c[b>>2]|0}c[b>>2]=s+1;a[s]=r;q=h}h=q+1|0}gX(g);i=d;return 1}function i$(a){a=a|0;var b=0;b=~~+gK(a,1);c4(a,+b7(b|0,~~+gL(a,2,0.0)|0));return 1}function i0(a){a=a|0;c5(a,bs(gD(a,1,0,0)|0)|0);return 1}function i1(a){a=a|0;da(a,bz(gE(a,1,0)|0)|0);return 1}function i2(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=gE(a,1,0)|0;e=(aJ(d|0)|0)==0;f=c[(bE()|0)>>2]|0;if(e){c6(a,1);g=1;i=b;return g|0}else{c3(a);e=bF(f|0)|0;dc(a,7024,(h=i,i=i+16|0,c[h>>2]=d,c[h+8>>2]=e,h)|0)|0;i=h;c5(a,f);g=3;i=b;return g|0}return 0}function i3(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;d=gE(a,1,0)|0;e=(bJ(d|0,gE(a,2,0)|0)|0)==0;f=c[(bE()|0)>>2]|0;if(e){c6(a,1);g=1;i=b;return g|0}else{c3(a);e=bF(f|0)|0;dc(a,7024,(h=i,i=i+16|0,c[h>>2]=d,c[h+8>>2]=e,h)|0)|0;i=h;c5(a,f);g=3;i=b;return g|0}return 0}function i4(a){a=a|0;var b=0;b=gD(a,1,0,0)|0;da(a,bh(c[488+((gC(a,2,8176,456)|0)<<2)>>2]|0,b|0)|0);return 1}function i5(a){a=a|0;a_(gN(a,1,0)|0);return 0}function i6(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;b=i;i=i+48|0;d=b|0;if((cK(a,1)|0)<1){e=cb(0)|0}else{gI(a,1,5);cG(a,1);df(a,-1,9616);if((cS(a,-1)|0)==0){f=0}else{f=c$(a,-1)|0}cG(a,-2);c[d>>2]=f;df(a,-1,9416);if((cS(a,-1)|0)==0){g=0}else{g=c$(a,-1)|0}cG(a,-2);c[d+4>>2]=g;df(a,-1,9192);if((cS(a,-1)|0)==0){h=12}else{h=c$(a,-1)|0}cG(a,-2);c[d+8>>2]=h;df(a,-1,9056);if((cS(a,-1)|0)==0){h=gz(a,8368,(j=i,i=i+8|0,c[j>>2]=9056,j)|0)|0;i=j;k=h}else{h=c$(a,-1)|0;cG(a,-2);k=h}c[d+12>>2]=k;df(a,-1,8936);if((cS(a,-1)|0)==0){k=gz(a,8368,(j=i,i=i+8|0,c[j>>2]=8936,j)|0)|0;i=j;l=k}else{k=c$(a,-1)|0;cG(a,-2);l=k}c[d+16>>2]=l-1;df(a,-1,8760);if((cS(a,-1)|0)==0){l=gz(a,8368,(j=i,i=i+8|0,c[j>>2]=8760,j)|0)|0;i=j;m=l}else{l=c$(a,-1)|0;cG(a,-2);m=l}c[d+20>>2]=m-1900;df(a,-1,8560);if((cK(a,-1)|0)==0){n=-1}else{n=cX(a,-1)|0}cG(a,-2);c[d+32>>2]=n;e=br(d|0)|0}if((e|0)==-1){c3(a);i=b;return 1}else{c4(a,+(e|0));i=b;return 1}return 0}function i7(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;i=i+1024|0;d=b|0;if((aA(d|0)|0)==0){e=gz(a,9816,(f=i,i=i+1|0,i=i+7>>3<<3,c[f>>2]=0,f)|0)|0;i=f;g=e;i=b;return g|0}else{da(a,d);g=1;i=b;return g|0}return 0}function i8(a){a=a|0;gQ(a,3880,8);return 1}function i9(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0;b=i;i=i+1048|0;d=b|0;e=b+1040|0;f=gD(a,2,10584,e)|0;gI(a,1,5);g=gN(a,3,1)|0;if((cK(a,4)|0)<1){h=c1(a,1)|0}else{h=gM(a,4)|0}gt(a,d);do{if((g|0)<(h|0)){j=g;do{dh(a,1,j);if((cQ(a,-1)|0)==0){k=cL(a,cK(a,-1)|0)|0;gz(a,9360,(l=i,i=i+16|0,c[l>>2]=k,c[l+8>>2]=j,l)|0)|0;i=l}gZ(d);gV(d,f,c[e>>2]|0);j=j+1|0;}while((j|0)<(h|0))}else{if((g|0)==(h|0)){break}gX(d);i=b;return 1}}while(0);dh(a,1,h);if((cQ(a,-1)|0)==0){g=cL(a,cK(a,-1)|0)|0;gz(a,9360,(l=i,i=i+16|0,c[l>>2]=g,c[l+8>>2]=h,l)|0)|0;i=l}gZ(d);gX(d);i=b;return 1}function ja(a){a=a|0;var b=0,c=0;gI(a,1,5);gI(a,2,6);c3(a);if((dF(a,1)|0)==0){b=0;return b|0}while(1){cJ(a,2);cJ(a,-3);cJ(a,-3);dw(a,2,1);if((cK(a,-1)|0)!=0){b=1;c=2443;break}cG(a,-3);if((dF(a,1)|0)==0){b=0;c=2442;break}}if((c|0)==2442){return b|0}else if((c|0)==2443){return b|0}return 0}function jb(a){a=a|0;var b=0,c=0,d=0,e=0,f=0;gI(a,1,5);b=c1(a,1)|0;gI(a,2,6);if((b|0)<1){c=0;return c|0}else{d=1}while(1){cJ(a,2);c5(a,d);dh(a,1,d);dw(a,2,1);if((cK(a,-1)|0)!=0){c=1;e=2450;break}cG(a,-2);f=d+1|0;if((f|0)>(b|0)){c=0;e=2448;break}else{d=f}}if((e|0)==2450){return c|0}else if((e|0)==2448){return c|0}return 0}function jc(a){a=a|0;gI(a,1,5);c5(a,c1(a,1)|0);return 1}function jd(a){a=a|0;var b=0.0,c=0.0,d=0.0;gI(a,1,5);c3(a);L3123:do{if((dF(a,1)|0)==0){b=0.0}else{c=0.0;while(1){while(1){cG(a,-2);if((cK(a,-1)|0)==3){d=+cW(a,-1);if(d>c){break}}if((dF(a,1)|0)==0){b=c;break L3123}}if((dF(a,1)|0)==0){b=d;break}else{c=d}}}}while(0);c4(a,b);return 1}function je(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0;b=i;gI(a,1,5);d=(c1(a,1)|0)+1|0;e=cF(a)|0;do{if((e|0)==3){f=gM(a,2)|0;g=(f|0)>(d|0)?f:d;if((g|0)>(f|0)){h=g}else{j=f;break}while(1){g=h-1|0;dh(a,1,g);dp(a,1,h);if((g|0)>(f|0)){h=g}else{j=f;break}}}else if((e|0)==2){j=d}else{f=gz(a,9576,(g=i,i=i+1|0,i=i+7>>3<<3,c[g>>2]=0,g)|0)|0;i=g;k=f;i=b;return k|0}}while(0);dp(a,1,j);k=0;i=b;return k|0}function jf(a){a=a|0;var b=0,c=0,d=0,e=0;gI(a,1,5);b=c1(a,1)|0;c=gN(a,2,b)|0;if((c|0)<1|(c|0)>(b|0)){d=0;return d|0}dh(a,1,c);if((c|0)<(b|0)){e=c;while(1){c=e+1|0;dh(a,1,c);dp(a,1,e);if((c|0)<(b|0)){e=c}else{break}}}c3(a);dp(a,1,b);d=1;return d|0}function jg(a){a=a|0;var b=0,d=0;b=i;gI(a,1,5);gz(a,9776,(d=i,i=i+1|0,i=i+7>>3<<3,c[d>>2]=0,d)|0)|0;i=d;cJ(a,1);i=b;return 1}function jh(a){a=a|0;var b=0;gI(a,1,5);b=c1(a,1)|0;gH(a,40,10584);if((cK(a,2)|0)>=1){gI(a,2,6)}cG(a,2);ji(a,1,b);return 0}function ji(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;e=i;if((b|0)<(d|0)){f=b;g=d}else{i=e;return}while(1){dh(a,1,f);dh(a,1,g);if((jj(a,-1,-2)|0)==0){cG(a,-3)}else{dp(a,1,f);dp(a,1,g)}d=g-f|0;if((d|0)==1){h=2505;break}b=(g+f|0)/2|0;dh(a,1,b);dh(a,1,f);do{if((jj(a,-2,-1)|0)==0){cG(a,-2);dh(a,1,g);if((jj(a,-1,-2)|0)==0){cG(a,-3);break}else{dp(a,1,b);dp(a,1,g);break}}else{dp(a,1,b);dp(a,1,f)}}while(0);if((d|0)==2){h=2502;break}dh(a,1,b);cJ(a,-1);j=g-1|0;dh(a,1,j);dp(a,1,b);dp(a,1,j);k=j;l=f;while(1){m=l+1|0;dh(a,1,m);if((jj(a,-1,-2)|0)==0){n=l;o=m}else{p=m;while(1){if((p|0)>(g|0)){gz(a,10088,(q=i,i=i+1|0,i=i+7>>3<<3,c[q>>2]=0,q)|0)|0;i=q}cG(a,-2);m=p+1|0;dh(a,1,m);if((jj(a,-1,-2)|0)==0){n=p;o=m;break}else{p=m}}}p=k-1|0;dh(a,1,p);if((jj(a,-3,-1)|0)==0){r=p}else{m=p;while(1){if((m|0)<(f|0)){gz(a,10088,(q=i,i=i+1|0,i=i+7>>3<<3,c[q>>2]=0,q)|0)|0;i=q}cG(a,-2);p=m-1|0;dh(a,1,p);if((jj(a,-3,-1)|0)==0){r=p;break}else{m=p}}}if((r|0)<(o|0)){break}dp(a,1,o);dp(a,1,r);k=r;l=o}cG(a,-4);dh(a,1,j);dh(a,1,o);dp(a,1,j);dp(a,1,o);l=(o-f|0)<(g-o|0);k=n+2|0;b=l?k:f;d=l?g:n;ji(a,l?f:k,l?n:g);if((b|0)<(d|0)){f=b;g=d}else{h=2504;break}}if((h|0)==2502){i=e;return}else if((h|0)==2504){i=e;return}else if((h|0)==2505){i=e;return}}function jj(a,b,c){a=a|0;b=b|0;c=c|0;var d=0;if((cK(a,2)|0)==0){d=cV(a,b,c)|0;return d|0}else{cJ(a,2);cJ(a,b-1|0);cJ(a,c-2|0);dw(a,2,1);c=cX(a,-1)|0;cG(a,-2);d=c;return d|0}return 0}function jk(a){a=a|0;gQ(a,3800,184);df(a,-1,9184);dm(a,-2,7192);di(a,0,1);c9(a,10536,0);cJ(a,-2);dq(a,-2)|0;cG(a,-2);cJ(a,-2);dm(a,-2,4424);cG(a,-2);return 1}function jl(a){a=a|0;var b=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0;b=i;i=i+8|0;e=b|0;f=gE(a,1,e)|0;g=gN(a,2,1)|0;if((g|0)<0){h=g+1+(c[e>>2]|0)|0}else{h=g}g=(h|0)<0?0:h;h=gN(a,3,g)|0;j=c[e>>2]|0;if((h|0)<0){k=h+1+j|0}else{k=h}h=(k|0)<0?0:k;k=(g|0)<1?1:g;g=h>>>0>j>>>0?j:h;if((k|0)>(g|0)){l=0;i=b;return l|0}h=g-k+1|0;if((g|0)==2147483647){gz(a,5040,(g=i,i=i+1|0,i=i+7>>3<<3,c[g>>2]=0,g)|0)|0;i=g}gH(a,h,5040);if((h|0)<=0){l=h;i=b;return l|0}g=k-1|0;k=0;while(1){c5(a,d[f+(g+k)|0]|0);j=k+1|0;if((j|0)<(h|0)){k=j}else{l=h;break}}i=b;return l|0}function jm(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;d=i;i=i+1040|0;e=d|0;f=cF(b)|0;gt(b,e);if((f|0)<1){gX(e);i=d;return 1}g=e|0;h=e+1036|0;j=1;do{k=gM(b,j)|0;if((k&255|0)!=(k|0)){gy(b,j,5176)|0}l=c[g>>2]|0;if(l>>>0<h>>>0){m=l}else{gY(e)|0;m=c[g>>2]|0}c[g>>2]=m+1;a[m]=k&255;j=j+1|0;}while((j|0)<=(f|0));gX(e);i=d;return 1}function jn(a){a=a|0;var b=0,d=0;b=i;i=i+1040|0;d=b|0;gI(a,1,6);cG(a,1);gt(a,d);if((dC(a,252,d)|0)==0){gX(d);i=b;return 1}gz(a,5272,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0)|0;i=a;gX(d);i=b;return 1}function jo(a){a=a|0;return jA(a,1)|0}function jp(b){b=b|0;var e=0,f=0,g=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0.0,Y=0;e=i;i=i+1600|0;f=e|0;g=e+8|0;j=e+16|0;k=e+1056|0;l=e+1592|0;m=cF(b)|0;n=gE(b,1,g)|0;o=c[g>>2]|0;g=n+o|0;gt(b,j);L3242:do{if((o|0)>0){p=j|0;q=j+1036|0;r=k|0;s=k+1|0;t=e+1080|0;u=n;v=1;L3244:while(1){x=u;while(1){y=a[x]|0;if(y<<24>>24==37){z=x+1|0;if((a[z]|0)!=37){break}A=c[p>>2]|0;if(A>>>0<q>>>0){B=37;C=A}else{gY(j)|0;B=a[z]|0;C=c[p>>2]|0}c[p>>2]=C+1;a[C]=B;D=x+2|0}else{A=c[p>>2]|0;if(A>>>0<q>>>0){E=y;F=A}else{gY(j)|0;E=a[x]|0;F=c[p>>2]|0}c[p>>2]=F+1;a[F]=E;D=x+1|0}if(D>>>0<g>>>0){x=D}else{break L3242}}v=v+1|0;if((v|0)>(m|0)){gy(b,v,6472)|0;G=z}else{G=z}while(1){x=a[G]|0;if(x<<24>>24==0){H=0;break}if((aM(5616,x<<24>>24|0,6)|0)==0){H=x;break}G=G+1|0}x=z;if((G-x|0)>>>0>5){gz(b,5512,(I=i,i=i+1|0,i=i+7>>3<<3,c[I>>2]=0,I)|0)|0;i=I;J=a[G]|0}else{J=H}A=((J&255)-48|0)>>>0<10?G+1|0:G;y=((d[A]|0)-48|0)>>>0<10?A+1|0:A;A=a[y]|0;do{if(A<<24>>24==46){K=y+1|0;L=((d[K]|0)-48|0)>>>0<10?y+2|0:K;K=a[L]|0;if(((K&255)-48|0)>>>0>=10){M=L;N=K;break}K=L+1|0;M=K;N=a[K]|0}else{M=y;N=A}}while(0);if(((N&255)-48|0)>>>0<10){gz(b,5360,(I=i,i=i+1|0,i=i+7>>3<<3,c[I>>2]=0,I)|0)|0;i=I}a[r]=37;A=M-x|0;j3(s|0,z|0,A+1|0)|0;a[k+(A+2)|0]=0;u=M+1|0;O=a[M]|0;L3277:do{switch(O|0){case 113:{A=gE(b,v,f)|0;y=c[p>>2]|0;if(y>>>0<q>>>0){P=y}else{gY(j)|0;P=c[p>>2]|0}c[p>>2]=P+1;a[P]=34;y=c[f>>2]|0;c[f>>2]=y-1;L3282:do{if((y|0)!=0){K=A;while(1){L=a[K]|0;switch(L<<24>>24|0){case 34:case 92:case 10:{Q=c[p>>2]|0;if(Q>>>0<q>>>0){R=Q}else{gY(j)|0;R=c[p>>2]|0}c[p>>2]=R+1;a[R]=92;Q=c[p>>2]|0;if(Q>>>0<q>>>0){S=Q}else{gY(j)|0;S=c[p>>2]|0}Q=a[K]|0;c[p>>2]=S+1;a[S]=Q;break};case 13:{gV(j,6080,2);break};case 0:{gV(j,5800,4);break};default:{Q=c[p>>2]|0;if(Q>>>0<q>>>0){T=L;U=Q}else{gY(j)|0;T=a[K]|0;U=c[p>>2]|0}c[p>>2]=U+1;a[U]=T}}Q=c[f>>2]|0;c[f>>2]=Q-1;if((Q|0)==0){break L3282}else{K=K+1|0}}}}while(0);A=c[p>>2]|0;if(A>>>0<q>>>0){V=A}else{gY(j)|0;V=c[p>>2]|0}c[p>>2]=V+1;a[V]=34;break};case 115:{A=gE(b,v,l)|0;do{if((aU(r|0,46)|0)==0){if((c[l>>2]|0)>>>0<=99){break}cJ(b,v);gZ(j);break L3277}}while(0);a$(t|0,r|0,(I=i,i=i+8|0,c[I>>2]=A,I)|0)|0;i=I;W=2595;break};case 99:{y=~~+gK(b,v);a$(t|0,r|0,(I=i,i=i+8|0,c[I>>2]=y,I)|0)|0;i=I;W=2595;break};case 100:case 105:{y=j_(r|0)|0;K=k+(y-1)|0;Q=a[K]|0;L=K;w=108;a[L]=w&255;w=w>>8;a[L+1|0]=w&255;a[k+y|0]=Q;a[k+(y+1)|0]=0;y=~~+gK(b,v);a$(t|0,r|0,(I=i,i=i+8|0,c[I>>2]=y,I)|0)|0;i=I;W=2595;break};case 111:case 117:case 120:case 88:{y=j_(r|0)|0;Q=k+(y-1)|0;L=a[Q]|0;K=Q;w=108;a[K]=w&255;w=w>>8;a[K+1|0]=w&255;a[k+y|0]=L;a[k+(y+1)|0]=0;y=~~+gK(b,v);a$(t|0,r|0,(I=i,i=i+8|0,c[I>>2]=y,I)|0)|0;i=I;W=2595;break};case 101:case 69:case 102:case 103:case 71:{X=+gK(b,v);a$(t|0,r|0,(I=i,i=i+8|0,h[I>>3]=X,I)|0)|0;i=I;W=2595;break};default:{break L3244}}}while(0);if((W|0)==2595){W=0;gV(j,t,j_(t|0)|0)}if(u>>>0>=g>>>0){break L3242}}u=gz(b,6288,(I=i,i=i+8|0,c[I>>2]=O,I)|0)|0;i=I;Y=u;i=e;return Y|0}}while(0);gX(j);Y=1;i=e;return Y|0}function jq(a){a=a|0;var b=0,d=0;b=i;d=gz(a,6600,(a=i,i=i+1|0,i=i+7>>3<<3,c[a>>2]=0,a)|0)|0;i=a;i=b;return d|0}function jr(a){a=a|0;gE(a,1,0)|0;gE(a,2,0)|0;cG(a,2);c5(a,0);dd(a,286,3);return 1}function js(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0;d=i;i=i+1328|0;e=d|0;f=d+8|0;g=d+16|0;h=d+288|0;j=gE(b,1,f)|0;k=gE(b,2,0)|0;l=cK(b,3)|0;m=gN(b,4,(c[f>>2]|0)+1|0)|0;n=(a[k]|0)==94;o=n?k+1|0:k;if(!((l-3|0)>>>0<2|(l|0)==6|(l|0)==5)){gy(b,3,6824)|0}gt(b,h);l=g+8|0;c[l>>2]=b;k=g|0;c[k>>2]=j;p=g+4|0;c[p>>2]=j+(c[f>>2]|0);f=g+12|0;q=h|0;r=h+1036|0;s=g+20|0;t=g+16|0;u=j;j=0;while(1){if((j|0)>=(m|0)){v=u;w=j;x=2646;break}c[f>>2]=0;y=jB(g,u,o)|0;if((y|0)==0){z=j;x=2640}else{A=j+1|0;B=c[l>>2]|0;C=cK(B,3)|0;do{if((C|0)==3|(C|0)==4){D=c0(c[l>>2]|0,3,e)|0;if((c[e>>2]|0)==0){break}E=y-u|0;F=0;do{G=D+F|0;H=a[G]|0;do{if(H<<24>>24==37){I=F+1|0;J=D+I|0;K=a[J]|0;if(((K&255)-48|0)>>>0<10){if(K<<24>>24==48){gV(h,u,E);L=I;break}else{jC(g,(K<<24>>24)-49|0,u,y);gZ(h);L=I;break}}else{M=c[q>>2]|0;if(M>>>0<r>>>0){N=K;O=M}else{gY(h)|0;N=a[J]|0;O=c[q>>2]|0}c[q>>2]=O+1;a[O]=N;L=I;break}}else{I=c[q>>2]|0;if(I>>>0<r>>>0){P=H;Q=I}else{gY(h)|0;P=a[G]|0;Q=c[q>>2]|0}c[q>>2]=Q+1;a[Q]=P;L=F}}while(0);F=L+1|0;}while(F>>>0<(c[e>>2]|0)>>>0)}else if((C|0)==6){cJ(B,3);F=c[f>>2]|0;E=(F|0)!=0|(u|0)==0?F:1;gH(c[l>>2]|0,E,8536);if((E|0)>0){F=0;do{jC(g,F,u,y);F=F+1|0;}while((F|0)<(E|0))}dw(B,E,1);x=2634}else if((C|0)==5){L3358:do{if((c[f>>2]|0)>0){F=c[s>>2]|0;do{if((F|0)==-1){D=c[l>>2]|0;gz(D,8104,(R=i,i=i+1|0,i=i+7>>3<<3,c[R>>2]=0,R)|0)|0;i=R;S=c[l>>2]|0;T=c[t>>2]|0}else{D=c[l>>2]|0;G=c[t>>2]|0;if((F|0)!=-2){S=D;T=G;break}c5(D,G+1-(c[k>>2]|0)|0);break L3358}}while(0);c9(S,T,F)}else{c9(c[l>>2]|0,u,y-u|0)}}while(0);de(B,3);x=2634}else{x=2634}}while(0);if((x|0)==2634){x=0;do{if((cX(B,-1)|0)==0){cG(B,-2);c9(B,u,y-u|0)}else{if((cQ(B,-1)|0)!=0){break}C=cL(B,cK(B,-1)|0)|0;gz(B,6712,(R=i,i=i+8|0,c[R>>2]=C,R)|0)|0;i=R}}while(0);gZ(h)}if(y>>>0>u>>>0){U=y;V=A}else{z=A;x=2640}}if((x|0)==2640){x=0;if(u>>>0>=(c[p>>2]|0)>>>0){v=u;w=z;x=2647;break}B=c[q>>2]|0;if(B>>>0<r>>>0){W=B}else{gY(h)|0;W=c[q>>2]|0}B=a[u]|0;c[q>>2]=W+1;a[W]=B;U=u+1|0;V=z}if(n){v=U;w=V;x=2648;break}else{u=U;j=V}}if((x|0)==2646){X=c[p>>2]|0;Y=X;Z=v;_=Y-Z|0;gV(h,v,_);gX(h);c5(b,w);i=d;return 2}else if((x|0)==2647){X=c[p>>2]|0;Y=X;Z=v;_=Y-Z|0;gV(h,v,_);gX(h);c5(b,w);i=d;return 2}else if((x|0)==2648){X=c[p>>2]|0;Y=X;Z=v;_=Y-Z|0;gV(h,v,_);gX(h);c5(b,w);i=d;return 2}return 0}function jt(a){a=a|0;var b=0,d=0;b=i;i=i+8|0;d=b|0;gE(a,1,d)|0;c5(a,c[d>>2]|0);i=b;return 1}function ju(b){b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;e=i;i=i+1048|0;f=e|0;g=e+8|0;h=gE(b,1,f)|0;gt(b,g);if((c[f>>2]|0)==0){gX(g);i=e;return 1}b=g|0;j=g+1036|0;k=0;do{if((c[b>>2]|0)>>>0>=j>>>0){gY(g)|0}l=(j6(d[h+k|0]|0|0)|0)&255;m=c[b>>2]|0;c[b>>2]=m+1;a[m]=l;k=k+1|0;}while(k>>>0<(c[f>>2]|0)>>>0);gX(g);i=e;return 1}function jv(a){a=a|0;return jA(a,0)|0}function jw(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0;b=i;i=i+1048|0;d=b|0;e=b+8|0;f=gE(a,1,d)|0;g=gM(a,2)|0;gt(a,e);if((g|0)>0){h=g}else{gX(e);i=b;return 1}do{h=h-1|0;gV(e,f,c[d>>2]|0);}while((h|0)>0);gX(e);i=b;return 1}function jx(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;d=i;i=i+1048|0;e=d|0;f=d+8|0;g=gE(b,1,e)|0;gt(b,f);b=c[e>>2]|0;h=b-1|0;c[e>>2]=h;if((b|0)==0){gX(f);i=d;return 1}b=f|0;j=f+1036|0;k=h;do{h=c[b>>2]|0;if(h>>>0<j>>>0){l=k;m=h}else{gY(f)|0;l=c[e>>2]|0;m=c[b>>2]|0}h=a[g+l|0]|0;c[b>>2]=m+1;a[m]=h;h=c[e>>2]|0;k=h-1|0;c[e>>2]=k;}while((h|0)!=0);gX(f);i=d;return 1}function jy(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0;b=i;i=i+8|0;d=b|0;e=gE(a,1,d)|0;f=gM(a,2)|0;if((f|0)<0){g=f+1+(c[d>>2]|0)|0}else{g=f}f=(g|0)<0?0:g;g=gN(a,3,-1)|0;h=c[d>>2]|0;if((g|0)<0){j=g+1+h|0}else{j=g}g=(j|0)<0?0:j;j=(f|0)<1?1:f;f=(g|0)>(h|0)?h:g;if((j|0)>(f|0)){c9(a,10536,0);i=b;return 1}else{c9(a,e+(j-1)|0,1-j+f|0);i=b;return 1}return 0}function jz(b){b=b|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;e=i;i=i+1048|0;f=e|0;g=e+8|0;h=gE(b,1,f)|0;gt(b,g);if((c[f>>2]|0)==0){gX(g);i=e;return 1}b=g|0;j=g+1036|0;k=0;do{if((c[b>>2]|0)>>>0>=j>>>0){gY(g)|0}l=(bj(d[h+k|0]|0|0)|0)&255;m=c[b>>2]|0;c[b>>2]=m+1;a[m]=l;k=k+1|0;}while(k>>>0<(c[f>>2]|0)>>>0);gX(g);i=e;return 1}function jA(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0;e=i;i=i+288|0;f=e|0;g=e+8|0;h=e+16|0;j=gE(b,1,f)|0;k=gE(b,2,g)|0;l=gN(b,3,1)|0;if((l|0)<0){m=l+1+(c[f>>2]|0)|0}else{m=l}l=(m|0)<0?-1:m-1|0;if((l|0)<0){n=0}else{m=c[f>>2]|0;n=l>>>0>m>>>0?m:l}l=(d|0)!=0;L3443:do{if(l){if((cX(b,4)|0)==0){if((b2(k|0,8744)|0)!=0){o=2706;break}}d=j+n|0;m=(c[f>>2]|0)-n|0;p=c[g>>2]|0;L3448:do{if((p|0)==0){if((d|0)==0){break L3443}else{q=d}}else{if(p>>>0>m>>>0){break L3443}r=p-1|0;if((r|0)==(m|0)){break L3443}s=a[k]|0;t=k+1|0;u=d;v=m-r|0;while(1){w=aM(u|0,s|0,v|0)|0;if((w|0)==0){break L3443}x=w+1|0;if((j5(x|0,t|0,r|0)|0)==0){q=w;break L3448}w=x;y=u+v|0;if((y|0)==(w|0)){break L3443}else{u=x;v=y-w|0}}}}while(0);m=q-j|0;c5(b,m+1|0);c5(b,m+(c[g>>2]|0)|0);z=2;i=e;return z|0}else{o=2706}}while(0);L3459:do{if((o|0)==2706){g=(a[k]|0)==94;q=g?k+1|0:k;m=j+n|0;d=h+8|0;c[d>>2]=b;c[h>>2]=j;p=h+4|0;c[p>>2]=j+(c[f>>2]|0);v=h+12|0;L3461:do{if(g){c[v>>2]=0;u=jB(h,m,q)|0;if((u|0)==0){break L3459}else{A=m;B=u}}else{u=m;while(1){c[v>>2]=0;r=jB(h,u,q)|0;if((r|0)!=0){A=u;B=r;break L3461}if(u>>>0>=(c[p>>2]|0)>>>0){break L3459}u=u+1|0}}}while(0);if(l){p=j;c5(b,1-p+A|0);c5(b,B-p|0);p=c[v>>2]|0;gH(c[d>>2]|0,p,8536);if((p|0)>0){q=0;do{jC(h,q,0,0);q=q+1|0;}while((q|0)<(p|0))}z=p+2|0;i=e;return z|0}else{q=c[v>>2]|0;m=(q|0)!=0|(A|0)==0?q:1;gH(c[d>>2]|0,m,8536);if((m|0)>0){C=0}else{z=m;i=e;return z|0}while(1){jC(h,C,A,B);q=C+1|0;if((q|0)<(m|0)){C=q}else{z=m;break}}i=e;return z|0}}}while(0);c3(b);z=1;i=e;return z|0}function jB(b,e,f){b=b|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0;g=i;h=b+4|0;j=b+8|0;k=b|0;l=b+12|0;m=e;e=f;L3484:while(1){n=m+1|0;f=m-1|0;o=e;L3486:while(1){p=a[o]|0;L3488:do{switch(p|0){case 36:{q=o+1|0;if((a[q]|0)==0){r=2800;break L3484}else{s=q;t=q}break};case 0:{u=m;r=2859;break L3484;break};case 41:{r=2737;break L3484;break};case 37:{q=o+1|0;v=a[q]|0;w=v<<24>>24;if((w|0)==98){r=2744;break L3486}else if((w|0)!=102){x=v&255;if((x-48|0)>>>0<10){r=2791;break L3486}else{y=q;r=2801;break L3488}}q=o+2|0;do{if((a[q]|0)==91){z=o+3|0;r=2761}else{v=c[j>>2]|0;gz(v,7848,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A;v=a[q]|0;w=o+3|0;if((v|0)==91){z=w;r=2761;break}else if((v|0)!=37){B=w;C=w;break}if((a[w]|0)==0){v=c[j>>2]|0;gz(v,7584,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A}B=o+4|0;C=w}}while(0);if((r|0)==2761){r=0;w=(a[z]|0)==94?o+4|0:z;v=w;D=a[w]|0;while(1){if(D<<24>>24==0){w=c[j>>2]|0;gz(w,7432,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A;E=a[v]|0}else{E=D}w=v+1|0;if(E<<24>>24==37){F=(a[w]|0)==0?w:v+2|0}else{F=w}w=a[F]|0;if(w<<24>>24==93){break}else{v=F;D=w}}B=F+1|0;C=z}if((m|0)==(c[k>>2]|0)){G=0}else{G=d[f]|0}D=B-1|0;v=(a[C]|0)==94;w=v?C:q;H=v&1;v=H^1;I=w+1|0;L3517:do{if(I>>>0<D>>>0){J=w;K=I;while(1){L=a[K]|0;M=J+2|0;N=a[M]|0;L3520:do{if(L<<24>>24==37){if((jE(G,N&255)|0)==0){O=M}else{P=v;break L3517}}else{do{if(N<<24>>24==45){Q=J+3|0;if(Q>>>0>=D>>>0){break}if((L&255)>>>0>G>>>0){O=Q;break L3520}if((d[Q]|0)>>>0<G>>>0){O=Q;break L3520}else{P=v;break L3517}}}while(0);if((L&255|0)==(G|0)){P=v;break L3517}else{O=K}}}while(0);L=O+1|0;if(L>>>0<D>>>0){J=O;K=L}else{P=H;break}}}else{P=H}}while(0);if((P|0)!=0){u=0;r=2870;break L3484}H=a[m]|0;v=H&255;I=(a[C]|0)==94;w=I?C:q;K=I&1;I=K^1;J=w+1|0;L3531:do{if(J>>>0<D>>>0){L=w;N=J;while(1){M=a[N]|0;Q=L+2|0;R=a[Q]|0;L3534:do{if(M<<24>>24==37){if((jE(v,R&255)|0)==0){S=Q}else{T=I;break L3531}}else{do{if(R<<24>>24==45){U=L+3|0;if(U>>>0>=D>>>0){break}if((M&255)>(H&255)){S=U;break L3534}if((d[U]|0)<(H&255)){S=U;break L3534}else{T=I;break L3531}}}while(0);if(M<<24>>24==H<<24>>24){T=I;break L3531}else{S=N}}}while(0);M=S+1|0;if(M>>>0<D>>>0){L=S;N=M}else{T=K;break}}}else{T=K}}while(0);if((T|0)==0){u=0;r=2853;break L3484}else{o=B;continue L3486}break};case 40:{r=2728;break L3484;break};default:{y=o+1|0;r=2801}}}while(0);do{if((r|0)==2801){r=0;if((p|0)==37){if((a[y]|0)==0){K=c[j>>2]|0;gz(K,7584,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A}s=o+2|0;t=y;break}else if((p|0)!=91){s=y;t=y;break}K=(a[y]|0)==94?o+2|0:y;D=K;I=a[K]|0;while(1){if(I<<24>>24==0){K=c[j>>2]|0;gz(K,7432,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A;V=a[D]|0}else{V=I}K=D+1|0;if(V<<24>>24==37){W=(a[K]|0)==0?K:D+2|0}else{W=K}K=a[W]|0;if(K<<24>>24==93){break}else{D=W;I=K}}s=W+1|0;t=y}}while(0);if(m>>>0<(c[h>>2]|0)>>>0){p=a[m]|0;I=p&255;D=a[o]|0;K=D<<24>>24;L3564:do{if((K|0)==37){X=jE(I,d[t]|0)|0}else if((K|0)==91){H=s-1|0;v=(a[t]|0)==94;J=v?t:o;w=v&1;v=w^1;q=J+1|0;if(q>>>0<H>>>0){Y=J;Z=q}else{X=w;break}while(1){q=a[Z]|0;J=Y+2|0;N=a[J]|0;L3569:do{if(q<<24>>24==37){if((jE(I,N&255)|0)==0){_=J}else{X=v;break L3564}}else{do{if(N<<24>>24==45){L=Y+3|0;if(L>>>0>=H>>>0){break}if((q&255)>(p&255)){_=L;break L3569}if((d[L]|0)<(p&255)){_=L;break L3569}else{X=v;break L3564}}}while(0);if(q<<24>>24==p<<24>>24){X=v;break L3564}else{_=Z}}}while(0);q=_+1|0;if(q>>>0<H>>>0){Y=_;Z=q}else{X=w;break}}}else if((K|0)==46){X=1}else{X=D<<24>>24==p<<24>>24|0}}while(0);$=(X|0)!=0}else{$=0}p=a[s]|0;if((p|0)==45){r=2827;break L3484}else if((p|0)==42){r=2831;break L3484}else if((p|0)==43){r=2832;break L3484}else if((p|0)!=63){r=2849;break}p=s+1|0;if(!$){o=p;continue}D=jB(b,n,p)|0;if((D|0)==0){o=p}else{u=D;r=2862;break L3484}}if((r|0)==2791){r=0;f=x-49|0;do{if((f|0)<0){r=2794}else{if((f|0)>=(c[l>>2]|0)){r=2794;break}D=c[b+16+(f<<3)+4>>2]|0;if((D|0)==-1){r=2794}else{aa=f;ab=D}}}while(0);if((r|0)==2794){r=0;f=gz(c[j>>2]|0,8344,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A;aa=f;ab=c[b+16+(f<<3)+4>>2]|0}if(((c[h>>2]|0)-m|0)>>>0<ab>>>0){u=0;r=2851;break}if((j5(c[b+16+(aa<<3)>>2]|0,m|0,ab|0)|0)!=0){u=0;r=2854;break}f=m+ab|0;if((f|0)==0){u=0;r=2855;break}m=f;e=o+2|0;continue}else if((r|0)==2744){r=0;f=o+2|0;D=a[f]|0;if(D<<24>>24==0){r=2746}else{if((a[o+3|0]|0)==0){r=2746}else{ac=D}}if((r|0)==2746){r=0;D=c[j>>2]|0;gz(D,7168,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A;ac=a[f]|0}if((a[m]|0)!=ac<<24>>24){u=0;r=2857;break}f=a[o+3|0]|0;D=c[h>>2]|0;if(n>>>0<D>>>0){ad=m;ae=1;af=n}else{u=0;r=2858;break}while(1){p=a[af]|0;if(p<<24>>24==f<<24>>24){K=ae-1|0;if((K|0)==0){break}else{ag=K}}else{ag=(p<<24>>24==ac<<24>>24)+ae|0}p=af+1|0;if(p>>>0<D>>>0){ad=af;ae=ag;af=p}else{u=0;r=2852;break L3484}}D=ad+2|0;if((D|0)==0){u=0;r=2860;break}m=D;e=o+4|0;continue}else if((r|0)==2849){r=0;if($){m=n;e=s;continue}else{u=0;r=2869;break}}}if((r|0)==2800){u=(m|0)==(c[h>>2]|0)?m:0;i=g;return u|0}else if((r|0)==2827){e=s+1|0;ad=jB(b,m,e)|0;if((ad|0)!=0){u=ad;i=g;return u|0}ad=s-1|0;af=m;while(1){if(af>>>0>=(c[h>>2]|0)>>>0){u=0;r=2866;break}ag=a[af]|0;ae=ag&255;ac=a[o]|0;ab=ac<<24>>24;L3620:do{if((ab|0)==37){ah=jE(ae,d[t]|0)|0;r=2847}else if((ab|0)==91){aa=(a[t]|0)==94;x=aa?t:o;X=aa&1;aa=X^1;Z=x+1|0;if(Z>>>0<ad>>>0){ai=x;aj=Z}else{ah=X;r=2847;break}while(1){Z=a[aj]|0;x=ai+2|0;_=a[x]|0;L3625:do{if(Z<<24>>24==37){if((jE(ae,_&255)|0)==0){ak=x}else{ah=aa;r=2847;break L3620}}else{do{if(_<<24>>24==45){Y=ai+3|0;if(Y>>>0>=ad>>>0){break}if((Z&255)>(ag&255)){ak=Y;break L3625}if((d[Y]|0)<(ag&255)){ak=Y;break L3625}else{ah=aa;r=2847;break L3620}}}while(0);if(Z<<24>>24==ag<<24>>24){ah=aa;r=2847;break L3620}else{ak=aj}}}while(0);Z=ak+1|0;if(Z>>>0<ad>>>0){ai=ak;aj=Z}else{ah=X;r=2847;break}}}else if((ab|0)!=46){ah=ac<<24>>24==ag<<24>>24|0;r=2847}}while(0);if((r|0)==2847){r=0;if((ah|0)==0){u=0;r=2867;break}}ag=af+1|0;ac=jB(b,ag,e)|0;if((ac|0)==0){af=ag}else{u=ac;r=2868;break}}if((r|0)==2866){i=g;return u|0}else if((r|0)==2867){i=g;return u|0}else if((r|0)==2868){i=g;return u|0}}else if((r|0)==2831){u=jD(b,m,o,s)|0;i=g;return u|0}else if((r|0)==2832){if(!$){u=0;i=g;return u|0}u=jD(b,n,o,s)|0;i=g;return u|0}else if((r|0)==2851){i=g;return u|0}else if((r|0)==2852){i=g;return u|0}else if((r|0)==2853){i=g;return u|0}else if((r|0)==2854){i=g;return u|0}else if((r|0)==2855){i=g;return u|0}else if((r|0)==2857){i=g;return u|0}else if((r|0)==2858){i=g;return u|0}else if((r|0)==2859){i=g;return u|0}else if((r|0)==2860){i=g;return u|0}else if((r|0)==2862){i=g;return u|0}else if((r|0)==2869){i=g;return u|0}else if((r|0)==2870){i=g;return u|0}else if((r|0)==2737){s=o+1|0;n=c[l>>2]|0;while(1){$=n-1|0;if((n|0)<=0){r=2740;break}if((c[b+16+($<<3)+4>>2]|0)==-1){al=$;break}else{n=$}}if((r|0)==2740){n=gz(c[j>>2]|0,7e3,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A;al=n}n=b+16+(al<<3)+4|0;c[n>>2]=m-(c[b+16+(al<<3)>>2]|0);al=jB(b,m,s)|0;if((al|0)!=0){u=al;i=g;return u|0}c[n>>2]=-1;u=0;i=g;return u|0}else if((r|0)==2728){r=o+1|0;if((a[r]|0)==41){n=c[l>>2]|0;if((n|0)>31){al=c[j>>2]|0;gz(al,8536,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A}c[b+16+(n<<3)>>2]=m;c[b+16+(n<<3)+4>>2]=-2;c[l>>2]=n+1;n=jB(b,m,o+2|0)|0;if((n|0)!=0){u=n;i=g;return u|0}c[l>>2]=(c[l>>2]|0)-1;u=0;i=g;return u|0}else{n=c[l>>2]|0;if((n|0)>31){o=c[j>>2]|0;gz(o,8536,(A=i,i=i+1|0,i=i+7>>3<<3,c[A>>2]=0,A)|0)|0;i=A}c[b+16+(n<<3)>>2]=m;c[b+16+(n<<3)+4>>2]=-1;c[l>>2]=n+1;n=jB(b,m,r)|0;if((n|0)!=0){u=n;i=g;return u|0}c[l>>2]=(c[l>>2]|0)-1;u=0;i=g;return u|0}}return 0}function jC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;f=i;if((c[a+12>>2]|0)<=(b|0)){g=c[a+8>>2]|0;if((b|0)==0){c9(g,d,e-d|0);i=f;return}else{gz(g,8344,(h=i,i=i+1|0,i=i+7>>3<<3,c[h>>2]=0,h)|0)|0;i=h;i=f;return}}g=c[a+16+(b<<3)+4>>2]|0;do{if((g|0)==-1){d=a+8|0;e=c[d>>2]|0;gz(e,8104,(h=i,i=i+1|0,i=i+7>>3<<3,c[h>>2]=0,h)|0)|0;i=h;j=c[d>>2]|0;k=c[a+16+(b<<3)>>2]|0}else{d=c[a+8>>2]|0;e=c[a+16+(b<<3)>>2]|0;if((g|0)!=-2){j=d;k=e;break}c5(d,e+1-(c[a>>2]|0)|0);i=f;return}}while(0);c9(j,k,g);i=f;return}function jD(b,e,f,g){b=b|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;h=b+4|0;i=c[h>>2]|0;L3707:do{if(i>>>0>e>>>0){j=f+1|0;k=g-1|0;l=0;m=e;n=i;while(1){o=a[m]|0;p=o&255;q=a[f]|0;r=q<<24>>24;L3711:do{if((r|0)==37){s=jE(p,d[j]|0)|0;t=2905}else if((r|0)==46){u=n}else if((r|0)==91){v=(a[j]|0)==94;w=v?j:f;x=v&1;v=x^1;y=w+1|0;if(y>>>0<k>>>0){z=w;A=y}else{s=x;t=2905;break}while(1){y=a[A]|0;w=z+2|0;B=a[w]|0;L3717:do{if(y<<24>>24==37){if((jE(p,B&255)|0)==0){C=w}else{s=v;t=2905;break L3711}}else{do{if(B<<24>>24==45){D=z+3|0;if(D>>>0>=k>>>0){break}if((y&255)>(o&255)){C=D;break L3717}if((d[D]|0)<(o&255)){C=D;break L3717}else{s=v;t=2905;break L3711}}}while(0);if(y<<24>>24==o<<24>>24){s=v;t=2905;break L3711}else{C=A}}}while(0);y=C+1|0;if(y>>>0<k>>>0){z=C;A=y}else{s=x;t=2905;break}}}else{s=q<<24>>24==o<<24>>24|0;t=2905}}while(0);if((t|0)==2905){t=0;if((s|0)==0){E=l;break L3707}u=c[h>>2]|0}o=l+1|0;q=e+o|0;if(q>>>0<u>>>0){l=o;m=q;n=u}else{E=o;break}}}else{E=0}}while(0);u=g+1|0;g=E;while(1){if((g|0)<=-1){F=0;t=2912;break}E=jB(b,e+g|0,u)|0;if((E|0)==0){g=g-1|0}else{F=E;t=2913;break}}if((t|0)==2913){return F|0}else if((t|0)==2912){return F|0}return 0}function jE(a,b){a=a|0;b=b|0;var c=0,d=0;switch(j6(b|0)|0){case 120:{c=aY(a|0)|0;break};case 122:{c=(a|0)==0|0;break};case 119:{c=bq(a|0)|0;break};case 115:{c=aB(a|0)|0;break};case 112:{c=bU(a|0)|0;break};case 97:{c=bt(a|0)|0;break};case 117:{c=bd(a|0)|0;break};case 108:{c=bb(a|0)|0;break};case 100:{c=(a-48|0)>>>0<10|0;break};case 99:{c=b8(a|0)|0;break};default:{d=(b|0)==(a|0)|0;return d|0}}if((bb(b|0)|0)!=0){d=c;return d|0}d=(c|0)==0|0;return d|0}function jF(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;b=i;i=i+280|0;d=b|0;e=b+272|0;f=c0(a,-10003,e)|0;g=c0(a,-10004,0)|0;h=d+8|0;c[h>>2]=a;c[d>>2]=f;j=f+(c[e>>2]|0)|0;e=d+4|0;c[e>>2]=j;k=d+12|0;l=f+(c$(a,-10005)|0)|0;m=j;while(1){if(l>>>0>m>>>0){n=0;o=2939;break}c[k>>2]=0;p=jB(d,l,g)|0;if((p|0)!=0){break}l=l+1|0;m=c[e>>2]|0}if((o|0)==2939){i=b;return n|0}c5(a,p-f+((p|0)==(l|0))|0);cP(a,-10005);a=c[k>>2]|0;k=(a|0)!=0|(l|0)==0?a:1;gH(c[h>>2]|0,k,8536);if((k|0)>0){q=0}else{n=k;i=b;return n|0}while(1){jC(d,q,l,p);h=q+1|0;if((h|0)<(k|0)){q=h}else{n=k;break}}i=b;return n|0}function jG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;gV(d,b,c);return 0}function jH(a){a=a|0;var b=0,c=0;gF(a,3592)|0;dd(a,380,0);dm(a,-2,9152);gQ(a,7152,432);cJ(a,-1);cP(a,-10001);di(a,4,0);dd(a,388,0);dp(a,-2,1);dd(a,320,0);dp(a,-2,2);dd(a,524,0);dp(a,-2,3);dd(a,276,0);dp(a,-2,4);dm(a,-2,5608);b=bz(3768|0)|0;if((b|0)==0){da(a,3048)}else{c=gT(a,b,6816,6704)|0;gT(a,c,6592,3048)|0;cH(a,-2)}dm(a,-2,4376);c=bz(2344|0)|0;if((c|0)==0){da(a,2072)}else{b=gT(a,c,6816,6704)|0;gT(a,b,6592,2072)|0;cH(a,-2)}dm(a,-2,2680);c9(a,10272,9);dm(a,-2,10048);gS(a,-1e4,9760,2)|0;dm(a,-2,9560);di(a,0,0);dm(a,-2,9344);cJ(a,-10002);gQ(a,0,1368);cG(a,-2);return 1}function jI(a){a=a|0;c[(gG(a,1,3592)|0)>>2]=0;return 0}function jJ(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0;b=i;i=i+104|0;d=b|0;e=gE(a,1,0)|0;f=cF(a)|0;g=f+1|0;df(a,-1e4,9760);df(a,g,e);do{if((cK(a,-1)|0)!=5){cG(a,-2);if((gS(a,-10002,e,1)|0)==0){cJ(a,-1);dm(a,g,e);break}h=gz(a,8072,(j=i,i=i+8|0,c[j>>2]=e,j)|0)|0;i=j;k=h;i=b;return k|0}}while(0);df(a,-1,7840);g=(cK(a,-1)|0)==0;cG(a,-2);if(g){cJ(a,-1);dm(a,-2,7160);da(a,e);dm(a,-2,7840);g=a0(e|0,46)|0;c9(a,e,((g|0)==0?e:g+1|0)-e|0);dm(a,-2,6976)}cJ(a,-1);do{if((ej(a,1,d)|0)==0){l=2960}else{if((en(a,7576,d)|0)==0){l=2960;break}if((cM(a,-1)|0)!=0){l=2960}}}while(0);if((l|0)==2960){gz(a,7392,(j=i,i=i+1|0,i=i+7>>3<<3,c[j>>2]=0,j)|0)|0;i=j}cJ(a,-2);dv(a,-2)|0;cG(a,-2);if((f|0)<2){k=0;i=b;return k|0}else{m=2}while(1){cJ(a,m);cJ(a,-2);dw(a,1,0);j=m+1|0;if((j|0)>(f|0)){k=0;break}else{m=j}}i=b;return k|0}function jK(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=gE(a,1,0)|0;cG(a,1);df(a,-1e4,9760);df(a,2,d);if((cX(a,-1)|0)!=0){if((cZ(a,-1)|0)!=10480){i=b;return 1}gz(a,8880,(e=i,i=i+8|0,c[e>>2]=d,e)|0)|0;i=e;i=b;return 1}df(a,-10001,5608);if((cK(a,-1)|0)!=5){gz(a,8704,(e=i,i=i+1|0,i=i+7>>3<<3,c[e>>2]=0,e)|0)|0;i=e}c9(a,10552,0);f=1;while(1){dh(a,-2,f);if((cK(a,-1)|0)==0){g=c0(a,-2,0)|0;gz(a,8312,(e=i,i=i+16|0,c[e>>2]=d,c[e+8>>2]=g,e)|0)|0;i=e}da(a,d);dw(a,1,1);if((cK(a,-1)|0)==6){break}if((cQ(a,-1)|0)==0){cG(a,-2)}else{dG(a,2)}f=f+1|0}c7(a,10480);dm(a,2,d);da(a,d);dw(a,1,1);if((cK(a,-1)|0)!=0){dm(a,2,d)}df(a,2,d);if((cZ(a,-1)|0)!=10480){i=b;return 1}c6(a,1);cJ(a,-1);dm(a,2,d);i=b;return 1}function jL(a){a=a|0;var b=0,d=0,e=0;b=i;d=gE(a,1,0)|0;df(a,-10001,9344);if((cK(a,-1)|0)!=5){gz(a,4384,(e=i,i=i+1|0,i=i+7>>3<<3,c[e>>2]=0,e)|0)|0;i=e}df(a,-1,d);if((cK(a,-1)|0)!=0){i=b;return 1}dc(a,4272,(e=i,i=i+8|0,c[e>>2]=d,e)|0)|0;i=e;i=b;return 1}function jM(a){a=a|0;var b=0,d=0,e=0,f=0;b=i;d=jP(a,gE(a,1,0)|0,4376)|0;if((d|0)==0){i=b;return 1}if((g0(a,d)|0)==0){i=b;return 1}e=c0(a,1,0)|0;f=c0(a,-1,0)|0;gz(a,6240,(a=i,i=i+24|0,c[a>>2]=e,c[a+8>>2]=d,c[a+16>>2]=f,a)|0)|0;i=a;i=b;return 1}function jN(a){a=a|0;var b=0,d=0,e=0,f=0,g=0;b=i;d=gE(a,1,0)|0;e=jP(a,d,2680)|0;if((e|0)==0){i=b;return 1}f=aU(d|0,45)|0;g=gT(a,(f|0)==0?d:f+1|0,5496,5352)|0;dc(a,5256,(f=i,i=i+8|0,c[f>>2]=g,f)|0)|0;i=f;cH(a,-2);if((jQ(a,e)|0)==0){i=b;return 1}g=c0(a,1,0)|0;d=c0(a,-1,0)|0;gz(a,6240,(f=i,i=i+24|0,c[f>>2]=g,c[f+8>>2]=e,c[f+16>>2]=d,f)|0)|0;i=f;i=b;return 1}function jO(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,j=0;b=i;d=gE(a,1,0)|0;e=aU(d|0,46)|0;if((e|0)==0){f=0;i=b;return f|0}c9(a,d,e-d|0);e=jP(a,c0(a,-1,0)|0,2680)|0;if((e|0)==0){f=1;i=b;return f|0}g=aU(d|0,45)|0;h=gT(a,(g|0)==0?d:g+1|0,5496,5352)|0;dc(a,5256,(g=i,i=i+8|0,c[g>>2]=h,g)|0)|0;i=g;cH(a,-2);h=jQ(a,e)|0;if((h|0)==0){f=1;i=b;return f|0}else if((h|0)!=2){h=c0(a,1,0)|0;j=c0(a,-1,0)|0;gz(a,6240,(g=i,i=i+24|0,c[g>>2]=h,c[g+8>>2]=e,c[g+16>>2]=j,g)|0)|0;i=g}dc(a,6440,(g=i,i=i+16|0,c[g>>2]=d,c[g+8>>2]=e,g)|0)|0;i=g;f=1;i=b;return f|0}function jP(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0;f=i;g=gT(b,d,5496,5168)|0;df(b,-10001,e);d=c0(b,-1,0)|0;if((d|0)==0){gz(b,5008,(h=i,i=i+8|0,c[h>>2]=e,h)|0)|0;i=h}c9(b,10552,0);e=d;while(1){d=a[e]|0;if((d<<24>>24|0)==0){j=0;k=3034;break}else if((d<<24>>24|0)==59){e=e+1|0;continue}d=aU(e|0,59)|0;if((d|0)==0){l=e+(j_(e|0)|0)|0}else{l=d}c9(b,e,l-e|0);if((l|0)==0){j=0;k=3033;break}m=gT(b,c0(b,-1,0)|0,4880,g)|0;cH(b,-2);n=bl(m|0,4600|0)|0;if((n|0)!=0){k=3029;break}dc(b,4720,(h=i,i=i+8|0,c[h>>2]=m,h)|0)|0;i=h;cH(b,-2);dG(b,2);e=l}if((k|0)==3029){ar(n|0)|0;j=m;i=f;return j|0}else if((k|0)==3033){i=f;return j|0}else if((k|0)==3034){i=f;return j|0}return 0}function jQ(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=i;dc(a,5792,(e=i,i=i+16|0,c[e>>2]=5720,c[e+8>>2]=b,e)|0)|0;i=e;de(a,-1e4);if((cK(a,-1)|0)==0){cG(a,-2);f=dH(a,4)|0;c[f>>2]=0;df(a,-1e4,3592);dq(a,-2)|0;dc(a,5792,(e=i,i=i+16|0,c[e>>2]=5720,c[e+8>>2]=b,e)|0)|0;i=e;cJ(a,-2);dl(a,-1e4);g=f}else{g=cZ(a,-1)|0}f=(c[g>>2]|0)==0;c9(a,6e3,58);if(!f){h=2;i=d;return h|0}c[g>>2]=0;h=1;i=d;return h|0}function jR(a){a=a|0;var b=0,c=0,d=0;b=gE(a,1,0)|0;gE(a,2,0)|0;c=jQ(a,b)|0;if((c|0)==0){d=1;return d|0}c3(a);cI(a,-2);da(a,(c|0)==1?4072:4024);d=3;return d|0}function jS(a){a=a|0;gI(a,1,5);if((dj(a,1)|0)==0){di(a,0,1);cJ(a,-1);dq(a,1)|0}cJ(a,-10002);dm(a,-2,4136);return 0}function jT(a){a=a|0;dd(a,504,0);da(a,10528);dw(a,1,0);dd(a,398,0);da(a,9080);dw(a,1,0);dd(a,350,0);da(a,7064);dw(a,1,0);dd(a,282,0);da(a,5552);dw(a,1,0);dd(a,356,0);da(a,4312);dw(a,1,0);dd(a,324,0);da(a,3744);dw(a,1,0);dd(a,296,0);da(a,3040);dw(a,1,0);dd(a,412,0);da(a,2672);dw(a,1,0);return}function jU(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0;do{if(a>>>0<245){if(a>>>0<11){b=16}else{b=a+11&-8}d=b>>>3;e=c[2648]|0;f=e>>>(d>>>0);if((f&3|0)!=0){g=(f&1^1)+d|0;h=g<<1;i=10632+(h<<2)|0;j=10632+(h+2<<2)|0;h=c[j>>2]|0;k=h+8|0;l=c[k>>2]|0;do{if((i|0)==(l|0)){c[2648]=e&~(1<<g)}else{if(l>>>0<(c[2652]|0)>>>0){bM();return 0}m=l+12|0;if((c[m>>2]|0)==(h|0)){c[m>>2]=i;c[j>>2]=l;break}else{bM();return 0}}}while(0);l=g<<3;c[h+4>>2]=l|3;j=h+(l|4)|0;c[j>>2]=c[j>>2]|1;n=k;return n|0}if(b>>>0<=(c[2650]|0)>>>0){o=b;break}if((f|0)!=0){j=2<<d;l=f<<d&(j|-j);j=(l&-l)-1|0;l=j>>>12&16;i=j>>>(l>>>0);j=i>>>5&8;m=i>>>(j>>>0);i=m>>>2&4;p=m>>>(i>>>0);m=p>>>1&2;q=p>>>(m>>>0);p=q>>>1&1;r=(j|l|i|m|p)+(q>>>(p>>>0))|0;p=r<<1;q=10632+(p<<2)|0;m=10632+(p+2<<2)|0;p=c[m>>2]|0;i=p+8|0;l=c[i>>2]|0;do{if((q|0)==(l|0)){c[2648]=e&~(1<<r)}else{if(l>>>0<(c[2652]|0)>>>0){bM();return 0}j=l+12|0;if((c[j>>2]|0)==(p|0)){c[j>>2]=q;c[m>>2]=l;break}else{bM();return 0}}}while(0);l=r<<3;m=l-b|0;c[p+4>>2]=b|3;q=p;e=q+b|0;c[q+(b|4)>>2]=m|1;c[q+l>>2]=m;l=c[2650]|0;if((l|0)!=0){q=c[2653]|0;d=l>>>3;l=d<<1;f=10632+(l<<2)|0;k=c[2648]|0;h=1<<d;do{if((k&h|0)==0){c[2648]=k|h;s=f;t=10632+(l+2<<2)|0}else{d=10632+(l+2<<2)|0;g=c[d>>2]|0;if(g>>>0>=(c[2652]|0)>>>0){s=g;t=d;break}bM();return 0}}while(0);c[t>>2]=q;c[s+12>>2]=q;c[q+8>>2]=s;c[q+12>>2]=f}c[2650]=m;c[2653]=e;n=i;return n|0}l=c[2649]|0;if((l|0)==0){o=b;break}h=(l&-l)-1|0;l=h>>>12&16;k=h>>>(l>>>0);h=k>>>5&8;p=k>>>(h>>>0);k=p>>>2&4;r=p>>>(k>>>0);p=r>>>1&2;d=r>>>(p>>>0);r=d>>>1&1;g=c[10896+((h|l|k|p|r)+(d>>>(r>>>0))<<2)>>2]|0;r=g;d=g;p=(c[g+4>>2]&-8)-b|0;while(1){g=c[r+16>>2]|0;if((g|0)==0){k=c[r+20>>2]|0;if((k|0)==0){break}else{u=k}}else{u=g}g=(c[u+4>>2]&-8)-b|0;k=g>>>0<p>>>0;r=u;d=k?u:d;p=k?g:p}r=d;i=c[2652]|0;if(r>>>0<i>>>0){bM();return 0}e=r+b|0;m=e;if(r>>>0>=e>>>0){bM();return 0}e=c[d+24>>2]|0;f=c[d+12>>2]|0;do{if((f|0)==(d|0)){q=d+20|0;g=c[q>>2]|0;if((g|0)==0){k=d+16|0;l=c[k>>2]|0;if((l|0)==0){v=0;break}else{w=l;x=k}}else{w=g;x=q}while(1){q=w+20|0;g=c[q>>2]|0;if((g|0)!=0){w=g;x=q;continue}q=w+16|0;g=c[q>>2]|0;if((g|0)==0){break}else{w=g;x=q}}if(x>>>0<i>>>0){bM();return 0}else{c[x>>2]=0;v=w;break}}else{q=c[d+8>>2]|0;if(q>>>0<i>>>0){bM();return 0}g=q+12|0;if((c[g>>2]|0)!=(d|0)){bM();return 0}k=f+8|0;if((c[k>>2]|0)==(d|0)){c[g>>2]=f;c[k>>2]=q;v=f;break}else{bM();return 0}}}while(0);L4106:do{if((e|0)!=0){f=d+28|0;i=10896+(c[f>>2]<<2)|0;do{if((d|0)==(c[i>>2]|0)){c[i>>2]=v;if((v|0)!=0){break}c[2649]=c[2649]&~(1<<c[f>>2]);break L4106}else{if(e>>>0<(c[2652]|0)>>>0){bM();return 0}q=e+16|0;if((c[q>>2]|0)==(d|0)){c[q>>2]=v}else{c[e+20>>2]=v}if((v|0)==0){break L4106}}}while(0);if(v>>>0<(c[2652]|0)>>>0){bM();return 0}c[v+24>>2]=e;f=c[d+16>>2]|0;do{if((f|0)!=0){if(f>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[v+16>>2]=f;c[f+24>>2]=v;break}}}while(0);f=c[d+20>>2]|0;if((f|0)==0){break}if(f>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[v+20>>2]=f;c[f+24>>2]=v;break}}}while(0);if(p>>>0<16){e=p+b|0;c[d+4>>2]=e|3;f=r+(e+4)|0;c[f>>2]=c[f>>2]|1}else{c[d+4>>2]=b|3;c[r+(b|4)>>2]=p|1;c[r+(p+b)>>2]=p;f=c[2650]|0;if((f|0)!=0){e=c[2653]|0;i=f>>>3;f=i<<1;q=10632+(f<<2)|0;k=c[2648]|0;g=1<<i;do{if((k&g|0)==0){c[2648]=k|g;y=q;z=10632+(f+2<<2)|0}else{i=10632+(f+2<<2)|0;l=c[i>>2]|0;if(l>>>0>=(c[2652]|0)>>>0){y=l;z=i;break}bM();return 0}}while(0);c[z>>2]=e;c[y+12>>2]=e;c[e+8>>2]=y;c[e+12>>2]=q}c[2650]=p;c[2653]=m}f=d+8|0;if((f|0)==0){o=b;break}else{n=f}return n|0}else{if(a>>>0>4294967231){o=-1;break}f=a+11|0;g=f&-8;k=c[2649]|0;if((k|0)==0){o=g;break}r=-g|0;i=f>>>8;do{if((i|0)==0){A=0}else{if(g>>>0>16777215){A=31;break}f=(i+1048320|0)>>>16&8;l=i<<f;h=(l+520192|0)>>>16&4;j=l<<h;l=(j+245760|0)>>>16&2;B=14-(h|f|l)+(j<<l>>>15)|0;A=g>>>((B+7|0)>>>0)&1|B<<1}}while(0);i=c[10896+(A<<2)>>2]|0;L3914:do{if((i|0)==0){C=0;D=r;E=0}else{if((A|0)==31){F=0}else{F=25-(A>>>1)|0}d=0;m=r;p=i;q=g<<F;e=0;while(1){B=c[p+4>>2]&-8;l=B-g|0;if(l>>>0<m>>>0){if((B|0)==(g|0)){C=p;D=l;E=p;break L3914}else{G=p;H=l}}else{G=d;H=m}l=c[p+20>>2]|0;B=c[p+16+(q>>>31<<2)>>2]|0;j=(l|0)==0|(l|0)==(B|0)?e:l;if((B|0)==0){C=G;D=H;E=j;break}else{d=G;m=H;p=B;q=q<<1;e=j}}}}while(0);if((E|0)==0&(C|0)==0){i=2<<A;r=k&(i|-i);if((r|0)==0){o=g;break}i=(r&-r)-1|0;r=i>>>12&16;e=i>>>(r>>>0);i=e>>>5&8;q=e>>>(i>>>0);e=q>>>2&4;p=q>>>(e>>>0);q=p>>>1&2;m=p>>>(q>>>0);p=m>>>1&1;I=c[10896+((i|r|e|q|p)+(m>>>(p>>>0))<<2)>>2]|0}else{I=E}if((I|0)==0){J=D;K=C}else{p=I;m=D;q=C;while(1){e=(c[p+4>>2]&-8)-g|0;r=e>>>0<m>>>0;i=r?e:m;e=r?p:q;r=c[p+16>>2]|0;if((r|0)!=0){p=r;m=i;q=e;continue}r=c[p+20>>2]|0;if((r|0)==0){J=i;K=e;break}else{p=r;m=i;q=e}}}if((K|0)==0){o=g;break}if(J>>>0>=((c[2650]|0)-g|0)>>>0){o=g;break}q=K;m=c[2652]|0;if(q>>>0<m>>>0){bM();return 0}p=q+g|0;k=p;if(q>>>0>=p>>>0){bM();return 0}e=c[K+24>>2]|0;i=c[K+12>>2]|0;do{if((i|0)==(K|0)){r=K+20|0;d=c[r>>2]|0;if((d|0)==0){j=K+16|0;B=c[j>>2]|0;if((B|0)==0){L=0;break}else{M=B;N=j}}else{M=d;N=r}while(1){r=M+20|0;d=c[r>>2]|0;if((d|0)!=0){M=d;N=r;continue}r=M+16|0;d=c[r>>2]|0;if((d|0)==0){break}else{M=d;N=r}}if(N>>>0<m>>>0){bM();return 0}else{c[N>>2]=0;L=M;break}}else{r=c[K+8>>2]|0;if(r>>>0<m>>>0){bM();return 0}d=r+12|0;if((c[d>>2]|0)!=(K|0)){bM();return 0}j=i+8|0;if((c[j>>2]|0)==(K|0)){c[d>>2]=i;c[j>>2]=r;L=i;break}else{bM();return 0}}}while(0);L3964:do{if((e|0)!=0){i=K+28|0;m=10896+(c[i>>2]<<2)|0;do{if((K|0)==(c[m>>2]|0)){c[m>>2]=L;if((L|0)!=0){break}c[2649]=c[2649]&~(1<<c[i>>2]);break L3964}else{if(e>>>0<(c[2652]|0)>>>0){bM();return 0}r=e+16|0;if((c[r>>2]|0)==(K|0)){c[r>>2]=L}else{c[e+20>>2]=L}if((L|0)==0){break L3964}}}while(0);if(L>>>0<(c[2652]|0)>>>0){bM();return 0}c[L+24>>2]=e;i=c[K+16>>2]|0;do{if((i|0)!=0){if(i>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[L+16>>2]=i;c[i+24>>2]=L;break}}}while(0);i=c[K+20>>2]|0;if((i|0)==0){break}if(i>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[L+20>>2]=i;c[i+24>>2]=L;break}}}while(0);do{if(J>>>0<16){e=J+g|0;c[K+4>>2]=e|3;i=q+(e+4)|0;c[i>>2]=c[i>>2]|1}else{c[K+4>>2]=g|3;c[q+(g|4)>>2]=J|1;c[q+(J+g)>>2]=J;i=J>>>3;if(J>>>0<256){e=i<<1;m=10632+(e<<2)|0;r=c[2648]|0;j=1<<i;do{if((r&j|0)==0){c[2648]=r|j;O=m;P=10632+(e+2<<2)|0}else{i=10632+(e+2<<2)|0;d=c[i>>2]|0;if(d>>>0>=(c[2652]|0)>>>0){O=d;P=i;break}bM();return 0}}while(0);c[P>>2]=k;c[O+12>>2]=k;c[q+(g+8)>>2]=O;c[q+(g+12)>>2]=m;break}e=p;j=J>>>8;do{if((j|0)==0){Q=0}else{if(J>>>0>16777215){Q=31;break}r=(j+1048320|0)>>>16&8;i=j<<r;d=(i+520192|0)>>>16&4;B=i<<d;i=(B+245760|0)>>>16&2;l=14-(d|r|i)+(B<<i>>>15)|0;Q=J>>>((l+7|0)>>>0)&1|l<<1}}while(0);j=10896+(Q<<2)|0;c[q+(g+28)>>2]=Q;c[q+(g+20)>>2]=0;c[q+(g+16)>>2]=0;m=c[2649]|0;l=1<<Q;if((m&l|0)==0){c[2649]=m|l;c[j>>2]=e;c[q+(g+24)>>2]=j;c[q+(g+12)>>2]=e;c[q+(g+8)>>2]=e;break}if((Q|0)==31){R=0}else{R=25-(Q>>>1)|0}l=J<<R;m=c[j>>2]|0;while(1){if((c[m+4>>2]&-8|0)==(J|0)){break}S=m+16+(l>>>31<<2)|0;j=c[S>>2]|0;if((j|0)==0){T=3202;break}else{l=l<<1;m=j}}if((T|0)==3202){if(S>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[S>>2]=e;c[q+(g+24)>>2]=m;c[q+(g+12)>>2]=e;c[q+(g+8)>>2]=e;break}}l=m+8|0;j=c[l>>2]|0;i=c[2652]|0;if(m>>>0<i>>>0){bM();return 0}if(j>>>0<i>>>0){bM();return 0}else{c[j+12>>2]=e;c[l>>2]=e;c[q+(g+8)>>2]=j;c[q+(g+12)>>2]=m;c[q+(g+24)>>2]=0;break}}}while(0);q=K+8|0;if((q|0)==0){o=g;break}else{n=q}return n|0}}while(0);K=c[2650]|0;if(o>>>0<=K>>>0){S=K-o|0;J=c[2653]|0;if(S>>>0>15){R=J;c[2653]=R+o;c[2650]=S;c[R+(o+4)>>2]=S|1;c[R+K>>2]=S;c[J+4>>2]=o|3}else{c[2650]=0;c[2653]=0;c[J+4>>2]=K|3;S=J+(K+4)|0;c[S>>2]=c[S>>2]|1}n=J+8|0;return n|0}J=c[2651]|0;if(o>>>0<J>>>0){S=J-o|0;c[2651]=S;J=c[2654]|0;K=J;c[2654]=K+o;c[K+(o+4)>>2]=S|1;c[J+4>>2]=o|3;n=J+8|0;return n|0}do{if((c[2622]|0)==0){J=bK(8)|0;if((J-1&J|0)==0){c[2624]=J;c[2623]=J;c[2625]=-1;c[2626]=-1;c[2627]=0;c[2759]=0;c[2622]=(cb(0)|0)&-16^1431655768;break}else{bM();return 0}}}while(0);J=o+48|0;S=c[2624]|0;K=o+47|0;R=S+K|0;Q=-S|0;S=R&Q;if(S>>>0<=o>>>0){n=0;return n|0}O=c[2758]|0;do{if((O|0)!=0){P=c[2756]|0;L=P+S|0;if(L>>>0<=P>>>0|L>>>0>O>>>0){n=0}else{break}return n|0}}while(0);L4173:do{if((c[2759]&4|0)==0){O=c[2654]|0;L4175:do{if((O|0)==0){T=3232}else{L=O;P=11040;while(1){U=P|0;M=c[U>>2]|0;if(M>>>0<=L>>>0){V=P+4|0;if((M+(c[V>>2]|0)|0)>>>0>L>>>0){break}}M=c[P+8>>2]|0;if((M|0)==0){T=3232;break L4175}else{P=M}}if((P|0)==0){T=3232;break}L=R-(c[2651]|0)&Q;if(L>>>0>=2147483647){W=0;break}m=bB(L|0)|0;e=(m|0)==((c[U>>2]|0)+(c[V>>2]|0)|0);X=e?m:-1;Y=e?L:0;Z=m;_=L;T=3241}}while(0);do{if((T|0)==3232){O=bB(0)|0;if((O|0)==-1){W=0;break}g=O;L=c[2623]|0;m=L-1|0;if((m&g|0)==0){$=S}else{$=S-g+(m+g&-L)|0}L=c[2756]|0;g=L+$|0;if(!($>>>0>o>>>0&$>>>0<2147483647)){W=0;break}m=c[2758]|0;if((m|0)!=0){if(g>>>0<=L>>>0|g>>>0>m>>>0){W=0;break}}m=bB($|0)|0;g=(m|0)==(O|0);X=g?O:-1;Y=g?$:0;Z=m;_=$;T=3241}}while(0);L4195:do{if((T|0)==3241){m=-_|0;if((X|0)!=-1){aa=Y;ab=X;T=3252;break L4173}do{if((Z|0)!=-1&_>>>0<2147483647&_>>>0<J>>>0){g=c[2624]|0;O=K-_+g&-g;if(O>>>0>=2147483647){ac=_;break}if((bB(O|0)|0)==-1){bB(m|0)|0;W=Y;break L4195}else{ac=O+_|0;break}}else{ac=_}}while(0);if((Z|0)==-1){W=Y}else{aa=ac;ab=Z;T=3252;break L4173}}}while(0);c[2759]=c[2759]|4;ad=W;T=3249}else{ad=0;T=3249}}while(0);do{if((T|0)==3249){if(S>>>0>=2147483647){break}W=bB(S|0)|0;Z=bB(0)|0;if(!((Z|0)!=-1&(W|0)!=-1&W>>>0<Z>>>0)){break}ac=Z-W|0;Z=ac>>>0>(o+40|0)>>>0;Y=Z?W:-1;if((Y|0)!=-1){aa=Z?ac:ad;ab=Y;T=3252}}}while(0);do{if((T|0)==3252){ad=(c[2756]|0)+aa|0;c[2756]=ad;if(ad>>>0>(c[2757]|0)>>>0){c[2757]=ad}ad=c[2654]|0;L4215:do{if((ad|0)==0){S=c[2652]|0;if((S|0)==0|ab>>>0<S>>>0){c[2652]=ab}c[2760]=ab;c[2761]=aa;c[2763]=0;c[2657]=c[2622];c[2656]=-1;S=0;do{Y=S<<1;ac=10632+(Y<<2)|0;c[10632+(Y+3<<2)>>2]=ac;c[10632+(Y+2<<2)>>2]=ac;S=S+1|0;}while(S>>>0<32);S=ab+8|0;if((S&7|0)==0){ae=0}else{ae=-S&7}S=aa-40-ae|0;c[2654]=ab+ae;c[2651]=S;c[ab+(ae+4)>>2]=S|1;c[ab+(aa-36)>>2]=40;c[2655]=c[2626]}else{S=11040;while(1){af=c[S>>2]|0;ag=S+4|0;ah=c[ag>>2]|0;if((ab|0)==(af+ah|0)){T=3264;break}ac=c[S+8>>2]|0;if((ac|0)==0){break}else{S=ac}}do{if((T|0)==3264){if((c[S+12>>2]&8|0)!=0){break}ac=ad;if(!(ac>>>0>=af>>>0&ac>>>0<ab>>>0)){break}c[ag>>2]=ah+aa;ac=c[2654]|0;Y=(c[2651]|0)+aa|0;Z=ac;W=ac+8|0;if((W&7|0)==0){ai=0}else{ai=-W&7}W=Y-ai|0;c[2654]=Z+ai;c[2651]=W;c[Z+(ai+4)>>2]=W|1;c[Z+(Y+4)>>2]=40;c[2655]=c[2626];break L4215}}while(0);if(ab>>>0<(c[2652]|0)>>>0){c[2652]=ab}S=ab+aa|0;Y=11040;while(1){aj=Y|0;if((c[aj>>2]|0)==(S|0)){T=3274;break}Z=c[Y+8>>2]|0;if((Z|0)==0){break}else{Y=Z}}do{if((T|0)==3274){if((c[Y+12>>2]&8|0)!=0){break}c[aj>>2]=ab;S=Y+4|0;c[S>>2]=(c[S>>2]|0)+aa;S=ab+8|0;if((S&7|0)==0){ak=0}else{ak=-S&7}S=ab+(aa+8)|0;if((S&7|0)==0){al=0}else{al=-S&7}S=ab+(al+aa)|0;Z=S;W=ak+o|0;ac=ab+W|0;_=ac;K=S-(ab+ak)-o|0;c[ab+(ak+4)>>2]=o|3;do{if((Z|0)==(c[2654]|0)){J=(c[2651]|0)+K|0;c[2651]=J;c[2654]=_;c[ab+(W+4)>>2]=J|1}else{if((Z|0)==(c[2653]|0)){J=(c[2650]|0)+K|0;c[2650]=J;c[2653]=_;c[ab+(W+4)>>2]=J|1;c[ab+(J+W)>>2]=J;break}J=aa+4|0;X=c[ab+(J+al)>>2]|0;if((X&3|0)==1){$=X&-8;V=X>>>3;L4260:do{if(X>>>0<256){U=c[ab+((al|8)+aa)>>2]|0;Q=c[ab+(aa+12+al)>>2]|0;R=10632+(V<<1<<2)|0;do{if((U|0)!=(R|0)){if(U>>>0<(c[2652]|0)>>>0){bM();return 0}if((c[U+12>>2]|0)==(Z|0)){break}bM();return 0}}while(0);if((Q|0)==(U|0)){c[2648]=c[2648]&~(1<<V);break}do{if((Q|0)==(R|0)){am=Q+8|0}else{if(Q>>>0<(c[2652]|0)>>>0){bM();return 0}m=Q+8|0;if((c[m>>2]|0)==(Z|0)){am=m;break}bM();return 0}}while(0);c[U+12>>2]=Q;c[am>>2]=U}else{R=S;m=c[ab+((al|24)+aa)>>2]|0;P=c[ab+(aa+12+al)>>2]|0;do{if((P|0)==(R|0)){O=al|16;g=ab+(J+O)|0;L=c[g>>2]|0;if((L|0)==0){e=ab+(O+aa)|0;O=c[e>>2]|0;if((O|0)==0){an=0;break}else{ao=O;ap=e}}else{ao=L;ap=g}while(1){g=ao+20|0;L=c[g>>2]|0;if((L|0)!=0){ao=L;ap=g;continue}g=ao+16|0;L=c[g>>2]|0;if((L|0)==0){break}else{ao=L;ap=g}}if(ap>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[ap>>2]=0;an=ao;break}}else{g=c[ab+((al|8)+aa)>>2]|0;if(g>>>0<(c[2652]|0)>>>0){bM();return 0}L=g+12|0;if((c[L>>2]|0)!=(R|0)){bM();return 0}e=P+8|0;if((c[e>>2]|0)==(R|0)){c[L>>2]=P;c[e>>2]=g;an=P;break}else{bM();return 0}}}while(0);if((m|0)==0){break}P=ab+(aa+28+al)|0;U=10896+(c[P>>2]<<2)|0;do{if((R|0)==(c[U>>2]|0)){c[U>>2]=an;if((an|0)!=0){break}c[2649]=c[2649]&~(1<<c[P>>2]);break L4260}else{if(m>>>0<(c[2652]|0)>>>0){bM();return 0}Q=m+16|0;if((c[Q>>2]|0)==(R|0)){c[Q>>2]=an}else{c[m+20>>2]=an}if((an|0)==0){break L4260}}}while(0);if(an>>>0<(c[2652]|0)>>>0){bM();return 0}c[an+24>>2]=m;R=al|16;P=c[ab+(R+aa)>>2]|0;do{if((P|0)!=0){if(P>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[an+16>>2]=P;c[P+24>>2]=an;break}}}while(0);P=c[ab+(J+R)>>2]|0;if((P|0)==0){break}if(P>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[an+20>>2]=P;c[P+24>>2]=an;break}}}while(0);aq=ab+(($|al)+aa)|0;ar=$+K|0}else{aq=Z;ar=K}J=aq+4|0;c[J>>2]=c[J>>2]&-2;c[ab+(W+4)>>2]=ar|1;c[ab+(ar+W)>>2]=ar;J=ar>>>3;if(ar>>>0<256){V=J<<1;X=10632+(V<<2)|0;P=c[2648]|0;m=1<<J;do{if((P&m|0)==0){c[2648]=P|m;as=X;at=10632+(V+2<<2)|0}else{J=10632+(V+2<<2)|0;U=c[J>>2]|0;if(U>>>0>=(c[2652]|0)>>>0){as=U;at=J;break}bM();return 0}}while(0);c[at>>2]=_;c[as+12>>2]=_;c[ab+(W+8)>>2]=as;c[ab+(W+12)>>2]=X;break}V=ac;m=ar>>>8;do{if((m|0)==0){au=0}else{if(ar>>>0>16777215){au=31;break}P=(m+1048320|0)>>>16&8;$=m<<P;J=($+520192|0)>>>16&4;U=$<<J;$=(U+245760|0)>>>16&2;Q=14-(J|P|$)+(U<<$>>>15)|0;au=ar>>>((Q+7|0)>>>0)&1|Q<<1}}while(0);m=10896+(au<<2)|0;c[ab+(W+28)>>2]=au;c[ab+(W+20)>>2]=0;c[ab+(W+16)>>2]=0;X=c[2649]|0;Q=1<<au;if((X&Q|0)==0){c[2649]=X|Q;c[m>>2]=V;c[ab+(W+24)>>2]=m;c[ab+(W+12)>>2]=V;c[ab+(W+8)>>2]=V;break}if((au|0)==31){av=0}else{av=25-(au>>>1)|0}Q=ar<<av;X=c[m>>2]|0;while(1){if((c[X+4>>2]&-8|0)==(ar|0)){break}aw=X+16+(Q>>>31<<2)|0;m=c[aw>>2]|0;if((m|0)==0){T=3347;break}else{Q=Q<<1;X=m}}if((T|0)==3347){if(aw>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[aw>>2]=V;c[ab+(W+24)>>2]=X;c[ab+(W+12)>>2]=V;c[ab+(W+8)>>2]=V;break}}Q=X+8|0;m=c[Q>>2]|0;$=c[2652]|0;if(X>>>0<$>>>0){bM();return 0}if(m>>>0<$>>>0){bM();return 0}else{c[m+12>>2]=V;c[Q>>2]=V;c[ab+(W+8)>>2]=m;c[ab+(W+12)>>2]=X;c[ab+(W+24)>>2]=0;break}}}while(0);n=ab+(ak|8)|0;return n|0}}while(0);Y=ad;W=11040;while(1){ax=c[W>>2]|0;if(ax>>>0<=Y>>>0){ay=c[W+4>>2]|0;az=ax+ay|0;if(az>>>0>Y>>>0){break}}W=c[W+8>>2]|0}W=ax+(ay-39)|0;if((W&7|0)==0){aA=0}else{aA=-W&7}W=ax+(ay-47+aA)|0;ac=W>>>0<(ad+16|0)>>>0?Y:W;W=ac+8|0;_=ab+8|0;if((_&7|0)==0){aB=0}else{aB=-_&7}_=aa-40-aB|0;c[2654]=ab+aB;c[2651]=_;c[ab+(aB+4)>>2]=_|1;c[ab+(aa-36)>>2]=40;c[2655]=c[2626];c[ac+4>>2]=27;c[W>>2]=c[2760];c[W+4>>2]=c[11044>>2];c[W+8>>2]=c[11048>>2];c[W+12>>2]=c[11052>>2];c[2760]=ab;c[2761]=aa;c[2763]=0;c[2762]=W;W=ac+28|0;c[W>>2]=7;if((ac+32|0)>>>0<az>>>0){_=W;while(1){W=_+4|0;c[W>>2]=7;if((_+8|0)>>>0<az>>>0){_=W}else{break}}}if((ac|0)==(Y|0)){break}_=ac-ad|0;W=Y+(_+4)|0;c[W>>2]=c[W>>2]&-2;c[ad+4>>2]=_|1;c[Y+_>>2]=_;W=_>>>3;if(_>>>0<256){K=W<<1;Z=10632+(K<<2)|0;S=c[2648]|0;m=1<<W;do{if((S&m|0)==0){c[2648]=S|m;aC=Z;aD=10632+(K+2<<2)|0}else{W=10632+(K+2<<2)|0;Q=c[W>>2]|0;if(Q>>>0>=(c[2652]|0)>>>0){aC=Q;aD=W;break}bM();return 0}}while(0);c[aD>>2]=ad;c[aC+12>>2]=ad;c[ad+8>>2]=aC;c[ad+12>>2]=Z;break}K=ad;m=_>>>8;do{if((m|0)==0){aE=0}else{if(_>>>0>16777215){aE=31;break}S=(m+1048320|0)>>>16&8;Y=m<<S;ac=(Y+520192|0)>>>16&4;W=Y<<ac;Y=(W+245760|0)>>>16&2;Q=14-(ac|S|Y)+(W<<Y>>>15)|0;aE=_>>>((Q+7|0)>>>0)&1|Q<<1}}while(0);m=10896+(aE<<2)|0;c[ad+28>>2]=aE;c[ad+20>>2]=0;c[ad+16>>2]=0;Z=c[2649]|0;Q=1<<aE;if((Z&Q|0)==0){c[2649]=Z|Q;c[m>>2]=K;c[ad+24>>2]=m;c[ad+12>>2]=ad;c[ad+8>>2]=ad;break}if((aE|0)==31){aF=0}else{aF=25-(aE>>>1)|0}Q=_<<aF;Z=c[m>>2]|0;while(1){if((c[Z+4>>2]&-8|0)==(_|0)){break}aG=Z+16+(Q>>>31<<2)|0;m=c[aG>>2]|0;if((m|0)==0){T=3382;break}else{Q=Q<<1;Z=m}}if((T|0)==3382){if(aG>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[aG>>2]=K;c[ad+24>>2]=Z;c[ad+12>>2]=ad;c[ad+8>>2]=ad;break}}Q=Z+8|0;_=c[Q>>2]|0;m=c[2652]|0;if(Z>>>0<m>>>0){bM();return 0}if(_>>>0<m>>>0){bM();return 0}else{c[_+12>>2]=K;c[Q>>2]=K;c[ad+8>>2]=_;c[ad+12>>2]=Z;c[ad+24>>2]=0;break}}}while(0);ad=c[2651]|0;if(ad>>>0<=o>>>0){break}_=ad-o|0;c[2651]=_;ad=c[2654]|0;Q=ad;c[2654]=Q+o;c[Q+(o+4)>>2]=_|1;c[ad+4>>2]=o|3;n=ad+8|0;return n|0}}while(0);c[(bE()|0)>>2]=12;n=0;return n|0}function jV(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;if((a|0)==0){return}b=a-8|0;d=b;e=c[2652]|0;if(b>>>0<e>>>0){bM()}f=c[a-4>>2]|0;g=f&3;if((g|0)==1){bM()}h=f&-8;i=a+(h-8)|0;j=i;L10:do{if((f&1|0)==0){k=c[b>>2]|0;if((g|0)==0){return}l=-8-k|0;m=a+l|0;n=m;o=k+h|0;if(m>>>0<e>>>0){bM()}if((n|0)==(c[2653]|0)){p=a+(h-4)|0;if((c[p>>2]&3|0)!=3){q=n;r=o;break}c[2650]=o;c[p>>2]=c[p>>2]&-2;c[a+(l+4)>>2]=o|1;c[i>>2]=o;return}p=k>>>3;if(k>>>0<256){k=c[a+(l+8)>>2]|0;s=c[a+(l+12)>>2]|0;t=10632+(p<<1<<2)|0;do{if((k|0)!=(t|0)){if(k>>>0<e>>>0){bM()}if((c[k+12>>2]|0)==(n|0)){break}bM()}}while(0);if((s|0)==(k|0)){c[2648]=c[2648]&~(1<<p);q=n;r=o;break}do{if((s|0)==(t|0)){u=s+8|0}else{if(s>>>0<e>>>0){bM()}v=s+8|0;if((c[v>>2]|0)==(n|0)){u=v;break}bM()}}while(0);c[k+12>>2]=s;c[u>>2]=k;q=n;r=o;break}t=m;p=c[a+(l+24)>>2]|0;v=c[a+(l+12)>>2]|0;do{if((v|0)==(t|0)){w=a+(l+20)|0;x=c[w>>2]|0;if((x|0)==0){y=a+(l+16)|0;z=c[y>>2]|0;if((z|0)==0){A=0;break}else{B=z;C=y}}else{B=x;C=w}while(1){w=B+20|0;x=c[w>>2]|0;if((x|0)!=0){B=x;C=w;continue}w=B+16|0;x=c[w>>2]|0;if((x|0)==0){break}else{B=x;C=w}}if(C>>>0<e>>>0){bM()}else{c[C>>2]=0;A=B;break}}else{w=c[a+(l+8)>>2]|0;if(w>>>0<e>>>0){bM()}x=w+12|0;if((c[x>>2]|0)!=(t|0)){bM()}y=v+8|0;if((c[y>>2]|0)==(t|0)){c[x>>2]=v;c[y>>2]=w;A=v;break}else{bM()}}}while(0);if((p|0)==0){q=n;r=o;break}v=a+(l+28)|0;m=10896+(c[v>>2]<<2)|0;do{if((t|0)==(c[m>>2]|0)){c[m>>2]=A;if((A|0)!=0){break}c[2649]=c[2649]&~(1<<c[v>>2]);q=n;r=o;break L10}else{if(p>>>0<(c[2652]|0)>>>0){bM()}k=p+16|0;if((c[k>>2]|0)==(t|0)){c[k>>2]=A}else{c[p+20>>2]=A}if((A|0)==0){q=n;r=o;break L10}}}while(0);if(A>>>0<(c[2652]|0)>>>0){bM()}c[A+24>>2]=p;t=c[a+(l+16)>>2]|0;do{if((t|0)!=0){if(t>>>0<(c[2652]|0)>>>0){bM()}else{c[A+16>>2]=t;c[t+24>>2]=A;break}}}while(0);t=c[a+(l+20)>>2]|0;if((t|0)==0){q=n;r=o;break}if(t>>>0<(c[2652]|0)>>>0){bM()}else{c[A+20>>2]=t;c[t+24>>2]=A;q=n;r=o;break}}else{q=d;r=h}}while(0);d=q;if(d>>>0>=i>>>0){bM()}A=a+(h-4)|0;e=c[A>>2]|0;if((e&1|0)==0){bM()}do{if((e&2|0)==0){if((j|0)==(c[2654]|0)){B=(c[2651]|0)+r|0;c[2651]=B;c[2654]=q;c[q+4>>2]=B|1;if((q|0)!=(c[2653]|0)){return}c[2653]=0;c[2650]=0;return}if((j|0)==(c[2653]|0)){B=(c[2650]|0)+r|0;c[2650]=B;c[2653]=q;c[q+4>>2]=B|1;c[d+B>>2]=B;return}B=(e&-8)+r|0;C=e>>>3;L112:do{if(e>>>0<256){u=c[a+h>>2]|0;g=c[a+(h|4)>>2]|0;b=10632+(C<<1<<2)|0;do{if((u|0)!=(b|0)){if(u>>>0<(c[2652]|0)>>>0){bM()}if((c[u+12>>2]|0)==(j|0)){break}bM()}}while(0);if((g|0)==(u|0)){c[2648]=c[2648]&~(1<<C);break}do{if((g|0)==(b|0)){D=g+8|0}else{if(g>>>0<(c[2652]|0)>>>0){bM()}f=g+8|0;if((c[f>>2]|0)==(j|0)){D=f;break}bM()}}while(0);c[u+12>>2]=g;c[D>>2]=u}else{b=i;f=c[a+(h+16)>>2]|0;t=c[a+(h|4)>>2]|0;do{if((t|0)==(b|0)){p=a+(h+12)|0;v=c[p>>2]|0;if((v|0)==0){m=a+(h+8)|0;k=c[m>>2]|0;if((k|0)==0){E=0;break}else{F=k;G=m}}else{F=v;G=p}while(1){p=F+20|0;v=c[p>>2]|0;if((v|0)!=0){F=v;G=p;continue}p=F+16|0;v=c[p>>2]|0;if((v|0)==0){break}else{F=v;G=p}}if(G>>>0<(c[2652]|0)>>>0){bM()}else{c[G>>2]=0;E=F;break}}else{p=c[a+h>>2]|0;if(p>>>0<(c[2652]|0)>>>0){bM()}v=p+12|0;if((c[v>>2]|0)!=(b|0)){bM()}m=t+8|0;if((c[m>>2]|0)==(b|0)){c[v>>2]=t;c[m>>2]=p;E=t;break}else{bM()}}}while(0);if((f|0)==0){break}t=a+(h+20)|0;u=10896+(c[t>>2]<<2)|0;do{if((b|0)==(c[u>>2]|0)){c[u>>2]=E;if((E|0)!=0){break}c[2649]=c[2649]&~(1<<c[t>>2]);break L112}else{if(f>>>0<(c[2652]|0)>>>0){bM()}g=f+16|0;if((c[g>>2]|0)==(b|0)){c[g>>2]=E}else{c[f+20>>2]=E}if((E|0)==0){break L112}}}while(0);if(E>>>0<(c[2652]|0)>>>0){bM()}c[E+24>>2]=f;b=c[a+(h+8)>>2]|0;do{if((b|0)!=0){if(b>>>0<(c[2652]|0)>>>0){bM()}else{c[E+16>>2]=b;c[b+24>>2]=E;break}}}while(0);b=c[a+(h+12)>>2]|0;if((b|0)==0){break}if(b>>>0<(c[2652]|0)>>>0){bM()}else{c[E+20>>2]=b;c[b+24>>2]=E;break}}}while(0);c[q+4>>2]=B|1;c[d+B>>2]=B;if((q|0)!=(c[2653]|0)){H=B;break}c[2650]=B;return}else{c[A>>2]=e&-2;c[q+4>>2]=r|1;c[d+r>>2]=r;H=r}}while(0);r=H>>>3;if(H>>>0<256){d=r<<1;e=10632+(d<<2)|0;A=c[2648]|0;E=1<<r;do{if((A&E|0)==0){c[2648]=A|E;I=e;J=10632+(d+2<<2)|0}else{r=10632+(d+2<<2)|0;h=c[r>>2]|0;if(h>>>0>=(c[2652]|0)>>>0){I=h;J=r;break}bM()}}while(0);c[J>>2]=q;c[I+12>>2]=q;c[q+8>>2]=I;c[q+12>>2]=e;return}e=q;I=H>>>8;do{if((I|0)==0){K=0}else{if(H>>>0>16777215){K=31;break}J=(I+1048320|0)>>>16&8;d=I<<J;E=(d+520192|0)>>>16&4;A=d<<E;d=(A+245760|0)>>>16&2;r=14-(E|J|d)+(A<<d>>>15)|0;K=H>>>((r+7|0)>>>0)&1|r<<1}}while(0);I=10896+(K<<2)|0;c[q+28>>2]=K;c[q+20>>2]=0;c[q+16>>2]=0;r=c[2649]|0;d=1<<K;do{if((r&d|0)==0){c[2649]=r|d;c[I>>2]=e;c[q+24>>2]=I;c[q+12>>2]=q;c[q+8>>2]=q}else{if((K|0)==31){L=0}else{L=25-(K>>>1)|0}A=H<<L;J=c[I>>2]|0;while(1){if((c[J+4>>2]&-8|0)==(H|0)){break}M=J+16+(A>>>31<<2)|0;E=c[M>>2]|0;if((E|0)==0){N=129;break}else{A=A<<1;J=E}}if((N|0)==129){if(M>>>0<(c[2652]|0)>>>0){bM()}else{c[M>>2]=e;c[q+24>>2]=J;c[q+12>>2]=q;c[q+8>>2]=q;break}}A=J+8|0;B=c[A>>2]|0;E=c[2652]|0;if(J>>>0<E>>>0){bM()}if(B>>>0<E>>>0){bM()}else{c[B+12>>2]=e;c[A>>2]=e;c[q+8>>2]=B;c[q+12>>2]=J;c[q+24>>2]=0;break}}}while(0);q=(c[2656]|0)-1|0;c[2656]=q;if((q|0)==0){O=11048}else{return}while(1){q=c[O>>2]|0;if((q|0)==0){break}else{O=q+8|0}}c[2656]=-1;return}function jW(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0;if((a|0)==0){d=jU(b)|0;return d|0}if(b>>>0>4294967231){c[(bE()|0)>>2]=12;d=0;return d|0}if(b>>>0<11){e=16}else{e=b+11&-8}f=jX(a-8|0,e)|0;if((f|0)!=0){d=f+8|0;return d|0}f=jU(b)|0;if((f|0)==0){d=0;return d|0}e=c[a-4>>2]|0;g=(e&-8)-((e&3|0)==0?8:4)|0;e=g>>>0<b>>>0?g:b;j$(f|0,a|0,e)|0;jV(a);d=f;return d|0}function jX(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;d=a+4|0;e=c[d>>2]|0;f=e&-8;g=a;h=g+f|0;i=h;j=c[2652]|0;if(g>>>0<j>>>0){bM();return 0}k=e&3;if(!((k|0)!=1&g>>>0<h>>>0)){bM();return 0}l=g+(f|4)|0;m=c[l>>2]|0;if((m&1|0)==0){bM();return 0}if((k|0)==0){if(b>>>0<256){n=0;return n|0}do{if(f>>>0>=(b+4|0)>>>0){if((f-b|0)>>>0>c[2624]<<1>>>0){break}else{n=a}return n|0}}while(0);n=0;return n|0}if(f>>>0>=b>>>0){k=f-b|0;if(k>>>0<=15){n=a;return n|0}c[d>>2]=e&1|b|2;c[g+(b+4)>>2]=k|3;c[l>>2]=c[l>>2]|1;jY(g+b|0,k);n=a;return n|0}if((i|0)==(c[2654]|0)){k=(c[2651]|0)+f|0;if(k>>>0<=b>>>0){n=0;return n|0}l=k-b|0;c[d>>2]=e&1|b|2;c[g+(b+4)>>2]=l|1;c[2654]=g+b;c[2651]=l;n=a;return n|0}if((i|0)==(c[2653]|0)){l=(c[2650]|0)+f|0;if(l>>>0<b>>>0){n=0;return n|0}k=l-b|0;if(k>>>0>15){c[d>>2]=e&1|b|2;c[g+(b+4)>>2]=k|1;c[g+l>>2]=k;o=g+(l+4)|0;c[o>>2]=c[o>>2]&-2;p=g+b|0;q=k}else{c[d>>2]=e&1|l|2;e=g+(l+4)|0;c[e>>2]=c[e>>2]|1;p=0;q=0}c[2650]=q;c[2653]=p;n=a;return n|0}if((m&2|0)!=0){n=0;return n|0}p=(m&-8)+f|0;if(p>>>0<b>>>0){n=0;return n|0}q=p-b|0;e=m>>>3;L299:do{if(m>>>0<256){l=c[g+(f+8)>>2]|0;k=c[g+(f+12)>>2]|0;o=10632+(e<<1<<2)|0;do{if((l|0)!=(o|0)){if(l>>>0<j>>>0){bM();return 0}if((c[l+12>>2]|0)==(i|0)){break}bM();return 0}}while(0);if((k|0)==(l|0)){c[2648]=c[2648]&~(1<<e);break}do{if((k|0)==(o|0)){r=k+8|0}else{if(k>>>0<j>>>0){bM();return 0}s=k+8|0;if((c[s>>2]|0)==(i|0)){r=s;break}bM();return 0}}while(0);c[l+12>>2]=k;c[r>>2]=l}else{o=h;s=c[g+(f+24)>>2]|0;t=c[g+(f+12)>>2]|0;do{if((t|0)==(o|0)){u=g+(f+20)|0;v=c[u>>2]|0;if((v|0)==0){w=g+(f+16)|0;x=c[w>>2]|0;if((x|0)==0){y=0;break}else{z=x;A=w}}else{z=v;A=u}while(1){u=z+20|0;v=c[u>>2]|0;if((v|0)!=0){z=v;A=u;continue}u=z+16|0;v=c[u>>2]|0;if((v|0)==0){break}else{z=v;A=u}}if(A>>>0<j>>>0){bM();return 0}else{c[A>>2]=0;y=z;break}}else{u=c[g+(f+8)>>2]|0;if(u>>>0<j>>>0){bM();return 0}v=u+12|0;if((c[v>>2]|0)!=(o|0)){bM();return 0}w=t+8|0;if((c[w>>2]|0)==(o|0)){c[v>>2]=t;c[w>>2]=u;y=t;break}else{bM();return 0}}}while(0);if((s|0)==0){break}t=g+(f+28)|0;l=10896+(c[t>>2]<<2)|0;do{if((o|0)==(c[l>>2]|0)){c[l>>2]=y;if((y|0)!=0){break}c[2649]=c[2649]&~(1<<c[t>>2]);break L299}else{if(s>>>0<(c[2652]|0)>>>0){bM();return 0}k=s+16|0;if((c[k>>2]|0)==(o|0)){c[k>>2]=y}else{c[s+20>>2]=y}if((y|0)==0){break L299}}}while(0);if(y>>>0<(c[2652]|0)>>>0){bM();return 0}c[y+24>>2]=s;o=c[g+(f+16)>>2]|0;do{if((o|0)!=0){if(o>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[y+16>>2]=o;c[o+24>>2]=y;break}}}while(0);o=c[g+(f+20)>>2]|0;if((o|0)==0){break}if(o>>>0<(c[2652]|0)>>>0){bM();return 0}else{c[y+20>>2]=o;c[o+24>>2]=y;break}}}while(0);if(q>>>0<16){c[d>>2]=p|c[d>>2]&1|2;y=g+(p|4)|0;c[y>>2]=c[y>>2]|1;n=a;return n|0}else{c[d>>2]=c[d>>2]&1|b|2;c[g+(b+4)>>2]=q|3;d=g+(p|4)|0;c[d>>2]=c[d>>2]|1;jY(g+b|0,q);n=a;return n|0}return 0}function jY(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0;d=a;e=d+b|0;f=e;g=c[a+4>>2]|0;L375:do{if((g&1|0)==0){h=c[a>>2]|0;if((g&3|0)==0){return}i=d+(-h|0)|0;j=i;k=h+b|0;l=c[2652]|0;if(i>>>0<l>>>0){bM()}if((j|0)==(c[2653]|0)){m=d+(b+4)|0;if((c[m>>2]&3|0)!=3){n=j;o=k;break}c[2650]=k;c[m>>2]=c[m>>2]&-2;c[d+(4-h)>>2]=k|1;c[e>>2]=k;return}m=h>>>3;if(h>>>0<256){p=c[d+(8-h)>>2]|0;q=c[d+(12-h)>>2]|0;r=10632+(m<<1<<2)|0;do{if((p|0)!=(r|0)){if(p>>>0<l>>>0){bM()}if((c[p+12>>2]|0)==(j|0)){break}bM()}}while(0);if((q|0)==(p|0)){c[2648]=c[2648]&~(1<<m);n=j;o=k;break}do{if((q|0)==(r|0)){s=q+8|0}else{if(q>>>0<l>>>0){bM()}t=q+8|0;if((c[t>>2]|0)==(j|0)){s=t;break}bM()}}while(0);c[p+12>>2]=q;c[s>>2]=p;n=j;o=k;break}r=i;m=c[d+(24-h)>>2]|0;t=c[d+(12-h)>>2]|0;do{if((t|0)==(r|0)){u=16-h|0;v=d+(u+4)|0;w=c[v>>2]|0;if((w|0)==0){x=d+u|0;u=c[x>>2]|0;if((u|0)==0){y=0;break}else{z=u;A=x}}else{z=w;A=v}while(1){v=z+20|0;w=c[v>>2]|0;if((w|0)!=0){z=w;A=v;continue}v=z+16|0;w=c[v>>2]|0;if((w|0)==0){break}else{z=w;A=v}}if(A>>>0<l>>>0){bM()}else{c[A>>2]=0;y=z;break}}else{v=c[d+(8-h)>>2]|0;if(v>>>0<l>>>0){bM()}w=v+12|0;if((c[w>>2]|0)!=(r|0)){bM()}x=t+8|0;if((c[x>>2]|0)==(r|0)){c[w>>2]=t;c[x>>2]=v;y=t;break}else{bM()}}}while(0);if((m|0)==0){n=j;o=k;break}t=d+(28-h)|0;l=10896+(c[t>>2]<<2)|0;do{if((r|0)==(c[l>>2]|0)){c[l>>2]=y;if((y|0)!=0){break}c[2649]=c[2649]&~(1<<c[t>>2]);n=j;o=k;break L375}else{if(m>>>0<(c[2652]|0)>>>0){bM()}i=m+16|0;if((c[i>>2]|0)==(r|0)){c[i>>2]=y}else{c[m+20>>2]=y}if((y|0)==0){n=j;o=k;break L375}}}while(0);if(y>>>0<(c[2652]|0)>>>0){bM()}c[y+24>>2]=m;r=16-h|0;t=c[d+r>>2]|0;do{if((t|0)!=0){if(t>>>0<(c[2652]|0)>>>0){bM()}else{c[y+16>>2]=t;c[t+24>>2]=y;break}}}while(0);t=c[d+(r+4)>>2]|0;if((t|0)==0){n=j;o=k;break}if(t>>>0<(c[2652]|0)>>>0){bM()}else{c[y+20>>2]=t;c[t+24>>2]=y;n=j;o=k;break}}else{n=a;o=b}}while(0);a=c[2652]|0;if(e>>>0<a>>>0){bM()}y=d+(b+4)|0;z=c[y>>2]|0;do{if((z&2|0)==0){if((f|0)==(c[2654]|0)){A=(c[2651]|0)+o|0;c[2651]=A;c[2654]=n;c[n+4>>2]=A|1;if((n|0)!=(c[2653]|0)){return}c[2653]=0;c[2650]=0;return}if((f|0)==(c[2653]|0)){A=(c[2650]|0)+o|0;c[2650]=A;c[2653]=n;c[n+4>>2]=A|1;c[n+A>>2]=A;return}A=(z&-8)+o|0;s=z>>>3;L474:do{if(z>>>0<256){g=c[d+(b+8)>>2]|0;t=c[d+(b+12)>>2]|0;h=10632+(s<<1<<2)|0;do{if((g|0)!=(h|0)){if(g>>>0<a>>>0){bM()}if((c[g+12>>2]|0)==(f|0)){break}bM()}}while(0);if((t|0)==(g|0)){c[2648]=c[2648]&~(1<<s);break}do{if((t|0)==(h|0)){B=t+8|0}else{if(t>>>0<a>>>0){bM()}m=t+8|0;if((c[m>>2]|0)==(f|0)){B=m;break}bM()}}while(0);c[g+12>>2]=t;c[B>>2]=g}else{h=e;m=c[d+(b+24)>>2]|0;l=c[d+(b+12)>>2]|0;do{if((l|0)==(h|0)){i=d+(b+20)|0;p=c[i>>2]|0;if((p|0)==0){q=d+(b+16)|0;v=c[q>>2]|0;if((v|0)==0){C=0;break}else{D=v;E=q}}else{D=p;E=i}while(1){i=D+20|0;p=c[i>>2]|0;if((p|0)!=0){D=p;E=i;continue}i=D+16|0;p=c[i>>2]|0;if((p|0)==0){break}else{D=p;E=i}}if(E>>>0<a>>>0){bM()}else{c[E>>2]=0;C=D;break}}else{i=c[d+(b+8)>>2]|0;if(i>>>0<a>>>0){bM()}p=i+12|0;if((c[p>>2]|0)!=(h|0)){bM()}q=l+8|0;if((c[q>>2]|0)==(h|0)){c[p>>2]=l;c[q>>2]=i;C=l;break}else{bM()}}}while(0);if((m|0)==0){break}l=d+(b+28)|0;g=10896+(c[l>>2]<<2)|0;do{if((h|0)==(c[g>>2]|0)){c[g>>2]=C;if((C|0)!=0){break}c[2649]=c[2649]&~(1<<c[l>>2]);break L474}else{if(m>>>0<(c[2652]|0)>>>0){bM()}t=m+16|0;if((c[t>>2]|0)==(h|0)){c[t>>2]=C}else{c[m+20>>2]=C}if((C|0)==0){break L474}}}while(0);if(C>>>0<(c[2652]|0)>>>0){bM()}c[C+24>>2]=m;h=c[d+(b+16)>>2]|0;do{if((h|0)!=0){if(h>>>0<(c[2652]|0)>>>0){bM()}else{c[C+16>>2]=h;c[h+24>>2]=C;break}}}while(0);h=c[d+(b+20)>>2]|0;if((h|0)==0){break}if(h>>>0<(c[2652]|0)>>>0){bM()}else{c[C+20>>2]=h;c[h+24>>2]=C;break}}}while(0);c[n+4>>2]=A|1;c[n+A>>2]=A;if((n|0)!=(c[2653]|0)){F=A;break}c[2650]=A;return}else{c[y>>2]=z&-2;c[n+4>>2]=o|1;c[n+o>>2]=o;F=o}}while(0);o=F>>>3;if(F>>>0<256){z=o<<1;y=10632+(z<<2)|0;C=c[2648]|0;b=1<<o;do{if((C&b|0)==0){c[2648]=C|b;G=y;H=10632+(z+2<<2)|0}else{o=10632+(z+2<<2)|0;d=c[o>>2]|0;if(d>>>0>=(c[2652]|0)>>>0){G=d;H=o;break}bM()}}while(0);c[H>>2]=n;c[G+12>>2]=n;c[n+8>>2]=G;c[n+12>>2]=y;return}y=n;G=F>>>8;do{if((G|0)==0){I=0}else{if(F>>>0>16777215){I=31;break}H=(G+1048320|0)>>>16&8;z=G<<H;b=(z+520192|0)>>>16&4;C=z<<b;z=(C+245760|0)>>>16&2;o=14-(b|H|z)+(C<<z>>>15)|0;I=F>>>((o+7|0)>>>0)&1|o<<1}}while(0);G=10896+(I<<2)|0;c[n+28>>2]=I;c[n+20>>2]=0;c[n+16>>2]=0;o=c[2649]|0;z=1<<I;if((o&z|0)==0){c[2649]=o|z;c[G>>2]=y;c[n+24>>2]=G;c[n+12>>2]=n;c[n+8>>2]=n;return}if((I|0)==31){J=0}else{J=25-(I>>>1)|0}I=F<<J;J=c[G>>2]|0;while(1){if((c[J+4>>2]&-8|0)==(F|0)){break}K=J+16+(I>>>31<<2)|0;G=c[K>>2]|0;if((G|0)==0){L=409;break}else{I=I<<1;J=G}}if((L|0)==409){if(K>>>0<(c[2652]|0)>>>0){bM()}c[K>>2]=y;c[n+24>>2]=J;c[n+12>>2]=n;c[n+8>>2]=n;return}K=J+8|0;L=c[K>>2]|0;I=c[2652]|0;if(J>>>0<I>>>0){bM()}if(L>>>0<I>>>0){bM()}c[L+12>>2]=y;c[K>>2]=y;c[n+8>>2]=L;c[n+12>>2]=J;c[n+24>>2]=0;return}function jZ(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0,x=0,y=0,z=0.0,A=0.0,B=0,C=0,D=0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0.0,O=0,P=0,Q=0.0,R=0.0,S=0.0;e=b;while(1){f=e+1|0;if((aB(a[e]|0)|0)==0){break}else{e=f}}g=a[e]|0;if((g<<24>>24|0)==43){i=f;j=0}else if((g<<24>>24|0)==45){i=f;j=1}else{i=e;j=0}e=-1;f=0;g=i;while(1){k=a[g]|0;if(((k<<24>>24)-48|0)>>>0<10){l=e}else{if(k<<24>>24!=46|(e|0)>-1){break}else{l=f}}e=l;f=f+1|0;g=g+1|0}l=g+(-f|0)|0;i=(e|0)<0;m=((i^1)<<31>>31)+f|0;n=(m|0)>18;o=(n?-18:-m|0)+(i?f:e)|0;e=n?18:m;do{if((e|0)==0){p=b;q=0.0}else{if((e|0)>9){m=l;n=e;f=0;while(1){i=a[m]|0;r=m+1|0;if(i<<24>>24==46){s=a[r]|0;t=m+2|0}else{s=i;t=r}u=(f*10|0)-48+(s<<24>>24)|0;r=n-1|0;if((r|0)>9){m=t;n=r;f=u}else{break}}v=+(u|0)*1.0e9;w=9;x=t;y=457}else{if((e|0)>0){v=0.0;w=e;x=l;y=457}else{z=0.0;A=0.0}}if((y|0)==457){f=x;n=w;m=0;while(1){r=a[f]|0;i=f+1|0;if(r<<24>>24==46){B=a[i]|0;C=f+2|0}else{B=r;C=i}D=(m*10|0)-48+(B<<24>>24)|0;i=n-1|0;if((i|0)>0){f=C;n=i;m=D}else{break}}z=+(D|0);A=v}E=A+z;do{if((k<<24>>24|0)==69|(k<<24>>24|0)==101){m=g+1|0;n=a[m]|0;if((n<<24>>24|0)==45){F=g+2|0;G=1}else if((n<<24>>24|0)==43){F=g+2|0;G=0}else{F=m;G=0}m=a[F]|0;if(((m<<24>>24)-48|0)>>>0<10){H=F;I=0;J=m}else{K=0;L=F;M=G;break}while(1){m=(I*10|0)-48+(J<<24>>24)|0;n=H+1|0;f=a[n]|0;if(((f<<24>>24)-48|0)>>>0<10){H=n;I=m;J=f}else{K=m;L=n;M=G;break}}}else{K=0;L=g;M=0}}while(0);n=o+((M|0)==0?K:-K|0)|0;m=(n|0)<0?-n|0:n;if((m|0)>511){c[(bE()|0)>>2]=34;N=1.0;O=360;P=511;y=474}else{if((m|0)==0){Q=1.0}else{N=1.0;O=360;P=m;y=474}}if((y|0)==474){while(1){y=0;if((P&1|0)==0){R=N}else{R=N*+h[O>>3]}m=P>>1;if((m|0)==0){Q=R;break}else{N=R;O=O+8|0;P=m;y=474}}}if((n|0)>-1){p=L;q=E*Q;break}else{p=L;q=E/Q;break}}}while(0);if((d|0)!=0){c[d>>2]=p}if((j|0)==0){S=q;return+S}S=-0.0-q;return+S}function j_(b){b=b|0;var c=0;c=b;while(a[c]|0){c=c+1|0}return c-b|0}function j$(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=b|0;if((b&3)==(d&3)){while(b&3){if((e|0)==0)return f|0;a[b]=a[d]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b]=a[d]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function j0(a,b,d){a=a|0;b=b|0;d=d|0;var e=0;t=t+1|0;c[a>>2]=t;while((e|0)<40){if((c[d+(e<<2)>>2]|0)==0){c[d+(e<<2)>>2]=t;c[d+((e<<2)+4)>>2]=b;c[d+((e<<2)+8)>>2]=0;return 0}e=e+2|0}ba(116);ba(111);ba(111);ba(32);ba(109);ba(97);ba(110);ba(121);ba(32);ba(115);ba(101);ba(116);ba(106);ba(109);ba(112);ba(115);ba(32);ba(105);ba(110);ba(32);ba(97);ba(32);ba(102);ba(117);ba(110);ba(99);ba(116);ba(105);ba(111);ba(110);ba(32);ba(99);ba(97);ba(108);ba(108);ba(44);ba(32);ba(98);ba(117);ba(105);ba(108);ba(100);ba(32);ba(119);ba(105);ba(116);ba(104);ba(32);ba(97);ba(32);ba(104);ba(105);ba(103);ba(104);ba(101);ba(114);ba(32);ba(118);ba(97);ba(108);ba(117);ba(101);ba(32);ba(102);ba(111);ba(114);ba(32);ba(77);ba(65);ba(88);ba(95);ba(83);ba(69);ba(84);ba(74);ba(77);ba(80);ba(83);ba(10);ab(0);return 0}function j1(a,b){a=a|0;b=b|0;var d=0,e=0;while((d|0)<20){e=c[b+(d<<2)>>2]|0;if((e|0)==0)break;if((e|0)==(a|0)){return c[b+((d<<2)+4)>>2]|0}d=d+2|0}return 0}function j2(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=b+e|0;if((e|0)>=20){d=d&255;e=b&3;g=d|d<<8|d<<16|d<<24;h=f&~3;if(e){e=b+4-e|0;while((b|0)<(e|0)){a[b]=d;b=b+1|0}}while((b|0)<(h|0)){c[b>>2]=g;b=b+4|0}}while((b|0)<(f|0)){a[b]=d;b=b+1|0}}function j3(b,c,d){b=b|0;c=c|0;d=d|0;var e=0,f=0;while((e|0)<(d|0)){a[b+e|0]=f?0:a[c+e|0]|0;f=f?1:(a[c+e|0]|0)==0;e=e+1|0}return b|0}function j4(b,c){b=b|0;c=c|0;var d=0,e=0;d=b+(j_(b)|0)|0;do{a[d+e|0]=a[c+e|0];e=e+1|0}while(a[c+(e-1)|0]|0);return b|0}function j5(a,b,c){a=a|0;b=b|0;c=c|0;var e=0,f=0,g=0;while((e|0)<(c|0)){f=d[a+e|0]|0;g=d[b+e|0]|0;if((f|0)!=(g|0))return((f|0)>(g|0)?1:-1)|0;e=e+1|0}return 0}function j6(a){a=a|0;if((a|0)<65)return a|0;if((a|0)>90)return a|0;return a-65+97|0}function j7(a,b){a=a|0;b=b|0;return cd[a&1023](b|0)|0}function j8(a){a=a|0;return ag(0,a|0)|0}function j9(a){a=a|0;return ag(1,a|0)|0}function ka(a){a=a|0;return ag(2,a|0)|0}function kb(a){a=a|0;return ag(3,a|0)|0}function kc(a){a=a|0;return ag(4,a|0)|0}function kd(a){a=a|0;return ag(5,a|0)|0}function ke(a){a=a|0;return ag(6,a|0)|0}function kf(a){a=a|0;return ag(7,a|0)|0}function kg(a){a=a|0;return ag(8,a|0)|0}function kh(a){a=a|0;return ag(9,a|0)|0}function ki(a){a=a|0;return ag(10,a|0)|0}function kj(a){a=a|0;return ag(11,a|0)|0}function kk(a){a=a|0;return ag(12,a|0)|0}function kl(a){a=a|0;return ag(13,a|0)|0}function km(a){a=a|0;return ag(14,a|0)|0}function kn(a){a=a|0;return ag(15,a|0)|0}function ko(a){a=a|0;return ag(16,a|0)|0}function kp(a){a=a|0;return ag(17,a|0)|0}function kq(a){a=a|0;return ag(18,a|0)|0}function kr(a){a=a|0;return ag(19,a|0)|0}function ks(a){a=a|0;return ag(20,a|0)|0}function kt(a){a=a|0;return ag(21,a|0)|0}function ku(a){a=a|0;return ag(22,a|0)|0}function kv(a){a=a|0;return ag(23,a|0)|0}function kw(a){a=a|0;return ag(24,a|0)|0}function kx(a){a=a|0;return ag(25,a|0)|0}function ky(a){a=a|0;return ag(26,a|0)|0}function kz(a){a=a|0;return ag(27,a|0)|0}function kA(a){a=a|0;return ag(28,a|0)|0}function kB(a){a=a|0;return ag(29,a|0)|0}function kC(a){a=a|0;return ag(30,a|0)|0}function kD(a){a=a|0;return ag(31,a|0)|0}function kE(a){a=a|0;return ag(32,a|0)|0}function kF(a){a=a|0;return ag(33,a|0)|0}function kG(a){a=a|0;return ag(34,a|0)|0}function kH(a){a=a|0;return ag(35,a|0)|0}function kI(a){a=a|0;return ag(36,a|0)|0}function kJ(a){a=a|0;return ag(37,a|0)|0}function kK(a){a=a|0;return ag(38,a|0)|0}function kL(a){a=a|0;return ag(39,a|0)|0}function kM(a){a=a|0;return ag(40,a|0)|0}function kN(a){a=a|0;return ag(41,a|0)|0}function kO(a){a=a|0;return ag(42,a|0)|0}function kP(a){a=a|0;return ag(43,a|0)|0}function kQ(a){a=a|0;return ag(44,a|0)|0}function kR(a){a=a|0;return ag(45,a|0)|0}function kS(a){a=a|0;return ag(46,a|0)|0}function kT(a){a=a|0;return ag(47,a|0)|0}function kU(a){a=a|0;return ag(48,a|0)|0}function kV(a){a=a|0;return ag(49,a|0)|0}function kW(a){a=a|0;return ag(50,a|0)|0}function kX(a){a=a|0;return ag(51,a|0)|0}function kY(a){a=a|0;return ag(52,a|0)|0}function kZ(a){a=a|0;return ag(53,a|0)|0}function k_(a){a=a|0;return ag(54,a|0)|0}function k$(a){a=a|0;return ag(55,a|0)|0}function k0(a){a=a|0;return ag(56,a|0)|0}function k1(a){a=a|0;return ag(57,a|0)|0}function k2(a){a=a|0;return ag(58,a|0)|0}function k3(a){a=a|0;return ag(59,a|0)|0}function k4(a){a=a|0;return ag(60,a|0)|0}function k5(a){a=a|0;return ag(61,a|0)|0}function k6(a){a=a|0;return ag(62,a|0)|0}function k7(a){a=a|0;return ag(63,a|0)|0}function k8(a){a=a|0;return ag(64,a|0)|0}function k9(a){a=a|0;return ag(65,a|0)|0}function la(a){a=a|0;return ag(66,a|0)|0}function lb(a){a=a|0;return ag(67,a|0)|0}function lc(a){a=a|0;return ag(68,a|0)|0}function ld(a){a=a|0;return ag(69,a|0)|0}function le(a){a=a|0;return ag(70,a|0)|0}function lf(a){a=a|0;return ag(71,a|0)|0}function lg(a){a=a|0;return ag(72,a|0)|0}function lh(a){a=a|0;return ag(73,a|0)|0}function li(a){a=a|0;return ag(74,a|0)|0}function lj(a){a=a|0;return ag(75,a|0)|0}function lk(a){a=a|0;return ag(76,a|0)|0}function ll(a){a=a|0;return ag(77,a|0)|0}function lm(a){a=a|0;return ag(78,a|0)|0}function ln(a){a=a|0;return ag(79,a|0)|0}function lo(a){a=a|0;return ag(80,a|0)|0}function lp(a){a=a|0;return ag(81,a|0)|0}function lq(a){a=a|0;return ag(82,a|0)|0}function lr(a){a=a|0;return ag(83,a|0)|0}function ls(a){a=a|0;return ag(84,a|0)|0}function lt(a){a=a|0;return ag(85,a|0)|0}function lu(a){a=a|0;return ag(86,a|0)|0}function lv(a){a=a|0;return ag(87,a|0)|0}function lw(a){a=a|0;return ag(88,a|0)|0}function lx(a){a=a|0;return ag(89,a|0)|0}function ly(a){a=a|0;return ag(90,a|0)|0}function lz(a){a=a|0;return ag(91,a|0)|0}function lA(a){a=a|0;return ag(92,a|0)|0}function lB(a){a=a|0;return ag(93,a|0)|0}function lC(a){a=a|0;return ag(94,a|0)|0}function lD(a){a=a|0;return ag(95,a|0)|0}function lE(a){a=a|0;return ag(96,a|0)|0}function lF(a){a=a|0;return ag(97,a|0)|0}function lG(a){a=a|0;return ag(98,a|0)|0}function lH(a){a=a|0;return ag(99,a|0)|0}function lI(a){a=a|0;return ag(100,a|0)|0}function lJ(a){a=a|0;return ag(101,a|0)|0}function lK(a){a=a|0;return ag(102,a|0)|0}function lL(a){a=a|0;return ag(103,a|0)|0}function lM(a){a=a|0;return ag(104,a|0)|0}function lN(a){a=a|0;return ag(105,a|0)|0}function lO(a){a=a|0;return ag(106,a|0)|0}function lP(a){a=a|0;return ag(107,a|0)|0}function lQ(a){a=a|0;return ag(108,a|0)|0}function lR(a){a=a|0;return ag(109,a|0)|0}function lS(a){a=a|0;return ag(110,a|0)|0}function lT(a){a=a|0;return ag(111,a|0)|0}function lU(a){a=a|0;return ag(112,a|0)|0}function lV(a){a=a|0;return ag(113,a|0)|0}function lW(a){a=a|0;return ag(114,a|0)|0}function lX(a){a=a|0;return ag(115,a|0)|0}function lY(a){a=a|0;return ag(116,a|0)|0}function lZ(a){a=a|0;return ag(117,a|0)|0}function l_(a){a=a|0;return ag(118,a|0)|0}function l$(a){a=a|0;return ag(119,a|0)|0}function l0(a){a=a|0;return ag(120,a|0)|0}function l1(a){a=a|0;return ag(121,a|0)|0}function l2(a){a=a|0;return ag(122,a|0)|0}function l3(a){a=a|0;return ag(123,a|0)|0}function l4(a){a=a|0;return ag(124,a|0)|0}function l5(a,b){a=a|0;b=b|0;ce[a&255](b|0)}function l6(a){a=a|0;ag(0,a|0)}function l7(a){a=a|0;ag(1,a|0)}function l8(a){a=a|0;ag(2,a|0)}function l9(a){a=a|0;ag(3,a|0)}function ma(a){a=a|0;ag(4,a|0)}function mb(a){a=a|0;ag(5,a|0)}function mc(a){a=a|0;ag(6,a|0)}function md(a){a=a|0;ag(7,a|0)}function me(a){a=a|0;ag(8,a|0)}function mf(a){a=a|0;ag(9,a|0)}function mg(a){a=a|0;ag(10,a|0)}function mh(a){a=a|0;ag(11,a|0)}function mi(a){a=a|0;ag(12,a|0)}function mj(a){a=a|0;ag(13,a|0)}function mk(a){a=a|0;ag(14,a|0)}function ml(a){a=a|0;ag(15,a|0)}function mm(a){a=a|0;ag(16,a|0)}function mn(a){a=a|0;ag(17,a|0)}function mo(a){a=a|0;ag(18,a|0)}function mp(a){a=a|0;ag(19,a|0)}function mq(a){a=a|0;ag(20,a|0)}function mr(a){a=a|0;ag(21,a|0)}function ms(a){a=a|0;ag(22,a|0)}function mt(a){a=a|0;ag(23,a|0)}function mu(a){a=a|0;ag(24,a|0)}function mv(a){a=a|0;ag(25,a|0)}function mw(a){a=a|0;ag(26,a|0)}function mx(a){a=a|0;ag(27,a|0)}function my(a){a=a|0;ag(28,a|0)}function mz(a){a=a|0;ag(29,a|0)}function mA(a){a=a|0;ag(30,a|0)}function mB(a){a=a|0;ag(31,a|0)}function mC(a){a=a|0;ag(32,a|0)}function mD(a){a=a|0;ag(33,a|0)}function mE(a){a=a|0;ag(34,a|0)}function mF(a){a=a|0;ag(35,a|0)}function mG(a){a=a|0;ag(36,a|0)}function mH(a){a=a|0;ag(37,a|0)}function mI(a){a=a|0;ag(38,a|0)}function mJ(a){a=a|0;ag(39,a|0)}function mK(a){a=a|0;ag(40,a|0)}function mL(a){a=a|0;ag(41,a|0)}function mM(a){a=a|0;ag(42,a|0)}function mN(a){a=a|0;ag(43,a|0)}function mO(a){a=a|0;ag(44,a|0)}function mP(a){a=a|0;ag(45,a|0)}function mQ(a){a=a|0;ag(46,a|0)}function mR(a){a=a|0;ag(47,a|0)}function mS(a){a=a|0;ag(48,a|0)}function mT(a){a=a|0;ag(49,a|0)}function mU(a){a=a|0;ag(50,a|0)}function mV(a){a=a|0;ag(51,a|0)}function mW(a){a=a|0;ag(52,a|0)}function mX(a){a=a|0;ag(53,a|0)}function mY(a){a=a|0;ag(54,a|0)}function mZ(a){a=a|0;ag(55,a|0)}function m_(a){a=a|0;ag(56,a|0)}function m$(a){a=a|0;ag(57,a|0)}function m0(a){a=a|0;ag(58,a|0)}function m1(a){a=a|0;ag(59,a|0)}function m2(a){a=a|0;ag(60,a|0)}function m3(a){a=a|0;ag(61,a|0)}function m4(a){a=a|0;ag(62,a|0)}function m5(a){a=a|0;ag(63,a|0)}function m6(a){a=a|0;ag(64,a|0)}function m7(a){a=a|0;ag(65,a|0)}function m8(a){a=a|0;ag(66,a|0)}function m9(a){a=a|0;ag(67,a|0)}function na(a){a=a|0;ag(68,a|0)}function nb(a){a=a|0;ag(69,a|0)}function nc(a){a=a|0;ag(70,a|0)}function nd(a){a=a|0;ag(71,a|0)}function ne(a){a=a|0;ag(72,a|0)}function nf(a){a=a|0;ag(73,a|0)}function ng(a){a=a|0;ag(74,a|0)}function nh(a){a=a|0;ag(75,a|0)}function ni(a){a=a|0;ag(76,a|0)}function nj(a){a=a|0;ag(77,a|0)}function nk(a){a=a|0;ag(78,a|0)}function nl(a){a=a|0;ag(79,a|0)}function nm(a){a=a|0;ag(80,a|0)}function nn(a){a=a|0;ag(81,a|0)}function no(a){a=a|0;ag(82,a|0)}function np(a){a=a|0;ag(83,a|0)}function nq(a){a=a|0;ag(84,a|0)}function nr(a){a=a|0;ag(85,a|0)}function ns(a){a=a|0;ag(86,a|0)}function nt(a){a=a|0;ag(87,a|0)}function nu(a){a=a|0;ag(88,a|0)}function nv(a){a=a|0;ag(89,a|0)}function nw(a){a=a|0;ag(90,a|0)}function nx(a){a=a|0;ag(91,a|0)}function ny(a){a=a|0;ag(92,a|0)}function nz(a){a=a|0;ag(93,a|0)}function nA(a){a=a|0;ag(94,a|0)}function nB(a){a=a|0;ag(95,a|0)}function nC(a){a=a|0;ag(96,a|0)}function nD(a){a=a|0;ag(97,a|0)}function nE(a){a=a|0;ag(98,a|0)}function nF(a){a=a|0;ag(99,a|0)}function nG(a){a=a|0;ag(100,a|0)}function nH(a){a=a|0;ag(101,a|0)}function nI(a){a=a|0;ag(102,a|0)}function nJ(a){a=a|0;ag(103,a|0)}function nK(a){a=a|0;ag(104,a|0)}function nL(a){a=a|0;ag(105,a|0)}function nM(a){a=a|0;ag(106,a|0)}function nN(a){a=a|0;ag(107,a|0)}function nO(a){a=a|0;ag(108,a|0)}function nP(a){a=a|0;ag(109,a|0)}function nQ(a){a=a|0;ag(110,a|0)}function nR(a){a=a|0;ag(111,a|0)}function nS(a){a=a|0;ag(112,a|0)}function nT(a){a=a|0;ag(113,a|0)}function nU(a){a=a|0;ag(114,a|0)}function nV(a){a=a|0;ag(115,a|0)}function nW(a){a=a|0;ag(116,a|0)}function nX(a){a=a|0;ag(117,a|0)}function nY(a){a=a|0;ag(118,a|0)}function nZ(a){a=a|0;ag(119,a|0)}function n_(a){a=a|0;ag(120,a|0)}function n$(a){a=a|0;ag(121,a|0)}function n0(a){a=a|0;ag(122,a|0)}function n1(a){a=a|0;ag(123,a|0)}function n2(a){a=a|0;ag(124,a|0)}function n3(a,b,c){a=a|0;b=b|0;c=c|0;cf[a&511](b|0,c|0)}function n4(a,b){a=a|0;b=b|0;ag(0,a|0,b|0)}function n5(a,b){a=a|0;b=b|0;ag(1,a|0,b|0)}function n6(a,b){a=a|0;b=b|0;ag(2,a|0,b|0)}function n7(a,b){a=a|0;b=b|0;ag(3,a|0,b|0)}function n8(a,b){a=a|0;b=b|0;ag(4,a|0,b|0)}function n9(a,b){a=a|0;b=b|0;ag(5,a|0,b|0)}function oa(a,b){a=a|0;b=b|0;ag(6,a|0,b|0)}function ob(a,b){a=a|0;b=b|0;ag(7,a|0,b|0)}function oc(a,b){a=a|0;b=b|0;ag(8,a|0,b|0)}function od(a,b){a=a|0;b=b|0;ag(9,a|0,b|0)}function oe(a,b){a=a|0;b=b|0;ag(10,a|0,b|0)}function of(a,b){a=a|0;b=b|0;ag(11,a|0,b|0)}function og(a,b){a=a|0;b=b|0;ag(12,a|0,b|0)}function oh(a,b){a=a|0;b=b|0;ag(13,a|0,b|0)}function oi(a,b){a=a|0;b=b|0;ag(14,a|0,b|0)}function oj(a,b){a=a|0;b=b|0;ag(15,a|0,b|0)}function ok(a,b){a=a|0;b=b|0;ag(16,a|0,b|0)}function ol(a,b){a=a|0;b=b|0;ag(17,a|0,b|0)}function om(a,b){a=a|0;b=b|0;ag(18,a|0,b|0)}function on(a,b){a=a|0;b=b|0;ag(19,a|0,b|0)}function oo(a,b){a=a|0;b=b|0;ag(20,a|0,b|0)}function op(a,b){a=a|0;b=b|0;ag(21,a|0,b|0)}function oq(a,b){a=a|0;b=b|0;ag(22,a|0,b|0)}function or(a,b){a=a|0;b=b|0;ag(23,a|0,b|0)}function os(a,b){a=a|0;b=b|0;ag(24,a|0,b|0)}function ot(a,b){a=a|0;b=b|0;ag(25,a|0,b|0)}function ou(a,b){a=a|0;b=b|0;ag(26,a|0,b|0)}function ov(a,b){a=a|0;b=b|0;ag(27,a|0,b|0)}function ow(a,b){a=a|0;b=b|0;ag(28,a|0,b|0)}function ox(a,b){a=a|0;b=b|0;ag(29,a|0,b|0)}function oy(a,b){a=a|0;b=b|0;ag(30,a|0,b|0)}function oz(a,b){a=a|0;b=b|0;ag(31,a|0,b|0)}function oA(a,b){a=a|0;b=b|0;ag(32,a|0,b|0)}function oB(a,b){a=a|0;b=b|0;ag(33,a|0,b|0)}function oC(a,b){a=a|0;b=b|0;ag(34,a|0,b|0)}function oD(a,b){a=a|0;b=b|0;ag(35,a|0,b|0)}function oE(a,b){a=a|0;b=b|0;ag(36,a|0,b|0)}function oF(a,b){a=a|0;b=b|0;ag(37,a|0,b|0)}function oG(a,b){a=a|0;b=b|0;ag(38,a|0,b|0)}function oH(a,b){a=a|0;b=b|0;ag(39,a|0,b|0)}function oI(a,b){a=a|0;b=b|0;ag(40,a|0,b|0)}function oJ(a,b){a=a|0;b=b|0;ag(41,a|0,b|0)}function oK(a,b){a=a|0;b=b|0;ag(42,a|0,b|0)}function oL(a,b){a=a|0;b=b|0;ag(43,a|0,b|0)}function oM(a,b){a=a|0;b=b|0;ag(44,a|0,b|0)}function oN(a,b){a=a|0;b=b|0;ag(45,a|0,b|0)}function oO(a,b){a=a|0;b=b|0;ag(46,a|0,b|0)}function oP(a,b){a=a|0;b=b|0;ag(47,a|0,b|0)}function oQ(a,b){a=a|0;b=b|0;ag(48,a|0,b|0)}function oR(a,b){a=a|0;b=b|0;ag(49,a|0,b|0)}function oS(a,b){a=a|0;b=b|0;ag(50,a|0,b|0)}function oT(a,b){a=a|0;b=b|0;ag(51,a|0,b|0)}function oU(a,b){a=a|0;b=b|0;ag(52,a|0,b|0)}function oV(a,b){a=a|0;b=b|0;ag(53,a|0,b|0)}function oW(a,b){a=a|0;b=b|0;ag(54,a|0,b|0)}function oX(a,b){a=a|0;b=b|0;ag(55,a|0,b|0)}function oY(a,b){a=a|0;b=b|0;ag(56,a|0,b|0)}function oZ(a,b){a=a|0;b=b|0;ag(57,a|0,b|0)}function o_(a,b){a=a|0;b=b|0;ag(58,a|0,b|0)}function o$(a,b){a=a|0;b=b|0;ag(59,a|0,b|0)}function o0(a,b){a=a|0;b=b|0;ag(60,a|0,b|0)}function o1(a,b){a=a|0;b=b|0;ag(61,a|0,b|0)}function o2(a,b){a=a|0;b=b|0;ag(62,a|0,b|0)}function o3(a,b){a=a|0;b=b|0;ag(63,a|0,b|0)}function o4(a,b){a=a|0;b=b|0;ag(64,a|0,b|0)}function o5(a,b){a=a|0;b=b|0;ag(65,a|0,b|0)}function o6(a,b){a=a|0;b=b|0;ag(66,a|0,b|0)}function o7(a,b){a=a|0;b=b|0;ag(67,a|0,b|0)}function o8(a,b){a=a|0;b=b|0;ag(68,a|0,b|0)}function o9(a,b){a=a|0;b=b|0;ag(69,a|0,b|0)}function pa(a,b){a=a|0;b=b|0;ag(70,a|0,b|0)}function pb(a,b){a=a|0;b=b|0;ag(71,a|0,b|0)}function pc(a,b){a=a|0;b=b|0;ag(72,a|0,b|0)}function pd(a,b){a=a|0;b=b|0;ag(73,a|0,b|0)}function pe(a,b){a=a|0;b=b|0;ag(74,a|0,b|0)}function pf(a,b){a=a|0;b=b|0;ag(75,a|0,b|0)}function pg(a,b){a=a|0;b=b|0;ag(76,a|0,b|0)}function ph(a,b){a=a|0;b=b|0;ag(77,a|0,b|0)}function pi(a,b){a=a|0;b=b|0;ag(78,a|0,b|0)}function pj(a,b){a=a|0;b=b|0;ag(79,a|0,b|0)}function pk(a,b){a=a|0;b=b|0;ag(80,a|0,b|0)}function pl(a,b){a=a|0;b=b|0;ag(81,a|0,b|0)}function pm(a,b){a=a|0;b=b|0;ag(82,a|0,b|0)}function pn(a,b){a=a|0;b=b|0;ag(83,a|0,b|0)}function po(a,b){a=a|0;b=b|0;ag(84,a|0,b|0)}function pp(a,b){a=a|0;b=b|0;ag(85,a|0,b|0)}function pq(a,b){a=a|0;b=b|0;ag(86,a|0,b|0)}function pr(a,b){a=a|0;b=b|0;ag(87,a|0,b|0)}function ps(a,b){a=a|0;b=b|0;ag(88,a|0,b|0)}function pt(a,b){a=a|0;b=b|0;ag(89,a|0,b|0)}function pu(a,b){a=a|0;b=b|0;ag(90,a|0,b|0)}function pv(a,b){a=a|0;b=b|0;ag(91,a|0,b|0)}function pw(a,b){a=a|0;b=b|0;ag(92,a|0,b|0)}function px(a,b){a=a|0;b=b|0;ag(93,a|0,b|0)}function py(a,b){a=a|0;b=b|0;ag(94,a|0,b|0)}function pz(a,b){a=a|0;b=b|0;ag(95,a|0,b|0)}function pA(a,b){a=a|0;b=b|0;ag(96,a|0,b|0)}function pB(a,b){a=a|0;b=b|0;ag(97,a|0,b|0)}function pC(a,b){a=a|0;b=b|0;ag(98,a|0,b|0)}function pD(a,b){a=a|0;b=b|0;ag(99,a|0,b|0)}function pE(a,b){a=a|0;b=b|0;ag(100,a|0,b|0)}function pF(a,b){a=a|0;b=b|0;ag(101,a|0,b|0)}function pG(a,b){a=a|0;b=b|0;ag(102,a|0,b|0)}function pH(a,b){a=a|0;b=b|0;ag(103,a|0,b|0)}function pI(a,b){a=a|0;b=b|0;ag(104,a|0,b|0)}function pJ(a,b){a=a|0;b=b|0;ag(105,a|0,b|0)}function pK(a,b){a=a|0;b=b|0;ag(106,a|0,b|0)}function pL(a,b){a=a|0;b=b|0;ag(107,a|0,b|0)}function pM(a,b){a=a|0;b=b|0;ag(108,a|0,b|0)}function pN(a,b){a=a|0;b=b|0;ag(109,a|0,b|0)}function pO(a,b){a=a|0;b=b|0;ag(110,a|0,b|0)}function pP(a,b){a=a|0;b=b|0;ag(111,a|0,b|0)}function pQ(a,b){a=a|0;b=b|0;ag(112,a|0,b|0)}function pR(a,b){a=a|0;b=b|0;ag(113,a|0,b|0)}function pS(a,b){a=a|0;b=b|0;ag(114,a|0,b|0)}function pT(a,b){a=a|0;b=b|0;ag(115,a|0,b|0)}function pU(a,b){a=a|0;b=b|0;ag(116,a|0,b|0)}function pV(a,b){a=a|0;b=b|0;ag(117,a|0,b|0)}function pW(a,b){a=a|0;b=b|0;ag(118,a|0,b|0)}function pX(a,b){a=a|0;b=b|0;ag(119,a|0,b|0)}function pY(a,b){a=a|0;b=b|0;ag(120,a|0,b|0)}function pZ(a,b){a=a|0;b=b|0;ag(121,a|0,b|0)}function p_(a,b){a=a|0;b=b|0;ag(122,a|0,b|0)}function p$(a,b){a=a|0;b=b|0;ag(123,a|0,b|0)}function p0(a,b){a=a|0;b=b|0;ag(124,a|0,b|0)}function p1(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return cg[a&511](b|0,c|0,d|0,e|0)|0}function p2(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(0,a|0,b|0,c|0,d|0)|0}function p3(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(1,a|0,b|0,c|0,d|0)|0}function p4(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(2,a|0,b|0,c|0,d|0)|0}function p5(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(3,a|0,b|0,c|0,d|0)|0}function p6(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(4,a|0,b|0,c|0,d|0)|0}function p7(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(5,a|0,b|0,c|0,d|0)|0}function p8(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(6,a|0,b|0,c|0,d|0)|0}function p9(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(7,a|0,b|0,c|0,d|0)|0}function qa(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(8,a|0,b|0,c|0,d|0)|0}function qb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(9,a|0,b|0,c|0,d|0)|0}function qc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(10,a|0,b|0,c|0,d|0)|0}function qd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(11,a|0,b|0,c|0,d|0)|0}function qe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(12,a|0,b|0,c|0,d|0)|0}function qf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(13,a|0,b|0,c|0,d|0)|0}function qg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(14,a|0,b|0,c|0,d|0)|0}function qh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(15,a|0,b|0,c|0,d|0)|0}function qi(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(16,a|0,b|0,c|0,d|0)|0}function qj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(17,a|0,b|0,c|0,d|0)|0}function qk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(18,a|0,b|0,c|0,d|0)|0}function ql(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(19,a|0,b|0,c|0,d|0)|0}function qm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(20,a|0,b|0,c|0,d|0)|0}function qn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(21,a|0,b|0,c|0,d|0)|0}function qo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(22,a|0,b|0,c|0,d|0)|0}function qp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(23,a|0,b|0,c|0,d|0)|0}function qq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(24,a|0,b|0,c|0,d|0)|0}function qr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(25,a|0,b|0,c|0,d|0)|0}function qs(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(26,a|0,b|0,c|0,d|0)|0}function qt(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(27,a|0,b|0,c|0,d|0)|0}function qu(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(28,a|0,b|0,c|0,d|0)|0}function qv(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(29,a|0,b|0,c|0,d|0)|0}function qw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(30,a|0,b|0,c|0,d|0)|0}function qx(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(31,a|0,b|0,c|0,d|0)|0}function qy(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(32,a|0,b|0,c|0,d|0)|0}function qz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(33,a|0,b|0,c|0,d|0)|0}function qA(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(34,a|0,b|0,c|0,d|0)|0}function qB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(35,a|0,b|0,c|0,d|0)|0}function qC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(36,a|0,b|0,c|0,d|0)|0}function qD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(37,a|0,b|0,c|0,d|0)|0}function qE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(38,a|0,b|0,c|0,d|0)|0}function qF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(39,a|0,b|0,c|0,d|0)|0}function qG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(40,a|0,b|0,c|0,d|0)|0}function qH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(41,a|0,b|0,c|0,d|0)|0}function qI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(42,a|0,b|0,c|0,d|0)|0}function qJ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(43,a|0,b|0,c|0,d|0)|0}function qK(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(44,a|0,b|0,c|0,d|0)|0}function qL(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(45,a|0,b|0,c|0,d|0)|0}function qM(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(46,a|0,b|0,c|0,d|0)|0}function qN(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(47,a|0,b|0,c|0,d|0)|0}function qO(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(48,a|0,b|0,c|0,d|0)|0}function qP(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(49,a|0,b|0,c|0,d|0)|0}function qQ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(50,a|0,b|0,c|0,d|0)|0}function qR(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(51,a|0,b|0,c|0,d|0)|0}function qS(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(52,a|0,b|0,c|0,d|0)|0}function qT(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(53,a|0,b|0,c|0,d|0)|0}function qU(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(54,a|0,b|0,c|0,d|0)|0}function qV(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(55,a|0,b|0,c|0,d|0)|0}function qW(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(56,a|0,b|0,c|0,d|0)|0}function qX(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(57,a|0,b|0,c|0,d|0)|0}function qY(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(58,a|0,b|0,c|0,d|0)|0}function qZ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(59,a|0,b|0,c|0,d|0)|0}function q_(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(60,a|0,b|0,c|0,d|0)|0}function q$(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(61,a|0,b|0,c|0,d|0)|0}function q0(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(62,a|0,b|0,c|0,d|0)|0}function q1(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(63,a|0,b|0,c|0,d|0)|0}function q2(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(64,a|0,b|0,c|0,d|0)|0}function q3(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(65,a|0,b|0,c|0,d|0)|0}function q4(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(66,a|0,b|0,c|0,d|0)|0}function q5(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(67,a|0,b|0,c|0,d|0)|0}function q6(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(68,a|0,b|0,c|0,d|0)|0}function q7(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(69,a|0,b|0,c|0,d|0)|0}function q8(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(70,a|0,b|0,c|0,d|0)|0}function q9(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(71,a|0,b|0,c|0,d|0)|0}function ra(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(72,a|0,b|0,c|0,d|0)|0}function rb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(73,a|0,b|0,c|0,d|0)|0}function rc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(74,a|0,b|0,c|0,d|0)|0}function rd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(75,a|0,b|0,c|0,d|0)|0}function re(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(76,a|0,b|0,c|0,d|0)|0}function rf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(77,a|0,b|0,c|0,d|0)|0}function rg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(78,a|0,b|0,c|0,d|0)|0}function rh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(79,a|0,b|0,c|0,d|0)|0}function ri(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(80,a|0,b|0,c|0,d|0)|0}function rj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(81,a|0,b|0,c|0,d|0)|0}function rk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(82,a|0,b|0,c|0,d|0)|0}function rl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(83,a|0,b|0,c|0,d|0)|0}function rm(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(84,a|0,b|0,c|0,d|0)|0}function rn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(85,a|0,b|0,c|0,d|0)|0}function ro(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(86,a|0,b|0,c|0,d|0)|0}function rp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(87,a|0,b|0,c|0,d|0)|0}function rq(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(88,a|0,b|0,c|0,d|0)|0}function rr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(89,a|0,b|0,c|0,d|0)|0}function rs(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(90,a|0,b|0,c|0,d|0)|0}function rt(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(91,a|0,b|0,c|0,d|0)|0}function ru(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(92,a|0,b|0,c|0,d|0)|0}function rv(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(93,a|0,b|0,c|0,d|0)|0}function rw(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(94,a|0,b|0,c|0,d|0)|0}function rx(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(95,a|0,b|0,c|0,d|0)|0}function ry(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(96,a|0,b|0,c|0,d|0)|0}function rz(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(97,a|0,b|0,c|0,d|0)|0}function rA(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(98,a|0,b|0,c|0,d|0)|0}function rB(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(99,a|0,b|0,c|0,d|0)|0}function rC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(100,a|0,b|0,c|0,d|0)|0}function rD(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(101,a|0,b|0,c|0,d|0)|0}function rE(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(102,a|0,b|0,c|0,d|0)|0}function rF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(103,a|0,b|0,c|0,d|0)|0}function rG(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(104,a|0,b|0,c|0,d|0)|0}function rH(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(105,a|0,b|0,c|0,d|0)|0}function rI(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(106,a|0,b|0,c|0,d|0)|0}function rJ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(107,a|0,b|0,c|0,d|0)|0}function rK(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(108,a|0,b|0,c|0,d|0)|0}function rL(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(109,a|0,b|0,c|0,d|0)|0}function rM(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(110,a|0,b|0,c|0,d|0)|0}function rN(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(111,a|0,b|0,c|0,d|0)|0}function rO(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(112,a|0,b|0,c|0,d|0)|0}function rP(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(113,a|0,b|0,c|0,d|0)|0}function rQ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(114,a|0,b|0,c|0,d|0)|0}function rR(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(115,a|0,b|0,c|0,d|0)|0}function rS(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(116,a|0,b|0,c|0,d|0)|0}function rT(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(117,a|0,b|0,c|0,d|0)|0}function rU(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(118,a|0,b|0,c|0,d|0)|0}function rV(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(119,a|0,b|0,c|0,d|0)|0}function rW(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(120,a|0,b|0,c|0,d|0)|0}function rX(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(121,a|0,b|0,c|0,d|0)|0}function rY(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(122,a|0,b|0,c|0,d|0)|0}function rZ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(123,a|0,b|0,c|0,d|0)|0}function r_(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ag(124,a|0,b|0,c|0,d|0)|0}function r$(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return ch[a&511](b|0,c|0,d|0)|0}function r0(a,b,c){a=a|0;b=b|0;c=c|0;return ag(0,a|0,b|0,c|0)|0}function r1(a,b,c){a=a|0;b=b|0;c=c|0;return ag(1,a|0,b|0,c|0)|0}function r2(a,b,c){a=a|0;b=b|0;c=c|0;return ag(2,a|0,b|0,c|0)|0}function r3(a,b,c){a=a|0;b=b|0;c=c|0;return ag(3,a|0,b|0,c|0)|0}function r4(a,b,c){a=a|0;b=b|0;c=c|0;return ag(4,a|0,b|0,c|0)|0}function r5(a,b,c){a=a|0;b=b|0;c=c|0;return ag(5,a|0,b|0,c|0)|0}function r6(a,b,c){a=a|0;b=b|0;c=c|0;return ag(6,a|0,b|0,c|0)|0}function r7(a,b,c){a=a|0;b=b|0;c=c|0;return ag(7,a|0,b|0,c|0)|0}function r8(a,b,c){a=a|0;b=b|0;c=c|0;return ag(8,a|0,b|0,c|0)|0}function r9(a,b,c){a=a|0;b=b|0;c=c|0;return ag(9,a|0,b|0,c|0)|0}function sa(a,b,c){a=a|0;b=b|0;c=c|0;return ag(10,a|0,b|0,c|0)|0}function sb(a,b,c){a=a|0;b=b|0;c=c|0;return ag(11,a|0,b|0,c|0)|0}function sc(a,b,c){a=a|0;b=b|0;c=c|0;return ag(12,a|0,b|0,c|0)|0}function sd(a,b,c){a=a|0;b=b|0;c=c|0;return ag(13,a|0,b|0,c|0)|0}function se(a,b,c){a=a|0;b=b|0;c=c|0;return ag(14,a|0,b|0,c|0)|0}function sf(a,b,c){a=a|0;b=b|0;c=c|0;return ag(15,a|0,b|0,c|0)|0}function sg(a,b,c){a=a|0;b=b|0;c=c|0;return ag(16,a|0,b|0,c|0)|0}function sh(a,b,c){a=a|0;b=b|0;c=c|0;return ag(17,a|0,b|0,c|0)|0}function si(a,b,c){a=a|0;b=b|0;c=c|0;return ag(18,a|0,b|0,c|0)|0}function sj(a,b,c){a=a|0;b=b|0;c=c|0;return ag(19,a|0,b|0,c|0)|0}function sk(a,b,c){a=a|0;b=b|0;c=c|0;return ag(20,a|0,b|0,c|0)|0}function sl(a,b,c){a=a|0;b=b|0;c=c|0;return ag(21,a|0,b|0,c|0)|0}function sm(a,b,c){a=a|0;b=b|0;c=c|0;return ag(22,a|0,b|0,c|0)|0}function sn(a,b,c){a=a|0;b=b|0;c=c|0;return ag(23,a|0,b|0,c|0)|0}function so(a,b,c){a=a|0;b=b|0;c=c|0;return ag(24,a|0,b|0,c|0)|0}function sp(a,b,c){a=a|0;b=b|0;c=c|0;return ag(25,a|0,b|0,c|0)|0}function sq(a,b,c){a=a|0;b=b|0;c=c|0;return ag(26,a|0,b|0,c|0)|0}function sr(a,b,c){a=a|0;b=b|0;c=c|0;return ag(27,a|0,b|0,c|0)|0}function ss(a,b,c){a=a|0;b=b|0;c=c|0;return ag(28,a|0,b|0,c|0)|0}function st(a,b,c){a=a|0;b=b|0;c=c|0;return ag(29,a|0,b|0,c|0)|0}function su(a,b,c){a=a|0;b=b|0;c=c|0;return ag(30,a|0,b|0,c|0)|0}function sv(a,b,c){a=a|0;b=b|0;c=c|0;return ag(31,a|0,b|0,c|0)|0}function sw(a,b,c){a=a|0;b=b|0;c=c|0;return ag(32,a|0,b|0,c|0)|0}function sx(a,b,c){a=a|0;b=b|0;c=c|0;return ag(33,a|0,b|0,c|0)|0}function sy(a,b,c){a=a|0;b=b|0;c=c|0;return ag(34,a|0,b|0,c|0)|0}function sz(a,b,c){a=a|0;b=b|0;c=c|0;return ag(35,a|0,b|0,c|0)|0}function sA(a,b,c){a=a|0;b=b|0;c=c|0;return ag(36,a|0,b|0,c|0)|0}function sB(a,b,c){a=a|0;b=b|0;c=c|0;return ag(37,a|0,b|0,c|0)|0}function sC(a,b,c){a=a|0;b=b|0;c=c|0;return ag(38,a|0,b|0,c|0)|0}function sD(a,b,c){a=a|0;b=b|0;c=c|0;return ag(39,a|0,b|0,c|0)|0}function sE(a,b,c){a=a|0;b=b|0;c=c|0;return ag(40,a|0,b|0,c|0)|0}function sF(a,b,c){a=a|0;b=b|0;c=c|0;return ag(41,a|0,b|0,c|0)|0}function sG(a,b,c){a=a|0;b=b|0;c=c|0;return ag(42,a|0,b|0,c|0)|0}function sH(a,b,c){a=a|0;b=b|0;c=c|0;return ag(43,a|0,b|0,c|0)|0}function sI(a,b,c){a=a|0;b=b|0;c=c|0;return ag(44,a|0,b|0,c|0)|0}function sJ(a,b,c){a=a|0;b=b|0;c=c|0;return ag(45,a|0,b|0,c|0)|0}function sK(a,b,c){a=a|0;b=b|0;c=c|0;return ag(46,a|0,b|0,c|0)|0}function sL(a,b,c){a=a|0;b=b|0;c=c|0;return ag(47,a|0,b|0,c|0)|0}function sM(a,b,c){a=a|0;b=b|0;c=c|0;return ag(48,a|0,b|0,c|0)|0}function sN(a,b,c){a=a|0;b=b|0;c=c|0;return ag(49,a|0,b|0,c|0)|0}function sO(a,b,c){a=a|0;b=b|0;c=c|0;return ag(50,a|0,b|0,c|0)|0}function sP(a,b,c){a=a|0;b=b|0;c=c|0;return ag(51,a|0,b|0,c|0)|0}function sQ(a,b,c){a=a|0;b=b|0;c=c|0;return ag(52,a|0,b|0,c|0)|0}function sR(a,b,c){a=a|0;b=b|0;c=c|0;return ag(53,a|0,b|0,c|0)|0}function sS(a,b,c){a=a|0;b=b|0;c=c|0;return ag(54,a|0,b|0,c|0)|0}function sT(a,b,c){a=a|0;b=b|0;c=c|0;return ag(55,a|0,b|0,c|0)|0}function sU(a,b,c){a=a|0;b=b|0;c=c|0;return ag(56,a|0,b|0,c|0)|0}function sV(a,b,c){a=a|0;b=b|0;c=c|0;return ag(57,a|0,b|0,c|0)|0}function sW(a,b,c){a=a|0;b=b|0;c=c|0;return ag(58,a|0,b|0,c|0)|0}function sX(a,b,c){a=a|0;b=b|0;c=c|0;return ag(59,a|0,b|0,c|0)|0}function sY(a,b,c){a=a|0;b=b|0;c=c|0;return ag(60,a|0,b|0,c|0)|0}function sZ(a,b,c){a=a|0;b=b|0;c=c|0;return ag(61,a|0,b|0,c|0)|0}function s_(a,b,c){a=a|0;b=b|0;c=c|0;return ag(62,a|0,b|0,c|0)|0}function s$(a,b,c){a=a|0;b=b|0;c=c|0;return ag(63,a|0,b|0,c|0)|0}function s0(a,b,c){a=a|0;b=b|0;c=c|0;return ag(64,a|0,b|0,c|0)|0}function s1(a,b,c){a=a|0;b=b|0;c=c|0;return ag(65,a|0,b|0,c|0)|0}function s2(a,b,c){a=a|0;b=b|0;c=c|0;return ag(66,a|0,b|0,c|0)|0}function s3(a,b,c){a=a|0;b=b|0;c=c|0;return ag(67,a|0,b|0,c|0)|0}function s4(a,b,c){a=a|0;b=b|0;c=c|0;return ag(68,a|0,b|0,c|0)|0}function s5(a,b,c){a=a|0;b=b|0;c=c|0;return ag(69,a|0,b|0,c|0)|0}function s6(a,b,c){a=a|0;b=b|0;c=c|0;return ag(70,a|0,b|0,c|0)|0}function s7(a,b,c){a=a|0;b=b|0;c=c|0;return ag(71,a|0,b|0,c|0)|0}function s8(a,b,c){a=a|0;b=b|0;c=c|0;return ag(72,a|0,b|0,c|0)|0}function s9(a,b,c){a=a|0;b=b|0;c=c|0;return ag(73,a|0,b|0,c|0)|0}function ta(a,b,c){a=a|0;b=b|0;c=c|0;return ag(74,a|0,b|0,c|0)|0}function tb(a,b,c){a=a|0;b=b|0;c=c|0;return ag(75,a|0,b|0,c|0)|0}function tc(a,b,c){a=a|0;b=b|0;c=c|0;return ag(76,a|0,b|0,c|0)|0}function td(a,b,c){a=a|0;b=b|0;c=c|0;return ag(77,a|0,b|0,c|0)|0}function te(a,b,c){a=a|0;b=b|0;c=c|0;return ag(78,a|0,b|0,c|0)|0}function tf(a,b,c){a=a|0;b=b|0;c=c|0;return ag(79,a|0,b|0,c|0)|0}function tg(a,b,c){a=a|0;b=b|0;c=c|0;return ag(80,a|0,b|0,c|0)|0}function th(a,b,c){a=a|0;b=b|0;c=c|0;return ag(81,a|0,b|0,c|0)|0}function ti(a,b,c){a=a|0;b=b|0;c=c|0;return ag(82,a|0,b|0,c|0)|0}function tj(a,b,c){a=a|0;b=b|0;c=c|0;return ag(83,a|0,b|0,c|0)|0}function tk(a,b,c){a=a|0;b=b|0;c=c|0;return ag(84,a|0,b|0,c|0)|0}function tl(a,b,c){a=a|0;b=b|0;c=c|0;return ag(85,a|0,b|0,c|0)|0}function tm(a,b,c){a=a|0;b=b|0;c=c|0;return ag(86,a|0,b|0,c|0)|0}function tn(a,b,c){a=a|0;b=b|0;c=c|0;return ag(87,a|0,b|0,c|0)|0}function to(a,b,c){a=a|0;b=b|0;c=c|0;return ag(88,a|0,b|0,c|0)|0}function tp(a,b,c){a=a|0;b=b|0;c=c|0;return ag(89,a|0,b|0,c|0)|0}function tq(a,b,c){a=a|0;b=b|0;c=c|0;return ag(90,a|0,b|0,c|0)|0}function tr(a,b,c){a=a|0;b=b|0;c=c|0;return ag(91,a|0,b|0,c|0)|0}function ts(a,b,c){a=a|0;b=b|0;c=c|0;return ag(92,a|0,b|0,c|0)|0}function tt(a,b,c){a=a|0;b=b|0;c=c|0;return ag(93,a|0,b|0,c|0)|0}function tu(a,b,c){a=a|0;b=b|0;c=c|0;return ag(94,a|0,b|0,c|0)|0}function tv(a,b,c){a=a|0;b=b|0;c=c|0;return ag(95,a|0,b|0,c|0)|0}function tw(a,b,c){a=a|0;b=b|0;c=c|0;return ag(96,a|0,b|0,c|0)|0}function tx(a,b,c){a=a|0;b=b|0;c=c|0;return ag(97,a|0,b|0,c|0)|0}function ty(a,b,c){a=a|0;b=b|0;c=c|0;return ag(98,a|0,b|0,c|0)|0}function tz(a,b,c){a=a|0;b=b|0;c=c|0;return ag(99,a|0,b|0,c|0)|0}function tA(a,b,c){a=a|0;b=b|0;c=c|0;return ag(100,a|0,b|0,c|0)|0}function tB(a,b,c){a=a|0;b=b|0;c=c|0;return ag(101,a|0,b|0,c|0)|0}function tC(a,b,c){a=a|0;b=b|0;c=c|0;return ag(102,a|0,b|0,c|0)|0}function tD(a,b,c){a=a|0;b=b|0;c=c|0;return ag(103,a|0,b|0,c|0)|0}function tE(a,b,c){a=a|0;b=b|0;c=c|0;return ag(104,a|0,b|0,c|0)|0}function tF(a,b,c){a=a|0;b=b|0;c=c|0;return ag(105,a|0,b|0,c|0)|0}function tG(a,b,c){a=a|0;b=b|0;c=c|0;return ag(106,a|0,b|0,c|0)|0}function tH(a,b,c){a=a|0;b=b|0;c=c|0;return ag(107,a|0,b|0,c|0)|0}function tI(a,b,c){a=a|0;b=b|0;c=c|0;return ag(108,a|0,b|0,c|0)|0}function tJ(a,b,c){a=a|0;b=b|0;c=c|0;return ag(109,a|0,b|0,c|0)|0}function tK(a,b,c){a=a|0;b=b|0;c=c|0;return ag(110,a|0,b|0,c|0)|0}function tL(a,b,c){a=a|0;b=b|0;c=c|0;return ag(111,a|0,b|0,c|0)|0}function tM(a,b,c){a=a|0;b=b|0;c=c|0;return ag(112,a|0,b|0,c|0)|0}function tN(a,b,c){a=a|0;b=b|0;c=c|0;return ag(113,a|0,b|0,c|0)|0}function tO(a,b,c){a=a|0;b=b|0;c=c|0;return ag(114,a|0,b|0,c|0)|0}function tP(a,b,c){a=a|0;b=b|0;c=c|0;return ag(115,a|0,b|0,c|0)|0}function tQ(a,b,c){a=a|0;b=b|0;c=c|0;return ag(116,a|0,b|0,c|0)|0}function tR(a,b,c){a=a|0;b=b|0;c=c|0;return ag(117,a|0,b|0,c|0)|0}function tS(a,b,c){a=a|0;b=b|0;c=c|0;return ag(118,a|0,b|0,c|0)|0}function tT(a,b,c){a=a|0;b=b|0;c=c|0;return ag(119,a|0,b|0,c|0)|0}function tU(a,b,c){a=a|0;b=b|0;c=c|0;return ag(120,a|0,b|0,c|0)|0}function tV(a,b,c){a=a|0;b=b|0;c=c|0;return ag(121,a|0,b|0,c|0)|0}function tW(a,b,c){a=a|0;b=b|0;c=c|0;return ag(122,a|0,b|0,c|0)|0}function tX(a,b,c){a=a|0;b=b|0;c=c|0;return ag(123,a|0,b|0,c|0)|0}function tY(a,b,c){a=a|0;b=b|0;c=c|0;return ag(124,a|0,b|0,c|0)|0}function tZ(a){a=a|0;ci[a&255]()}function t_(){ag(0)}function t$(){ag(1)}function t0(){ag(2)}function t1(){ag(3)}function t2(){ag(4)}function t3(){ag(5)}function t4(){ag(6)}function t5(){ag(7)}function t6(){ag(8)}function t7(){ag(9)}function t8(){ag(10)}function t9(){ag(11)}function ua(){ag(12)}function ub(){ag(13)}function uc(){ag(14)}function ud(){ag(15)}function ue(){ag(16)}function uf(){ag(17)}function ug(){ag(18)}function uh(){ag(19)}function ui(){ag(20)}function uj(){ag(21)}function uk(){ag(22)}function ul(){ag(23)}function um(){ag(24)}function un(){ag(25)}function uo(){ag(26)}function up(){ag(27)}function uq(){ag(28)}function ur(){ag(29)}function us(){ag(30)}function ut(){ag(31)}function uu(){ag(32)}function uv(){ag(33)}function uw(){ag(34)}function ux(){ag(35)}function uy(){ag(36)}function uz(){ag(37)}function uA(){ag(38)}function uB(){ag(39)}function uC(){ag(40)}function uD(){ag(41)}function uE(){ag(42)}function uF(){ag(43)}function uG(){ag(44)}function uH(){ag(45)}function uI(){ag(46)}function uJ(){ag(47)}function uK(){ag(48)}function uL(){ag(49)}function uM(){ag(50)}function uN(){ag(51)}function uO(){ag(52)}function uP(){ag(53)}function uQ(){ag(54)}function uR(){ag(55)}function uS(){ag(56)}function uT(){ag(57)}function uU(){ag(58)}function uV(){ag(59)}function uW(){ag(60)}function uX(){ag(61)}function uY(){ag(62)}function uZ(){ag(63)}function u_(){ag(64)}function u$(){ag(65)}function u0(){ag(66)}function u1(){ag(67)}function u2(){ag(68)}function u3(){ag(69)}function u4(){ag(70)}function u5(){ag(71)}function u6(){ag(72)}function u7(){ag(73)}function u8(){ag(74)}function u9(){ag(75)}function va(){ag(76)}function vb(){ag(77)}function vc(){ag(78)}function vd(){ag(79)}function ve(){ag(80)}function vf(){ag(81)}function vg(){ag(82)}function vh(){ag(83)}function vi(){ag(84)}function vj(){ag(85)}function vk(){ag(86)}function vl(){ag(87)}function vm(){ag(88)}function vn(){ag(89)}function vo(){ag(90)}function vp(){ag(91)}function vq(){ag(92)}function vr(){ag(93)}function vs(){ag(94)}function vt(){ag(95)}function vu(){ag(96)}function vv(){ag(97)}function vw(){ag(98)}function vx(){ag(99)}function vy(){ag(100)}function vz(){ag(101)}function vA(){ag(102)}function vB(){ag(103)}function vC(){ag(104)}function vD(){ag(105)}function vE(){ag(106)}function vF(){ag(107)}function vG(){ag(108)}function vH(){ag(109)}function vI(){ag(110)}function vJ(){ag(111)}function vK(){ag(112)}function vL(){ag(113)}function vM(){ag(114)}function vN(){ag(115)}function vO(){ag(116)}function vP(){ag(117)}function vQ(){ag(118)}function vR(){ag(119)}function vS(){ag(120)}function vT(){ag(121)}function vU(){ag(122)}function vV(){ag(123)}function vW(){ag(124)}function vX(a,b,c){a=a|0;b=b|0;c=c|0;return cj[a&255](b|0,c|0)|0}function vY(a,b){a=a|0;b=b|0;return ag(0,a|0,b|0)|0}function vZ(a,b){a=a|0;b=b|0;return ag(1,a|0,b|0)|0}function v_(a,b){a=a|0;b=b|0;return ag(2,a|0,b|0)|0}function v$(a,b){a=a|0;b=b|0;return ag(3,a|0,b|0)|0}function v0(a,b){a=a|0;b=b|0;return ag(4,a|0,b|0)|0}function v1(a,b){a=a|0;b=b|0;return ag(5,a|0,b|0)|0}function v2(a,b){a=a|0;b=b|0;return ag(6,a|0,b|0)|0}function v3(a,b){a=a|0;b=b|0;return ag(7,a|0,b|0)|0}function v4(a,b){a=a|0;b=b|0;return ag(8,a|0,b|0)|0}function v5(a,b){a=a|0;b=b|0;return ag(9,a|0,b|0)|0}function v6(a,b){a=a|0;b=b|0;return ag(10,a|0,b|0)|0}function v7(a,b){a=a|0;b=b|0;return ag(11,a|0,b|0)|0}function v8(a,b){a=a|0;b=b|0;return ag(12,a|0,b|0)|0}function v9(a,b){a=a|0;b=b|0;return ag(13,a|0,b|0)|0}function wa(a,b){a=a|0;b=b|0;return ag(14,a|0,b|0)|0}function wb(a,b){a=a|0;b=b|0;return ag(15,a|0,b|0)|0}function wc(a,b){a=a|0;b=b|0;return ag(16,a|0,b|0)|0}function wd(a,b){a=a|0;b=b|0;return ag(17,a|0,b|0)|0}function we(a,b){a=a|0;b=b|0;return ag(18,a|0,b|0)|0}function wf(a,b){a=a|0;b=b|0;return ag(19,a|0,b|0)|0}function wg(a,b){a=a|0;b=b|0;return ag(20,a|0,b|0)|0}function wh(a,b){a=a|0;b=b|0;return ag(21,a|0,b|0)|0}function wi(a,b){a=a|0;b=b|0;return ag(22,a|0,b|0)|0}function wj(a,b){a=a|0;b=b|0;return ag(23,a|0,b|0)|0}function wk(a,b){a=a|0;b=b|0;return ag(24,a|0,b|0)|0}function wl(a,b){a=a|0;b=b|0;return ag(25,a|0,b|0)|0}function wm(a,b){a=a|0;b=b|0;return ag(26,a|0,b|0)|0}function wn(a,b){a=a|0;b=b|0;return ag(27,a|0,b|0)|0}function wo(a,b){a=a|0;b=b|0;return ag(28,a|0,b|0)|0}function wp(a,b){a=a|0;b=b|0;return ag(29,a|0,b|0)|0}function wq(a,b){a=a|0;b=b|0;return ag(30,a|0,b|0)|0}function wr(a,b){a=a|0;b=b|0;return ag(31,a|0,b|0)|0}function ws(a,b){a=a|0;b=b|0;return ag(32,a|0,b|0)|0}function wt(a,b){a=a|0;b=b|0;return ag(33,a|0,b|0)|0}function wu(a,b){a=a|0;b=b|0;return ag(34,a|0,b|0)|0}function wv(a,b){a=a|0;b=b|0;return ag(35,a|0,b|0)|0}function ww(a,b){a=a|0;b=b|0;return ag(36,a|0,b|0)|0}function wx(a,b){a=a|0;b=b|0;return ag(37,a|0,b|0)|0}function wy(a,b){a=a|0;b=b|0;return ag(38,a|0,b|0)|0}function wz(a,b){a=a|0;b=b|0;return ag(39,a|0,b|0)|0}function wA(a,b){a=a|0;b=b|0;return ag(40,a|0,b|0)|0}function wB(a,b){a=a|0;b=b|0;return ag(41,a|0,b|0)|0}function wC(a,b){a=a|0;b=b|0;return ag(42,a|0,b|0)|0}function wD(a,b){a=a|0;b=b|0;return ag(43,a|0,b|0)|0}function wE(a,b){a=a|0;b=b|0;return ag(44,a|0,b|0)|0}function wF(a,b){a=a|0;b=b|0;return ag(45,a|0,b|0)|0}function wG(a,b){a=a|0;b=b|0;return ag(46,a|0,b|0)|0}function wH(a,b){a=a|0;b=b|0;return ag(47,a|0,b|0)|0}function wI(a,b){a=a|0;b=b|0;return ag(48,a|0,b|0)|0}function wJ(a,b){a=a|0;b=b|0;return ag(49,a|0,b|0)|0}function wK(a,b){a=a|0;b=b|0;return ag(50,a|0,b|0)|0}function wL(a,b){a=a|0;b=b|0;return ag(51,a|0,b|0)|0}function wM(a,b){a=a|0;b=b|0;return ag(52,a|0,b|0)|0}function wN(a,b){a=a|0;b=b|0;return ag(53,a|0,b|0)|0}function wO(a,b){a=a|0;b=b|0;return ag(54,a|0,b|0)|0}function wP(a,b){a=a|0;b=b|0;return ag(55,a|0,b|0)|0}function wQ(a,b){a=a|0;b=b|0;return ag(56,a|0,b|0)|0}function wR(a,b){a=a|0;b=b|0;return ag(57,a|0,b|0)|0}function wS(a,b){a=a|0;b=b|0;return ag(58,a|0,b|0)|0}function wT(a,b){a=a|0;b=b|0;return ag(59,a|0,b|0)|0}function wU(a,b){a=a|0;b=b|0;return ag(60,a|0,b|0)|0}function wV(a,b){a=a|0;b=b|0;return ag(61,a|0,b|0)|0}function wW(a,b){a=a|0;b=b|0;return ag(62,a|0,b|0)|0}function wX(a,b){a=a|0;b=b|0;return ag(63,a|0,b|0)|0}function wY(a,b){a=a|0;b=b|0;return ag(64,a|0,b|0)|0}function wZ(a,b){a=a|0;b=b|0;return ag(65,a|0,b|0)|0}function w_(a,b){a=a|0;b=b|0;return ag(66,a|0,b|0)|0}function w$(a,b){a=a|0;b=b|0;return ag(67,a|0,b|0)|0}function w0(a,b){a=a|0;b=b|0;return ag(68,a|0,b|0)|0}function w1(a,b){a=a|0;b=b|0;return ag(69,a|0,b|0)|0}function w2(a,b){a=a|0;b=b|0;return ag(70,a|0,b|0)|0}function w3(a,b){a=a|0;b=b|0;return ag(71,a|0,b|0)|0}function w4(a,b){a=a|0;b=b|0;return ag(72,a|0,b|0)|0}function w5(a,b){a=a|0;b=b|0;return ag(73,a|0,b|0)|0}function w6(a,b){a=a|0;b=b|0;return ag(74,a|0,b|0)|0}function w7(a,b){a=a|0;b=b|0;return ag(75,a|0,b|0)|0}function w8(a,b){a=a|0;b=b|0;return ag(76,a|0,b|0)|0}function w9(a,b){a=a|0;b=b|0;return ag(77,a|0,b|0)|0}function xa(a,b){a=a|0;b=b|0;return ag(78,a|0,b|0)|0}function xb(a,b){a=a|0;b=b|0;return ag(79,a|0,b|0)|0}function xc(a,b){a=a|0;b=b|0;return ag(80,a|0,b|0)|0}function xd(a,b){a=a|0;b=b|0;return ag(81,a|0,b|0)|0}function xe(a,b){a=a|0;b=b|0;return ag(82,a|0,b|0)|0}function xf(a,b){a=a|0;b=b|0;return ag(83,a|0,b|0)|0}function xg(a,b){a=a|0;b=b|0;return ag(84,a|0,b|0)|0}function xh(a,b){a=a|0;b=b|0;return ag(85,a|0,b|0)|0}function xi(a,b){a=a|0;b=b|0;return ag(86,a|0,b|0)|0}function xj(a,b){a=a|0;b=b|0;return ag(87,a|0,b|0)|0}function xk(a,b){a=a|0;b=b|0;return ag(88,a|0,b|0)|0}function xl(a,b){a=a|0;b=b|0;return ag(89,a|0,b|0)|0}function xm(a,b){a=a|0;b=b|0;return ag(90,a|0,b|0)|0}function xn(a,b){a=a|0;b=b|0;return ag(91,a|0,b|0)|0}function xo(a,b){a=a|0;b=b|0;return ag(92,a|0,b|0)|0}function xp(a,b){a=a|0;b=b|0;return ag(93,a|0,b|0)|0}function xq(a,b){a=a|0;b=b|0;return ag(94,a|0,b|0)|0}function xr(a,b){a=a|0;b=b|0;return ag(95,a|0,b|0)|0}function xs(a,b){a=a|0;b=b|0;return ag(96,a|0,b|0)|0}function xt(a,b){a=a|0;b=b|0;return ag(97,a|0,b|0)|0}function xu(a,b){a=a|0;b=b|0;return ag(98,a|0,b|0)|0}function xv(a,b){a=a|0;b=b|0;return ag(99,a|0,b|0)|0}function xw(a,b){a=a|0;b=b|0;return ag(100,a|0,b|0)|0}function xx(a,b){a=a|0;b=b|0;return ag(101,a|0,b|0)|0}function xy(a,b){a=a|0;b=b|0;return ag(102,a|0,b|0)|0}function xz(a,b){a=a|0;b=b|0;return ag(103,a|0,b|0)|0}function xA(a,b){a=a|0;b=b|0;return ag(104,a|0,b|0)|0}function xB(a,b){a=a|0;b=b|0;return ag(105,a|0,b|0)|0}function xC(a,b){a=a|0;b=b|0;return ag(106,a|0,b|0)|0}function xD(a,b){a=a|0;b=b|0;return ag(107,a|0,b|0)|0}function xE(a,b){a=a|0;b=b|0;return ag(108,a|0,b|0)|0}function xF(a,b){a=a|0;b=b|0;return ag(109,a|0,b|0)|0}function xG(a,b){a=a|0;b=b|0;return ag(110,a|0,b|0)|0}function xH(a,b){a=a|0;b=b|0;return ag(111,a|0,b|0)|0}function xI(a,b){a=a|0;b=b|0;return ag(112,a|0,b|0)|0}function xJ(a,b){a=a|0;b=b|0;return ag(113,a|0,b|0)|0}function xK(a,b){a=a|0;b=b|0;return ag(114,a|0,b|0)|0}function xL(a,b){a=a|0;b=b|0;return ag(115,a|0,b|0)|0}function xM(a,b){a=a|0;b=b|0;return ag(116,a|0,b|0)|0}function xN(a,b){a=a|0;b=b|0;return ag(117,a|0,b|0)|0}function xO(a,b){a=a|0;b=b|0;return ag(118,a|0,b|0)|0}function xP(a,b){a=a|0;b=b|0;return ag(119,a|0,b|0)|0}function xQ(a,b){a=a|0;b=b|0;return ag(120,a|0,b|0)|0}function xR(a,b){a=a|0;b=b|0;return ag(121,a|0,b|0)|0}function xS(a,b){a=a|0;b=b|0;return ag(122,a|0,b|0)|0}function xT(a,b){a=a|0;b=b|0;return ag(123,a|0,b|0)|0}function xU(a,b){a=a|0;b=b|0;return ag(124,a|0,b|0)|0}function xV(a){a=a|0;ab(0);return 0}function xW(a){a=a|0;ab(1)}function xX(a,b){a=a|0;b=b|0;ab(2)}function xY(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;ab(3);return 0}function xZ(a,b,c){a=a|0;b=b|0;c=c|0;ab(4);return 0}function x_(){ab(5)}function x$(a,b){a=a|0;b=b|0;ab(6);return 0}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7841 // EMSCRIPTEN_END_FUNCS\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7842 var cd=[xV,xV,j8,xV,j9,xV,ka,xV,kb,xV,kc,xV,kd,xV,ke,xV,kf,xV,kg,xV,kh,xV,ki,xV,kj,xV,kk,xV,kl,xV,km,xV,kn,xV,ko,xV,kp,xV,kq,xV,kr,xV,ks,xV,kt,xV,ku,xV,kv,xV,kw,xV,kx,xV,ky,xV,kz,xV,kA,xV,kB,xV,kC,xV,kD,xV,kE,xV,kF,xV,kG,xV,kH,xV,kI,xV,kJ,xV,kK,xV,kL,xV,kM,xV,kN,xV,kO,xV,kP,xV,kQ,xV,kR,xV,kS,xV,kT,xV,kU,xV,kV,xV,kW,xV,kX,xV,kY,xV,kZ,xV,k_,xV,k$,xV,k0,xV,k1,xV,k2,xV,k3,xV,k4,xV,k5,xV,k6,xV,k7,xV,k8,xV,k9,xV,la,xV,lb,xV,lc,xV,ld,xV,le,xV,lf,xV,lg,xV,lh,xV,li,xV,lj,xV,lk,xV,ll,xV,lm,xV,ln,xV,lo,xV,lp,xV,lq,xV,lr,xV,ls,xV,lt,xV,lu,xV,lv,xV,lw,xV,lx,xV,ly,xV,lz,xV,lA,xV,lB,xV,lC,xV,lD,xV,lE,xV,lF,xV,lG,xV,lH,xV,lI,xV,lJ,xV,lK,xV,lL,xV,lM,xV,lN,xV,lO,xV,lP,xV,lQ,xV,lR,xV,lS,xV,lT,xV,lU,xV,lV,xV,lW,xV,lX,xV,lY,xV,lZ,xV,l_,xV,l$,xV,l0,xV,l1,xV,l2,xV,l3,xV,l4,xV,iq,xV,hi,xV,hF,xV,ie,xV,hR,xV,iA,xV,hj,xV,iK,xV,hx,xV,iT,xV,iw,xV,hN,xV,jO,xV,ix,xV,hB,xV,h0,xV,il,xV,jF,xV,it,xV,iZ,xV,hP,xV,is,xV,iv,xV,jx,xV,jm,xV,i6,xV,hX,xV,ic,xV,i2,xV,hM,xV,jo,xV,iE,xV,he,xV,jv,xV,jM,xV,iQ,xV,jk,xV,hl,xV,hE,xV,iG,xV,g6,xV,iF,xV,je,xV,jz,xV,h7,xV,jn,xV,hO,xV,hW,xV,iO,xV,i8,xV,hk,xV,jr,xV,iY,xV,jg,xV,iy,xV,jw,xV,i7,xV,hS,xV,hD,xV,g8,xV,jp,xV,jK,xV,h4,xV,js,xV,jI,xV,iR,xV,hH,xV,ip,xV,jL,xV,hc,xV,ha,xV,iz,xV,im,xV,jH,xV,iP,xV,h2,xV,hh,xV,iX,xV,hp,xV,ia,xV,hK,xV,iI,xV,iB,xV,hv,xV,iD,xV,iW,xV,jq,xV,h9,xV,jf,xV,hd,xV,hT,xV,hU,xV,i$,xV,ho,xV,ju,xV,iN,xV,hn,xV,iM,xV,jl,xV,i4,xV,iS,xV,hQ,xV,io,xV,hr,xV,iH,xV,ib,xV,iJ,xV,jd,xV,hs,xV,i1,xV,hw,xV,hu,xV,h8,xV,iL,xV,hb,xV,jy,xV,hG,xV,hV,xV,g9,xV,jt,xV,hY,xV,hL,xV,hC,xV,i3,xV,i9,xV,hg,xV,g7,xV,iu,xV,id,xV,iU,xV,jb,xV,ja,xV,i_,xV,i5,xV,hA,xV,h6,xV,jN,xV,hz,xV,jR,xV,hm,xV,jS,xV,hq,xV,ht,xV,h3,xV,jc,xV,iV,xV,iC,xV,hy,xV,i0,xV,h1,xV,jh,xV,h5,xV,ir,xV,jJ,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV,xV];var ce=[xW,xW,l6,xW,l7,xW,l8,xW,l9,xW,ma,xW,mb,xW,mc,xW,md,xW,me,xW,mf,xW,mg,xW,mh,xW,mi,xW,mj,xW,mk,xW,ml,xW,mm,xW,mn,xW,mo,xW,mp,xW,mq,xW,mr,xW,ms,xW,mt,xW,mu,xW,mv,xW,mw,xW,mx,xW,my,xW,mz,xW,mA,xW,mB,xW,mC,xW,mD,xW,mE,xW,mF,xW,mG,xW,mH,xW,mI,xW,mJ,xW,mK,xW,mL,xW,mM,xW,mN,xW,mO,xW,mP,xW,mQ,xW,mR,xW,mS,xW,mT,xW,mU,xW,mV,xW,mW,xW,mX,xW,mY,xW,mZ,xW,m_,xW,m$,xW,m0,xW,m1,xW,m2,xW,m3,xW,m4,xW,m5,xW,m6,xW,m7,xW,m8,xW,m9,xW,na,xW,nb,xW,nc,xW,nd,xW,ne,xW,nf,xW,ng,xW,nh,xW,ni,xW,nj,xW,nk,xW,nl,xW,nm,xW,nn,xW,no,xW,np,xW,nq,xW,nr,xW,ns,xW,nt,xW,nu,xW,nv,xW,nw,xW,nx,xW,ny,xW,nz,xW,nA,xW,nB,xW,nC,xW,nD,xW,nE,xW,nF,xW,nG,xW,nH,xW,nI,xW,nJ,xW,nK,xW,nL,xW,nM,xW,nN,xW,nO,xW,nP,xW,nQ,xW,nR,xW,nS,xW,nT,xW,nU,xW,nV,xW,nW,xW,nX,xW,nY,xW,nZ,xW,n_,xW,n$,xW,n0,xW,n1,xW,n2,xW,xW,xW,xW,xW];var cf=[xX,xX,n4,xX,n5,xX,n6,xX,n7,xX,n8,xX,n9,xX,oa,xX,ob,xX,oc,xX,od,xX,oe,xX,of,xX,og,xX,oh,xX,oi,xX,oj,xX,ok,xX,ol,xX,om,xX,on,xX,oo,xX,op,xX,oq,xX,or,xX,os,xX,ot,xX,ou,xX,ov,xX,ow,xX,ox,xX,oy,xX,oz,xX,oA,xX,oB,xX,oC,xX,oD,xX,oE,xX,oF,xX,oG,xX,oH,xX,oI,xX,oJ,xX,oK,xX,oL,xX,oM,xX,oN,xX,oO,xX,oP,xX,oQ,xX,oR,xX,oS,xX,oT,xX,oU,xX,oV,xX,oW,xX,oX,xX,oY,xX,oZ,xX,o_,xX,o$,xX,o0,xX,o1,xX,o2,xX,o3,xX,o4,xX,o5,xX,o6,xX,o7,xX,o8,xX,o9,xX,pa,xX,pb,xX,pc,xX,pd,xX,pe,xX,pf,xX,pg,xX,ph,xX,pi,xX,pj,xX,pk,xX,pl,xX,pm,xX,pn,xX,po,xX,pp,xX,pq,xX,pr,xX,ps,xX,pt,xX,pu,xX,pv,xX,pw,xX,px,xX,py,xX,pz,xX,pA,xX,pB,xX,pC,xX,pD,xX,pE,xX,pF,xX,pG,xX,pH,xX,pI,xX,pJ,xX,pK,xX,pL,xX,pM,xX,pN,xX,pO,xX,pP,xX,pQ,xX,pR,xX,pS,xX,pT,xX,pU,xX,pV,xX,pW,xX,pX,xX,pY,xX,pZ,xX,p_,xX,p$,xX,p0,xX,dy,xX,fW,xX,fY,xX,eL,xX,eH,xX,h_,xX,dA,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX,xX];var cg=[xY,xY,p2,xY,p3,xY,p4,xY,p5,xY,p6,xY,p7,xY,p8,xY,p9,xY,qa,xY,qb,xY,qc,xY,qd,xY,qe,xY,qf,xY,qg,xY,qh,xY,qi,xY,qj,xY,qk,xY,ql,xY,qm,xY,qn,xY,qo,xY,qp,xY,qq,xY,qr,xY,qs,xY,qt,xY,qu,xY,qv,xY,qw,xY,qx,xY,qy,xY,qz,xY,qA,xY,qB,xY,qC,xY,qD,xY,qE,xY,qF,xY,qG,xY,qH,xY,qI,xY,qJ,xY,qK,xY,qL,xY,qM,xY,qN,xY,qO,xY,qP,xY,qQ,xY,qR,xY,qS,xY,qT,xY,qU,xY,qV,xY,qW,xY,qX,xY,qY,xY,qZ,xY,q_,xY,q$,xY,q0,xY,q1,xY,q2,xY,q3,xY,q4,xY,q5,xY,q6,xY,q7,xY,q8,xY,q9,xY,ra,xY,rb,xY,rc,xY,rd,xY,re,xY,rf,xY,rg,xY,rh,xY,ri,xY,rj,xY,rk,xY,rl,xY,rm,xY,rn,xY,ro,xY,rp,xY,rq,xY,rr,xY,rs,xY,rt,xY,ru,xY,rv,xY,rw,xY,rx,xY,ry,xY,rz,xY,rA,xY,rB,xY,rC,xY,rD,xY,rE,xY,rF,xY,rG,xY,rH,xY,rI,xY,rJ,xY,rK,xY,rL,xY,rM,xY,rN,xY,rO,xY,rP,xY,rQ,xY,rR,xY,rS,xY,rT,xY,rU,xY,rV,xY,rW,xY,rX,xY,rY,xY,rZ,xY,r_,xY,jG,xY,g5,xY,gh,xY,fA,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY,xY];var ch=[xZ,xZ,r0,xZ,r1,xZ,r2,xZ,r3,xZ,r4,xZ,r5,xZ,r6,xZ,r7,xZ,r8,xZ,r9,xZ,sa,xZ,sb,xZ,sc,xZ,sd,xZ,se,xZ,sf,xZ,sg,xZ,sh,xZ,si,xZ,sj,xZ,sk,xZ,sl,xZ,sm,xZ,sn,xZ,so,xZ,sp,xZ,sq,xZ,sr,xZ,ss,xZ,st,xZ,su,xZ,sv,xZ,sw,xZ,sx,xZ,sy,xZ,sz,xZ,sA,xZ,sB,xZ,sC,xZ,sD,xZ,sE,xZ,sF,xZ,sG,xZ,sH,xZ,sI,xZ,sJ,xZ,sK,xZ,sL,xZ,sM,xZ,sN,xZ,sO,xZ,sP,xZ,sQ,xZ,sR,xZ,sS,xZ,sT,xZ,sU,xZ,sV,xZ,sW,xZ,sX,xZ,sY,xZ,sZ,xZ,s_,xZ,s$,xZ,s0,xZ,s1,xZ,s2,xZ,s3,xZ,s4,xZ,s5,xZ,s6,xZ,s7,xZ,s8,xZ,s9,xZ,ta,xZ,tb,xZ,tc,xZ,td,xZ,te,xZ,tf,xZ,tg,xZ,th,xZ,ti,xZ,tj,xZ,tk,xZ,tl,xZ,tm,xZ,tn,xZ,to,xZ,tp,xZ,tq,xZ,tr,xZ,ts,xZ,tt,xZ,tu,xZ,tv,xZ,tw,xZ,tx,xZ,ty,xZ,tz,xZ,tA,xZ,tB,xZ,tC,xZ,tD,xZ,tE,xZ,tF,xZ,tG,xZ,tH,xZ,tI,xZ,tJ,xZ,tK,xZ,tL,xZ,tM,xZ,tN,xZ,tO,xZ,tP,xZ,tQ,xZ,tR,xZ,tS,xZ,tT,xZ,tU,xZ,tV,xZ,tW,xZ,tX,xZ,tY,xZ,hJ,xZ,g1,xZ,gU,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ,xZ];var ci=[x_,x_,t_,x_,t$,x_,t0,x_,t1,x_,t2,x_,t3,x_,t4,x_,t5,x_,t6,x_,t7,x_,t8,x_,t9,x_,ua,x_,ub,x_,uc,x_,ud,x_,ue,x_,uf,x_,ug,x_,uh,x_,ui,x_,uj,x_,uk,x_,ul,x_,um,x_,un,x_,uo,x_,up,x_,uq,x_,ur,x_,us,x_,ut,x_,uu,x_,uv,x_,uw,x_,ux,x_,uy,x_,uz,x_,uA,x_,uB,x_,uC,x_,uD,x_,uE,x_,uF,x_,uG,x_,uH,x_,uI,x_,uJ,x_,uK,x_,uL,x_,uM,x_,uN,x_,uO,x_,uP,x_,uQ,x_,uR,x_,uS,x_,uT,x_,uU,x_,uV,x_,uW,x_,uX,x_,uY,x_,uZ,x_,u_,x_,u$,x_,u0,x_,u1,x_,u2,x_,u3,x_,u4,x_,u5,x_,u6,x_,u7,x_,u8,x_,u9,x_,va,x_,vb,x_,vc,x_,vd,x_,ve,x_,vf,x_,vg,x_,vh,x_,vi,x_,vj,x_,vk,x_,vl,x_,vm,x_,vn,x_,vo,x_,vp,x_,vq,x_,vr,x_,vs,x_,vt,x_,vu,x_,vv,x_,vw,x_,vx,x_,vy,x_,vz,x_,vA,x_,vB,x_,vC,x_,vD,x_,vE,x_,vF,x_,vG,x_,vH,x_,vI,x_,vJ,x_,vK,x_,vL,x_,vM,x_,vN,x_,vO,x_,vP,x_,vQ,x_,vR,x_,vS,x_,vT,x_,vU,x_,vV,x_,vW,x_,x_,x_,x_,x_];var cj=[x$,x$,vY,x$,vZ,x$,v_,x$,v$,x$,v0,x$,v1,x$,v2,x$,v3,x$,v4,x$,v5,x$,v6,x$,v7,x$,v8,x$,v9,x$,wa,x$,wb,x$,wc,x$,wd,x$,we,x$,wf,x$,wg,x$,wh,x$,wi,x$,wj,x$,wk,x$,wl,x$,wm,x$,wn,x$,wo,x$,wp,x$,wq,x$,wr,x$,ws,x$,wt,x$,wu,x$,wv,x$,ww,x$,wx,x$,wy,x$,wz,x$,wA,x$,wB,x$,wC,x$,wD,x$,wE,x$,wF,x$,wG,x$,wH,x$,wI,x$,wJ,x$,wK,x$,wL,x$,wM,x$,wN,x$,wO,x$,wP,x$,wQ,x$,wR,x$,wS,x$,wT,x$,wU,x$,wV,x$,wW,x$,wX,x$,wY,x$,wZ,x$,w_,x$,w$,x$,w0,x$,w1,x$,w2,x$,w3,x$,w4,x$,w5,x$,w6,x$,w7,x$,w8,x$,w9,x$,xa,x$,xb,x$,xc,x$,xd,x$,xe,x$,xf,x$,xg,x$,xh,x$,xi,x$,xj,x$,xk,x$,xl,x$,xm,x$,xn,x$,xo,x$,xp,x$,xq,x$,xr,x$,xs,x$,xt,x$,xu,x$,xv,x$,xw,x$,xx,x$,xy,x$,xz,x$,xA,x$,xB,x$,xC,x$,xD,x$,xE,x$,xF,x$,xG,x$,xH,x$,xI,x$,xJ,x$,xK,x$,xL,x$,xM,x$,xN,x$,xO,x$,xP,x$,xQ,x$,xR,x$,xS,x$,xT,x$,xU,x$,x$,x$,x$,x$];return{_luaL_checkstack:gH,_strlen:j_,_strcat:j4,_lua_pushlightuserdata:c7,_lua_createtable:di,_luaL_optinteger:gN,_lua_rawset:dn,_strncpy:j3,_lua_setmetatable:dq,_lua_concat:dG,_luaL_optlstring:gD,_luaopen_io:h0,_memcpy:j$,_lua_pcall:dx,_lua_pushthread:c8,_lua_close:fX,_luaopen_math:iv,_lua_setupvalue:dJ,_lua_replace:cP,_memcmp:j5,_lua_gethookmask:eh,_lua_xmove:cC,_lua_load:dB,_lua_touserdata:cZ,_lua_rawget:dg,_free:jV,_lua_pushcclosure:dd,_lua_pushstring:da,_tolower:j6,_lua_getfenv:dk,_luaopen_string:jk,_lua_isuserdata:cR,_luaL_buffinit:gt,_lua_resume:eE,_lua_iscfunction:cM,_lua_remove:cH,_luaL_checkoption:gC,_lua_tointeger:c$,_lua_pushvfstring:db,_luaL_prepbuffer:gY,_lua_isnumber:cS,_luaL_checklstring:gE,_lua_isstring:cQ,_lua_pushlstring:c9,_lua_setfenv:dv,_lua_lessthan:cV,_luaopen_os:iY,_lua_yield:eI,_luaL_checkany:gJ,_luaL_addstring:gW,_lua_pushfstring:dc,_lua_insert:cI,_lua_tolstring:c0,_lua_pushnil:c3,_luaL_register:gQ,_lua_getupvalue:du,_lua_checkstack:cN,_luaopen_package:jH,_luaL_pushresult:gX,_lua_topointer:c2,_lua_error:dE,_lua_gettable:de,_luaopen_debug:hK,_lua_tonumber:cW,_luaL_checkinteger:gM,_lua_getstack:ej,_lua_gettop:cF,_lua_getlocal:el,_luaL_checktype:gI,_lua_newuserdata:dH,_lua_settable:dl,_luaL_addlstring:gV,_luaL_loadbuffer:g2,_lua_toboolean:cX,_lua_setallocf:dt,_memset:j2,_lua_gethook:eg,_lua_gethookcount:ei,_luaL_openlibs:jT,_lua_setlocal:em,_lua_tothread:c_,_lua_newstate:fV,_lua_pushvalue:cJ,_lua_tocfunction:cY,_lua_newthread:cO,_lua_typename:cL,_luaL_argerror:gy,_lua_rawgeti:dh,_testSetjmp:j1,_lua_sethook:ef,_lua_equal:cU,_luaL_callmeta:gP,_lua_call:dw,_luaL_typerror:gA,_malloc:jU,_lua_rawequal:cT,_lua_type:cK,_lua_getfield:df,_lua_objlen:c1,_luaL_checknumber:gK,_luaL_newmetatable:gF,_lua_getmetatable:dj,_luaL_newstate:g4,_luaopen_base:g7,_luaL_gsub:gT,_luaL_addvalue:gZ,_lua_atpanic:cE,_luaL_getmetafield:gO,_lua_getinfo:en,_lua_gc:dD,_lua_settop:cG,_lua_pushboolean:c6,_lua_setfield:dm,_luaL_ref:g_,_lua_next:dF,_luaL_findtable:gS,_luaL_checkudata:gG,_realloc:jW,_luaopen_table:i8,_lua_setlevel:cD,_luaL_loadfile:g0,_lua_pushnumber:c4,_lua_rawseti:dp,_saveSetjmp:j0,_luaL_optnumber:gL,_lua_pushinteger:c5,_lua_getallocf:ds,_lua_dump:dC,_lua_status:dr,_luaL_where:gB,_lua_cpcall:dz,_luaL_error:gz,_luaL_loadstring:g3,_luaL_unref:g$,runPostSets:cA,stackAlloc:ck,stackSave:cl,stackRestore:cm,setThrew:cn,setTempRet0:cq,setTempRet1:cr,setTempRet2:cs,setTempRet3:ct,setTempRet4:cu,setTempRet5:cv,setTempRet6:cw,setTempRet7:cx,setTempRet8:cy,setTempRet9:cz,dynCall_ii:j7,dynCall_vi:l5,dynCall_vii:n3,dynCall_iiiii:p1,dynCall_iiii:r$,dynCall_v:tZ,dynCall_iii:vX}})\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7843 // EMSCRIPTEN_END_ASM\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7844 ({ \"Math\": Math, \"Int8Array\": Int8Array, \"Int16Array\": Int16Array, \"Int32Array\": Int32Array, \"Uint8Array\": Uint8Array, \"Uint16Array\": Uint16Array, \"Uint32Array\": Uint32Array, \"Float32Array\": Float32Array, \"Float64Array\": Float64Array }, { \"abort\": abort, \"assert\": assert, \"asmPrintInt\": asmPrintInt, \"asmPrintFloat\": asmPrintFloat, \"min\": Math_min, \"jsCall\": jsCall, \"invoke_ii\": invoke_ii, \"invoke_vi\": invoke_vi, \"invoke_vii\": invoke_vii, \"invoke_iiiii\": invoke_iiiii, \"invoke_iiii\": invoke_iiii, \"invoke_v\": invoke_v, \"invoke_iii\": invoke_iii, \"_llvm_lifetime_end\": _llvm_lifetime_end, \"_lseek\": _lseek, \"__scanString\": __scanString, \"_fclose\": _fclose, \"_strtoul\": _strtoul, \"__isFloat\": __isFloat, \"_fflush\": _fflush, \"_fputc\": _fputc, \"_fwrite\": _fwrite, \"_strncmp\": _strncmp, \"_send\": _send, \"_fputs\": _fputs, \"_tmpnam\": _tmpnam, \"_isspace\": _isspace, \"_localtime\": _localtime, \"_read\": _read, \"_ceil\": _ceil, \"_strstr\": _strstr, \"_fsync\": _fsync, \"_fscanf\": _fscanf, \"_fmod\": _fmod, \"_remove\": _remove, \"_modf\": _modf, \"_strcmp\": _strcmp, \"_memchr\": _memchr, \"_llvm_va_end\": _llvm_va_end, \"_tmpfile\": _tmpfile, \"_snprintf\": _snprintf, \"_fgetc\": _fgetc, \"_cosh\": _cosh, \"_fgets\": _fgets, \"_close\": _close, \"_strchr\": _strchr, \"_asin\": _asin, \"_clock\": _clock, \"___setErrNo\": ___setErrNo, \"_isxdigit\": _isxdigit, \"_ftell\": _ftell, \"_exit\": _exit, \"_sprintf\": _sprintf, \"_strrchr\": _strrchr, \"_freopen\": _freopen, \"_strcspn\": _strcspn, \"__isLeapYear\": __isLeapYear, \"_ferror\": _ferror, \"_gmtime\": _gmtime, \"_localtime_r\": _localtime_r, \"_sinh\": _sinh, \"_recv\": _recv, \"_cos\": _cos, \"_putchar\": _putchar, \"_islower\": _islower, \"__exit\": __exit, \"_isupper\": _isupper, \"_strftime\": _strftime, \"_rand\": _rand, \"_tzset\": _tzset, \"_setlocale\": _setlocale, \"_ldexp\": _ldexp, \"_toupper\": _toupper, \"_pread\": _pread, \"_fopen\": _fopen, \"_open\": _open, \"_frexp\": _frexp, \"__arraySum\": __arraySum, \"_log\": _log, \"_isalnum\": _isalnum, \"_mktime\": _mktime, \"_system\": _system, \"_isalpha\": _isalpha, \"_rmdir\": _rmdir, \"_log10\": _log10, \"_fread\": _fread, \"__reallyNegative\": __reallyNegative, \"__formatString\": __formatString, \"_getenv\": _getenv, \"_llvm_pow_f64\": _llvm_pow_f64, \"_sbrk\": _sbrk, \"_tanh\": _tanh, \"_localeconv\": _localeconv, \"___errno_location\": ___errno_location, \"_strerror\": _strerror, \"_llvm_lifetime_start\": _llvm_lifetime_start, \"__parseInt\": __parseInt, \"_ungetc\": _ungetc, \"_rename\": _rename, \"_sysconf\": _sysconf, \"_srand\": _srand, \"_abort\": _abort, \"_fprintf\": _fprintf, \"_tan\": _tan, \"___buildEnvironment\": ___buildEnvironment, \"_feof\": _feof, \"__addDays\": __addDays, \"_strncat\": _strncat, \"_gmtime_r\": _gmtime_r, \"_ispunct\": _ispunct, \"_clearerr\": _clearerr, \"_fabs\": _fabs, \"_floor\": _floor, \"_fseek\": _fseek, \"_sqrt\": _sqrt, \"_write\": _write, \"_sin\": _sin, \"_longjmp\": _longjmp, \"_atan\": _atan, \"_strpbrk\": _strpbrk, \"_unlink\": _unlink, \"_acos\": _acos, \"_pwrite\": _pwrite, \"_strerror_r\": _strerror_r, \"_difftime\": _difftime, \"_iscntrl\": _iscntrl, \"_atan2\": _atan2, \"_exp\": _exp, \"_time\": _time, \"_setvbuf\": _setvbuf, \"STACKTOP\": STACKTOP, \"STACK_MAX\": STACK_MAX, \"tempDoublePtr\": tempDoublePtr, \"ABORT\": ABORT, \"NaN\": NaN, \"Infinity\": Infinity, \"_stdin\": _stdin, \"_stderr\": _stderr, \"_stdout\": _stdout }, buffer);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7845 var _luaL_checkstack = Module[\"_luaL_checkstack\"] = asm[\"_luaL_checkstack\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7846 var _strlen = Module[\"_strlen\"] = asm[\"_strlen\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7847 var _strcat = Module[\"_strcat\"] = asm[\"_strcat\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7848 var _lua_pushlightuserdata = Module[\"_lua_pushlightuserdata\"] = asm[\"_lua_pushlightuserdata\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7849 var _lua_createtable = Module[\"_lua_createtable\"] = asm[\"_lua_createtable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7850 var _luaL_optinteger = Module[\"_luaL_optinteger\"] = asm[\"_luaL_optinteger\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7851 var _lua_rawset = Module[\"_lua_rawset\"] = asm[\"_lua_rawset\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7852 var _strncpy = Module[\"_strncpy\"] = asm[\"_strncpy\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7853 var _lua_setmetatable = Module[\"_lua_setmetatable\"] = asm[\"_lua_setmetatable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7854 var _lua_concat = Module[\"_lua_concat\"] = asm[\"_lua_concat\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7855 var _luaL_optlstring = Module[\"_luaL_optlstring\"] = asm[\"_luaL_optlstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7856 var _luaopen_io = Module[\"_luaopen_io\"] = asm[\"_luaopen_io\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7857 var _memcpy = Module[\"_memcpy\"] = asm[\"_memcpy\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7858 var _lua_pcall = Module[\"_lua_pcall\"] = asm[\"_lua_pcall\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7859 var _lua_pushthread = Module[\"_lua_pushthread\"] = asm[\"_lua_pushthread\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7860 var _lua_close = Module[\"_lua_close\"] = asm[\"_lua_close\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7861 var _luaopen_math = Module[\"_luaopen_math\"] = asm[\"_luaopen_math\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7862 var _lua_setupvalue = Module[\"_lua_setupvalue\"] = asm[\"_lua_setupvalue\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7863 var _lua_replace = Module[\"_lua_replace\"] = asm[\"_lua_replace\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7864 var _memcmp = Module[\"_memcmp\"] = asm[\"_memcmp\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7865 var _lua_gethookmask = Module[\"_lua_gethookmask\"] = asm[\"_lua_gethookmask\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7866 var _lua_xmove = Module[\"_lua_xmove\"] = asm[\"_lua_xmove\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7867 var _lua_load = Module[\"_lua_load\"] = asm[\"_lua_load\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7868 var _lua_touserdata = Module[\"_lua_touserdata\"] = asm[\"_lua_touserdata\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7869 var _lua_rawget = Module[\"_lua_rawget\"] = asm[\"_lua_rawget\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7870 var _free = Module[\"_free\"] = asm[\"_free\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7871 var _lua_pushcclosure = Module[\"_lua_pushcclosure\"] = asm[\"_lua_pushcclosure\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7872 var _lua_pushstring = Module[\"_lua_pushstring\"] = asm[\"_lua_pushstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7873 var _tolower = Module[\"_tolower\"] = asm[\"_tolower\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7874 var _lua_getfenv = Module[\"_lua_getfenv\"] = asm[\"_lua_getfenv\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7875 var _luaopen_string = Module[\"_luaopen_string\"] = asm[\"_luaopen_string\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7876 var _lua_isuserdata = Module[\"_lua_isuserdata\"] = asm[\"_lua_isuserdata\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7877 var _luaL_buffinit = Module[\"_luaL_buffinit\"] = asm[\"_luaL_buffinit\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7878 var _lua_resume = Module[\"_lua_resume\"] = asm[\"_lua_resume\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7879 var _lua_iscfunction = Module[\"_lua_iscfunction\"] = asm[\"_lua_iscfunction\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7880 var _lua_remove = Module[\"_lua_remove\"] = asm[\"_lua_remove\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7881 var _luaL_checkoption = Module[\"_luaL_checkoption\"] = asm[\"_luaL_checkoption\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7882 var _lua_tointeger = Module[\"_lua_tointeger\"] = asm[\"_lua_tointeger\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7883 var _lua_pushvfstring = Module[\"_lua_pushvfstring\"] = asm[\"_lua_pushvfstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7884 var _luaL_prepbuffer = Module[\"_luaL_prepbuffer\"] = asm[\"_luaL_prepbuffer\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7885 var _lua_isnumber = Module[\"_lua_isnumber\"] = asm[\"_lua_isnumber\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7886 var _luaL_checklstring = Module[\"_luaL_checklstring\"] = asm[\"_luaL_checklstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7887 var _lua_isstring = Module[\"_lua_isstring\"] = asm[\"_lua_isstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7888 var _lua_pushlstring = Module[\"_lua_pushlstring\"] = asm[\"_lua_pushlstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7889 var _lua_setfenv = Module[\"_lua_setfenv\"] = asm[\"_lua_setfenv\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7890 var _lua_lessthan = Module[\"_lua_lessthan\"] = asm[\"_lua_lessthan\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7891 var _luaopen_os = Module[\"_luaopen_os\"] = asm[\"_luaopen_os\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7892 var _lua_yield = Module[\"_lua_yield\"] = asm[\"_lua_yield\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7893 var _luaL_checkany = Module[\"_luaL_checkany\"] = asm[\"_luaL_checkany\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7894 var _luaL_addstring = Module[\"_luaL_addstring\"] = asm[\"_luaL_addstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7895 var _lua_pushfstring = Module[\"_lua_pushfstring\"] = asm[\"_lua_pushfstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7896 var _lua_insert = Module[\"_lua_insert\"] = asm[\"_lua_insert\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7897 var _lua_tolstring = Module[\"_lua_tolstring\"] = asm[\"_lua_tolstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7898 var _lua_pushnil = Module[\"_lua_pushnil\"] = asm[\"_lua_pushnil\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7899 var _luaL_register = Module[\"_luaL_register\"] = asm[\"_luaL_register\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7900 var _lua_getupvalue = Module[\"_lua_getupvalue\"] = asm[\"_lua_getupvalue\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7901 var _lua_checkstack = Module[\"_lua_checkstack\"] = asm[\"_lua_checkstack\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7902 var _luaopen_package = Module[\"_luaopen_package\"] = asm[\"_luaopen_package\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7903 var _luaL_pushresult = Module[\"_luaL_pushresult\"] = asm[\"_luaL_pushresult\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7904 var _lua_topointer = Module[\"_lua_topointer\"] = asm[\"_lua_topointer\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7905 var _lua_error = Module[\"_lua_error\"] = asm[\"_lua_error\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7906 var _lua_gettable = Module[\"_lua_gettable\"] = asm[\"_lua_gettable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7907 var _luaopen_debug = Module[\"_luaopen_debug\"] = asm[\"_luaopen_debug\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7908 var _lua_tonumber = Module[\"_lua_tonumber\"] = asm[\"_lua_tonumber\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7909 var _luaL_checkinteger = Module[\"_luaL_checkinteger\"] = asm[\"_luaL_checkinteger\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7910 var _lua_getstack = Module[\"_lua_getstack\"] = asm[\"_lua_getstack\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7911 var _lua_gettop = Module[\"_lua_gettop\"] = asm[\"_lua_gettop\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7912 var _lua_getlocal = Module[\"_lua_getlocal\"] = asm[\"_lua_getlocal\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7913 var _luaL_checktype = Module[\"_luaL_checktype\"] = asm[\"_luaL_checktype\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7914 var _lua_newuserdata = Module[\"_lua_newuserdata\"] = asm[\"_lua_newuserdata\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7915 var _lua_settable = Module[\"_lua_settable\"] = asm[\"_lua_settable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7916 var _luaL_addlstring = Module[\"_luaL_addlstring\"] = asm[\"_luaL_addlstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7917 var _luaL_loadbuffer = Module[\"_luaL_loadbuffer\"] = asm[\"_luaL_loadbuffer\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7918 var _lua_toboolean = Module[\"_lua_toboolean\"] = asm[\"_lua_toboolean\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7919 var _lua_setallocf = Module[\"_lua_setallocf\"] = asm[\"_lua_setallocf\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7920 var _memset = Module[\"_memset\"] = asm[\"_memset\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7921 var _lua_gethook = Module[\"_lua_gethook\"] = asm[\"_lua_gethook\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7922 var _lua_gethookcount = Module[\"_lua_gethookcount\"] = asm[\"_lua_gethookcount\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7923 var _luaL_openlibs = Module[\"_luaL_openlibs\"] = asm[\"_luaL_openlibs\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7924 var _lua_setlocal = Module[\"_lua_setlocal\"] = asm[\"_lua_setlocal\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7925 var _lua_tothread = Module[\"_lua_tothread\"] = asm[\"_lua_tothread\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7926 var _lua_newstate = Module[\"_lua_newstate\"] = asm[\"_lua_newstate\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7927 var _lua_pushvalue = Module[\"_lua_pushvalue\"] = asm[\"_lua_pushvalue\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7928 var _lua_tocfunction = Module[\"_lua_tocfunction\"] = asm[\"_lua_tocfunction\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7929 var _lua_newthread = Module[\"_lua_newthread\"] = asm[\"_lua_newthread\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7930 var _lua_typename = Module[\"_lua_typename\"] = asm[\"_lua_typename\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7931 var _luaL_argerror = Module[\"_luaL_argerror\"] = asm[\"_luaL_argerror\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7932 var _lua_rawgeti = Module[\"_lua_rawgeti\"] = asm[\"_lua_rawgeti\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7933 var _testSetjmp = Module[\"_testSetjmp\"] = asm[\"_testSetjmp\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7934 var _lua_sethook = Module[\"_lua_sethook\"] = asm[\"_lua_sethook\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7935 var _lua_equal = Module[\"_lua_equal\"] = asm[\"_lua_equal\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7936 var _luaL_callmeta = Module[\"_luaL_callmeta\"] = asm[\"_luaL_callmeta\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7937 var _lua_call = Module[\"_lua_call\"] = asm[\"_lua_call\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7938 var _luaL_typerror = Module[\"_luaL_typerror\"] = asm[\"_luaL_typerror\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7939 var _malloc = Module[\"_malloc\"] = asm[\"_malloc\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7940 var _lua_rawequal = Module[\"_lua_rawequal\"] = asm[\"_lua_rawequal\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7941 var _lua_type = Module[\"_lua_type\"] = asm[\"_lua_type\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7942 var _lua_getfield = Module[\"_lua_getfield\"] = asm[\"_lua_getfield\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7943 var _lua_objlen = Module[\"_lua_objlen\"] = asm[\"_lua_objlen\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7944 var _luaL_checknumber = Module[\"_luaL_checknumber\"] = asm[\"_luaL_checknumber\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7945 var _luaL_newmetatable = Module[\"_luaL_newmetatable\"] = asm[\"_luaL_newmetatable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7946 var _lua_getmetatable = Module[\"_lua_getmetatable\"] = asm[\"_lua_getmetatable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7947 var _luaL_newstate = Module[\"_luaL_newstate\"] = asm[\"_luaL_newstate\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7948 var _luaopen_base = Module[\"_luaopen_base\"] = asm[\"_luaopen_base\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7949 var _luaL_gsub = Module[\"_luaL_gsub\"] = asm[\"_luaL_gsub\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7950 var _luaL_addvalue = Module[\"_luaL_addvalue\"] = asm[\"_luaL_addvalue\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7951 var _lua_atpanic = Module[\"_lua_atpanic\"] = asm[\"_lua_atpanic\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7952 var _luaL_getmetafield = Module[\"_luaL_getmetafield\"] = asm[\"_luaL_getmetafield\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7953 var _lua_getinfo = Module[\"_lua_getinfo\"] = asm[\"_lua_getinfo\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7954 var _lua_gc = Module[\"_lua_gc\"] = asm[\"_lua_gc\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7955 var _lua_settop = Module[\"_lua_settop\"] = asm[\"_lua_settop\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7956 var _lua_pushboolean = Module[\"_lua_pushboolean\"] = asm[\"_lua_pushboolean\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7957 var _lua_setfield = Module[\"_lua_setfield\"] = asm[\"_lua_setfield\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7958 var _luaL_ref = Module[\"_luaL_ref\"] = asm[\"_luaL_ref\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7959 var _lua_next = Module[\"_lua_next\"] = asm[\"_lua_next\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7960 var _luaL_findtable = Module[\"_luaL_findtable\"] = asm[\"_luaL_findtable\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7961 var _luaL_checkudata = Module[\"_luaL_checkudata\"] = asm[\"_luaL_checkudata\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7962 var _realloc = Module[\"_realloc\"] = asm[\"_realloc\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7963 var _luaopen_table = Module[\"_luaopen_table\"] = asm[\"_luaopen_table\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7964 var _lua_setlevel = Module[\"_lua_setlevel\"] = asm[\"_lua_setlevel\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7965 var _luaL_loadfile = Module[\"_luaL_loadfile\"] = asm[\"_luaL_loadfile\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7966 var _lua_pushnumber = Module[\"_lua_pushnumber\"] = asm[\"_lua_pushnumber\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7967 var _lua_rawseti = Module[\"_lua_rawseti\"] = asm[\"_lua_rawseti\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7968 var _saveSetjmp = Module[\"_saveSetjmp\"] = asm[\"_saveSetjmp\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7969 var _luaL_optnumber = Module[\"_luaL_optnumber\"] = asm[\"_luaL_optnumber\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7970 var _lua_pushinteger = Module[\"_lua_pushinteger\"] = asm[\"_lua_pushinteger\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7971 var _lua_getallocf = Module[\"_lua_getallocf\"] = asm[\"_lua_getallocf\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7972 var _lua_dump = Module[\"_lua_dump\"] = asm[\"_lua_dump\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7973 var _lua_status = Module[\"_lua_status\"] = asm[\"_lua_status\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7974 var _luaL_where = Module[\"_luaL_where\"] = asm[\"_luaL_where\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7975 var _lua_cpcall = Module[\"_lua_cpcall\"] = asm[\"_lua_cpcall\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7976 var _luaL_error = Module[\"_luaL_error\"] = asm[\"_luaL_error\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7977 var _luaL_loadstring = Module[\"_luaL_loadstring\"] = asm[\"_luaL_loadstring\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7978 var _luaL_unref = Module[\"_luaL_unref\"] = asm[\"_luaL_unref\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7979 var runPostSets = Module[\"runPostSets\"] = asm[\"runPostSets\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7980 var dynCall_ii = Module[\"dynCall_ii\"] = asm[\"dynCall_ii\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7981 var dynCall_vi = Module[\"dynCall_vi\"] = asm[\"dynCall_vi\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7982 var dynCall_vii = Module[\"dynCall_vii\"] = asm[\"dynCall_vii\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7983 var dynCall_iiiii = Module[\"dynCall_iiiii\"] = asm[\"dynCall_iiiii\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7984 var dynCall_iiii = Module[\"dynCall_iiii\"] = asm[\"dynCall_iiii\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7985 var dynCall_v = Module[\"dynCall_v\"] = asm[\"dynCall_v\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7986 var dynCall_iii = Module[\"dynCall_iii\"] = asm[\"dynCall_iii\"];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7987 Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7988 Runtime.stackSave = function() { return asm['stackSave']() };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7989 Runtime.stackRestore = function(top) { asm['stackRestore'](top) };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7990 // Warning: printing of i64 values may be slightly rounded! No deep i64 math used, so precise i64 code not included\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7991 var i64Math = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7992 // === Auto-generated postamble setup entry stuff ===\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7993 function ExitStatus(status) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7994 this.name = \"ExitStatus\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7995 this.message = \"Program terminated with exit(\" + status + \")\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7996 this.status = status;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7997 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7998 ExitStatus.prototype = new Error();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7999 ExitStatus.prototype.constructor = ExitStatus;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8000 var initialStackTop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8001 var preloadStartTime = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8002 var calledMain = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8003 Module['callMain'] = Module.callMain = function callMain(args) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8004 assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8005 assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8006 args = args || [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8007 if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8008 Module.printErr('preload time: ' + (Date.now() - preloadStartTime) + ' ms');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8009 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8010 ensureInitRuntime();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8011 var argc = args.length+1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8012 function pad() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8013 for (var i = 0; i < 4-1; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8014 argv.push(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8015 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8016 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8017 var argv = [allocate(intArrayFromString(\"/bin/this.program\"), 'i8', ALLOC_NORMAL) ];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8018 pad();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8019 for (var i = 0; i < argc-1; i = i + 1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8020 argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8021 pad();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8022 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8023 argv.push(0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8024 argv = allocate(argv, 'i32', ALLOC_NORMAL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8025 initialStackTop = STACKTOP;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8026 try {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8027 var ret = Module['_main'](argc, argv, 0);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8028 // if we're not running an evented main loop, it's time to exit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8029 if (!Module['noExitRuntime']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8030 exit(ret);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8031 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8032 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8033 catch(e) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8034 if (e instanceof ExitStatus) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8035 // exit() throws this once it's done to make sure execution\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8036 // has been stopped completely\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8037 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8038 } else if (e == 'SimulateInfiniteLoop') {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8039 // running an evented main loop, don't immediately exit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8040 Module['noExitRuntime'] = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8041 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8042 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8043 throw e;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8044 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8045 } finally {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8046 calledMain = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8047 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8048 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8049 function run(args) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8050 args = args || Module['arguments'];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8051 if (preloadStartTime === null) preloadStartTime = Date.now();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8052 if (runDependencies > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8053 Module.printErr('run() called, but dependencies remain, so not running');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8054 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8055 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8056 preRun();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8057 if (runDependencies > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8058 // a preRun added a dependency, run will be called later\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8059 return;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8060 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8061 function doRun() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8062 ensureInitRuntime();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8063 preMain();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8064 calledRun = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8065 if (Module['_main'] && shouldRunNow) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8066 Module['callMain'](args);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8067 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8068 postRun();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8069 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8070 if (Module['setStatus']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8071 Module['setStatus']('Running...');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8072 setTimeout(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8073 setTimeout(function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8074 Module['setStatus']('');\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8075 }, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8076 if (!ABORT) doRun();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8077 }, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8078 } else {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8079 doRun();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8080 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8081 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8082 Module['run'] = Module.run = run;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8083 function exit(status) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8084 ABORT = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8085 EXITSTATUS = status;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8086 STACKTOP = initialStackTop;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8087 // exit the runtime\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8088 exitRuntime();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8089 // TODO We should handle this differently based on environment.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8090 // In the browser, the best we can do is throw an exception\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8091 // to halt execution, but in node we could process.exit and\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8092 // I'd imagine SM shell would have something equivalent.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8093 // This would let us set a proper exit status (which\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8094 // would be great for checking test exit statuses).\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8095 // https://github.com/kripken/emscripten/issues/1371\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8096 // throw an exception to halt the current execution\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8097 throw new ExitStatus(status);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8098 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8099 Module['exit'] = Module.exit = exit;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8100 function abort(text) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8101 if (text) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8102 Module.print(text);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8103 Module.printErr(text);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8104 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8105 ABORT = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8106 EXITSTATUS = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8107 throw 'abort() at ' + (new Error().stack);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8108 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8109 Module['abort'] = Module.abort = abort;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8110 // {{PRE_RUN_ADDITIONS}}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8111 if (Module['preInit']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8112 if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8113 while (Module['preInit'].length > 0) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8114 Module['preInit'].pop()();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8115 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8116 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8117 // shouldRunNow refers to calling main(), not run().\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8118 var shouldRunNow = true;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8119 if (Module['noInitialRun']) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8120 shouldRunNow = false;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8121 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8122 run();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8123 // {{POST_RUN_ADDITIONS}}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8124 // {{MODULE_ADDITIONS}}\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8125 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8126 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8127 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8128 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8129 var C = { };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8130 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8131 var F = Module.cwrap;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8132 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8133 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8134 // c_type.js: basic C \"types\" for Lua 5.1 C API cwraps (fragment file)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8135 // This file is a part of lua5.1.js project:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8136 // Copyright (c) LogicEditor <info@logiceditor.com>\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8137 // Copyright (c) lua5.1.js authors\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8138 // See file `COPYRIGHT` for the license\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8139 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8140 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8141 var void_t = null;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8142 var void_ptr_t = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8143 var void_ptr_t_ptr_t = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8144 var const_void_ptr_t = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8145 var int_t = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8146 var size_t_ptr_t = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8147 var size_t = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8148 var const_char_ptr_t = \"string\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8149 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8150 var NULL = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8151 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8152 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8153 // lua.h.js: Lua 5.1 C API, lua.h definitions (fragment file)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8154 // This file is a part of lua5.1.js project:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8155 // Copyright (c) LogicEditor <info@logiceditor.com>\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8156 // Copyright (c) lua5.1.js authors\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8157 // See file `COPYRIGHT` for the license\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8158 // Based on original Lua 5.1.5 header files:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8159 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8160 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8161 // Note: Keeping this file as close to Lua sources as possible.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8162 // This includes avoiding breaking lines at 80 char limit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8163 // to keep original formatting despite JS code being somewhat longer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8164 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8165 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8166 var lua_Number = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8167 var lua_Integer = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8168 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8169 C.LUA_VERSION = \"Lua 5.1\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8170 C.LUA_RELEASE = \"Lua 5.1.5\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8171 C.LUA_VERSION_NUM = 501;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8172 C.LUA_COPYRIGHT = \"Copyright (C) 1994-2012 Lua.org, PUC-Rio\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8173 C.LUA_AUTHORS = \"R. Ierusalimschy, L. H. de Figueiredo & W. Celes\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8174 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8175 /* mark for precompiled code (`<esc>Lua') */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8176 C.LUA_SIGNATURE = \"\\033Lua\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8177 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8178 /* option for multiple returns in `lua_pcall' and `lua_call' */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8179 C.LUA_MULTRET = (-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8180 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8181 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8182 ** pseudo-indices\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8183 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8184 C.LUA_REGISTRYINDEX = (-10000);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8185 C.LUA_ENVIRONINDEX = (-10001);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8186 C.LUA_GLOBALSINDEX = (-10002);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8187 C.lua_upvalueindex = function(i) { return (C.LUA_GLOBALSINDEX-(i)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8188 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8189 /* thread status; 0 is OK */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8190 C.LUA_YIELD = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8191 C.LUA_ERRRUN = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8192 C.LUA_ERRSYNTAX = 3;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8193 C.LUA_ERRMEM = 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8194 C.LUA_ERRERR = 5;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8195 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8196 var lua_State = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8197 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8198 // typedef int (*lua_CFunction) (lua_State *L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8199 var lua_CFunction = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8200 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8201 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8202 ** functions that read/write blocks when loading/dumping Lua chunks\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8203 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8204 // typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8205 var lua_Reader = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8206 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8207 // typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8208 var lua_Writer = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8209 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8210 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8211 ** prototype for memory-allocation functions\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8212 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8213 // typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8214 var lua_Alloc = \"number\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8215 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8216 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8217 ** basic types\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8218 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8219 C.LUA_TNONE = (-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8220 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8221 C.LUA_TNIL = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8222 C.LUA_TBOOLEAN = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8223 C.LUA_TLIGHTUSERDATA = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8224 C.LUA_TNUMBER = 3;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8225 C.LUA_TSTRING = 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8226 C.LUA_TTABLE = 5;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8227 C.LUA_TFUNCTION = 6;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8228 C.LUA_TUSERDATA = 7;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8229 C.LUA_TTHREAD = 8;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8230 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8231 /* minimum Lua stack available to a C function */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8232 C.LUA_MINSTACK = 20;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8233 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8234 /* type of numbers in Lua */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8235 var LUA_NUMBER = lua_Number;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8236 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8237 /* type for integer functions */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8238 var LUA_INTEGER = lua_Integer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8239 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8240 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8241 ** state manipulation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8242 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8243 C.lua_newstate = F(\"lua_newstate\", lua_State, [lua_Alloc, void_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8244 C.lua_close = F(\"lua_close\", void_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8245 C.lua_newthread = F(\"lua_newthread\", lua_State, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8246 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8247 C.lua_atpanic = F(\"lua_atpanic\", lua_CFunction, [lua_State, lua_CFunction]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8248 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8249 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8250 ** basic stack manipulation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8251 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8252 C.lua_gettop = F(\"lua_gettop\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8253 C.lua_settop = F(\"lua_settop\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8254 C.lua_pushvalue = F(\"lua_pushvalue\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8255 C.lua_remove = F(\"lua_remove\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8256 C.lua_insert = F(\"lua_insert\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8257 C.lua_replace = F(\"lua_replace\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8258 C.lua_checkstack = F(\"lua_checkstack\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8259 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8260 C.lua_xmove = F(\"lua_xmove\", void_t, [lua_State, lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8261 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8262 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8263 ** access functions (stack -> C)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8264 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8265 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8266 C.lua_isnumber = F(\"lua_isnumber\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8267 C.lua_isstring = F(\"lua_isstring\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8268 C.lua_iscfunction = F(\"lua_iscfunction\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8269 C.lua_isuserdata = F(\"lua_isuserdata\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8270 C.lua_type = F(\"lua_type\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8271 C.lua_typename = F(\"lua_typename\", const_char_ptr_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8272 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8273 C.lua_equal = F(\"lua_equal\", int_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8274 C.lua_rawequal = F(\"lua_rawequal\", int_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8275 C.lua_lessthan = F(\"lua_lessthan\", int_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8276 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8277 C.lua_tonumber = F(\"lua_tonumber\", lua_Number, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8278 C.lua_tointeger = F(\"lua_tointeger\", lua_Integer, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8279 C.lua_toboolean = F(\"lua_toboolean\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8280 C.lua_tolstring = F(\"lua_tolstring\", const_char_ptr_t, [lua_State, int_t, size_t_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8281 C.lua_objlen = F(\"lua_objlen\", size_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8282 C.lua_tocfunction = F(\"lua_tocfunction\", lua_CFunction, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8283 C.lua_touserdata = F(\"lua_touserdata\", void_ptr_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8284 C.lua_tothread = F(\"lua_tothread\", lua_State, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8285 C.lua_topointer = F(\"lua_topointer\", const_void_ptr_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8286 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8287 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8288 ** push functions (C -> stack)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8289 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8290 C.lua_pushnil = F(\"lua_pushnil\", void_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8291 C.lua_pushnumber = F(\"lua_pushnumber\", void_t, [lua_State, lua_Number]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8292 C.lua_pushinteger = F(\"lua_pushinteger\", void_t, [lua_State, lua_Integer]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8293 C.lua_pushlstring = F(\"lua_pushlstring\", void_t, [lua_State, const_char_ptr_t, size_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8294 C.lua_pushstring = F(\"lua_pushstring\", void_t, [lua_State, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8295 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8296 // TODO: Support these.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8297 LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8298 va_list argp);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8299 LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8300 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8301 C.lua_pushcclosure = F(\"lua_pushcclosure\", void_t, [lua_State, lua_CFunction, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8302 C.lua_pushboolean = F(\"lua_pushboolean\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8303 C.lua_pushlightuserdata = F(\"lua_pushlightuserdata\", void_t, [lua_State, void_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8304 C.lua_pushthread = F(\"lua_pushthread\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8305 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8306 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8307 ** get functions (Lua -> stack)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8308 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8309 C.lua_gettable = F(\"lua_gettable\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8310 C.lua_getfield = F(\"lua_getfield\", void_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8311 C.lua_rawget = F(\"lua_rawget\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8312 C.lua_rawgeti = F(\"lua_rawgeti\", void_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8313 C.lua_createtable = F(\"lua_createtable\", void_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8314 C.lua_newuserdata = F(\"lua_newuserdata\", void_ptr_t, [lua_State, size_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8315 C.lua_getmetatable = F(\"lua_getmetatable\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8316 C.lua_getfenv = F(\"lua_getfenv\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8317 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8318 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8319 ** set functions (stack -> Lua)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8320 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8321 C.lua_settable = F(\"lua_settable\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8322 C.lua_setfield = F(\"lua_setfield\", void_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8323 C.lua_rawset = F(\"lua_rawset\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8324 C.lua_rawseti = F(\"lua_rawseti\", void_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8325 C.lua_setmetatable = F(\"lua_setmetatable\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8326 C.lua_setfenv = F(\"lua_setfenv\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8327 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8328 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8329 ** `load' and `call' functions (load and run Lua code)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8330 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8331 C.lua_call = F(\"lua_call\", void_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8332 C.lua_pcall = F(\"lua_pcall\", int_t, [lua_State, int_t, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8333 C.lua_cpcall = F(\"lua_cpcall\", int_t, [lua_State, lua_CFunction, void_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8334 C.lua_load = F(\"lua_load\", int_t, [lua_State, lua_Reader, void_ptr_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8335 const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8336 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8337 C.lua_dump = F(\"lua_dump\", int_t, [lua_State, lua_Writer, void_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8338 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8339 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8340 ** coroutine functions\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8341 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8342 C.lua_yield = F(\"lua_yield\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8343 C.lua_resume = F(\"lua_resume\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8344 C.lua_status = F(\"lua_status\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8345 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8346 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8347 ** garbage-collection function and options\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8348 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8349 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8350 C.LUA_GCSTOP = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8351 C.LUA_GCRESTART = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8352 C.LUA_GCCOLLECT = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8353 C.LUA_GCCOUNT = 3;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8354 C.LUA_GCCOUNTB = 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8355 C.LUA_GCSTEP = 5;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8356 C.LUA_GCSETPAUSE = 6;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8357 C.LUA_GCSETSTEPMUL = 7;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8358 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8359 C.lua_gc = F(\"lua_gc\", int_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8360 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8361 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8362 ** miscellaneous functions\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8363 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8364 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8365 C.lua_error = F(\"lua_error\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8366 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8367 C.lua_next = F(\"lua_next\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8368 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8369 C.lua_concat = F(\"lua_concat\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8370 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8371 C.lua_getallocf = F(\"lua_getallocf\", lua_Alloc, [lua_State, void_ptr_t_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8372 C.lua_setallocf = F(\"lua_setallocf\", void_t, [lua_State, lua_Alloc, void_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8373 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8374 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8375 ** ===============================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8376 ** some useful macros\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8377 ** ===============================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8378 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8379 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8380 C.lua_pop = function(L,n) { return C.lua_settop(L, -(n)-1); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8381 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8382 C.lua_newtable = function(L) { return C.lua_createtable(L, 0, 0); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8383 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8384 C.lua_register = function(L,n,f) { return (C.lua_pushcfunction(L, (f)), C.lua_setglobal(L, (n))); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8385 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8386 C.lua_pushcfunction = function(L,f) { return C.lua_pushcclosure(L, (f), 0); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8387 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8388 C.lua_strlen = function(L,i) { return C.lua_objlen(L, (i)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8389 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8390 C.lua_isfunction = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TFUNCTION); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8391 C.lua_istable = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TTABLE); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8392 C.lua_islightuserdata = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TLIGHTUSERDATA); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8393 C.lua_isnil = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TNIL); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8394 C.lua_isboolean = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TBOOLEAN); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8395 C.lua_isthread = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TTHREAD); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8396 C.lua_isnone = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TNONE); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8397 C.lua_isnoneornil = function(L, n) { return (C.lua_type(L, (n)) <= 0); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8398 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8399 C.lua_pushliteral = C.lua_pushstring;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8400 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8401 C.lua_setglobal = function(L,s) { return C.lua_setfield(L, C.LUA_GLOBALSINDEX, (s)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8402 C.lua_getglobal = function(L,s) { return C.lua_getfield(L, C.LUA_GLOBALSINDEX, (s)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8403 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8404 C.lua_tostring = function(L,i) { return C.lua_tolstring(L, (i), NULL); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8405 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8406 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8407 ** compatibility macros and functions\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8408 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8409 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8410 C.lua_open = function() { return C.luaL_newstate(); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8411 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8412 C.lua_getregistry = function(L) { return C.lua_pushvalue(L, C.LUA_REGISTRYINDEX); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8413 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8414 C.lua_getgccount = function(L) { return C.lua_gc(L, C.LUA_GCCOUNT, 0); }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8415 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8416 var lua_Chunkreader = lua_Reader;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8417 var lua_Chunkwriter = lua_Writer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8418 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8419 /* hack */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8420 C.lua_setlevel = F(\"lua_setlevel\", void_t, [lua_State, lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8421 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8422 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8423 ** {======================================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8424 ** Debug API\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8425 ** =======================================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8426 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8427 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8428 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8429 ** Event codes\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8430 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8431 C.LUA_HOOKCALL = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8432 C.LUA_HOOKRET = 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8433 C.LUA_HOOKLINE = 2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8434 C.LUA_HOOKCOUNT = 3;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8435 C.LUA_HOOKTAILRET = 4;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8436 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8437 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8438 ** Event masks\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8439 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8440 C.LUA_MASKCALL = (1 << C.LUA_HOOKCALL);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8441 C.LUA_MASKRET = (1 << C.LUA_HOOKRET);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8442 C.LUA_MASKLINE = (1 << C.LUA_HOOKLINE);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8443 C.LUA_MASKCOUNT = (1 << C.LUA_HOOKCOUNT);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8444 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8445 // TODO: Support these. (Note LUA_IDSIZE.)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8446 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8447 typedef struct lua_Debug lua_Debug; /* activation record * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8448 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8449 /* Functions to be called by the debuger in specific events * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8450 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8451 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8452 LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8453 LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8454 LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8455 LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8456 LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8457 LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8458 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8459 LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8460 LUA_API lua_Hook lua_gethook (lua_State *L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8461 LUA_API int lua_gethookmask (lua_State *L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8462 LUA_API int lua_gethookcount (lua_State *L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8463 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8464 struct lua_Debug {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8465 int event;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8466 const char *name; /* (n) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8467 const char *namewhat; /* (n) `global', `local', `field', `method' * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8468 const char *what; /* (S) `Lua', `C', `main', `tail' * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8469 const char *source; /* (S) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8470 int currentline; /* (l) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8471 int nups; /* (u) number of upvalues * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8472 int linedefined; /* (S) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8473 int lastlinedefined; /* (S) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8474 char short_src[LUA_IDSIZE]; /* (S) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8475 /* private part * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8476 int i_ci; /* active function * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8477 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8478 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8479 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8480 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8481 // lualib.h.js: Lua 5.1 C API, lualib.h definitions (fragment file)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8482 // This file is a part of lua5.1.js project:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8483 // Copyright (c) LogicEditor <info@logiceditor.com>\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8484 // Copyright (c) lua5.1.js authors\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8485 // See file `COPYRIGHT` for the license\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8486 // Based on original Lua 5.1.5 header files:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8487 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8488 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8489 // Note: Keeping this file as close to Lua sources as possible.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8490 // This includes avoiding breaking lines at 80 char limit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8491 // to keep original formatting despite JS code being somewhat longer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8492 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8493 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8494 /* Key to file-handle type */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8495 C.LUA_FILEHANDLE = \"FILE*\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8496 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8497 C.LUA_COLIBNAME = \"coroutine\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8498 C.luaopen_base = F(\"luaopen_base\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8499 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8500 C.LUA_TABLIBNAME = \"table\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8501 C.luaopen_table = F(\"luaopen_table\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8502 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8503 C.LUA_IOLIBNAME = \"io\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8504 C.luaopen_io = F(\"luaopen_io\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8505 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8506 C.LUA_OSLIBNAME = \"os\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8507 C.luaopen_os = F(\"luaopen_os\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8508 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8509 C.LUA_STRLIBNAME = \"string\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8510 C.luaopen_string = F(\"luaopen_string\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8511 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8512 C.LUA_MATHLIBNAME = \"math\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8513 C.luaopen_math = F(\"luaopen_math\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8514 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8515 C.LUA_DBLIBNAME = \"debug\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8516 C.luaopen_debug = F(\"luaopen_debug\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8517 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8518 C.LUA_LOADLIBNAME = \"package\";\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8519 C.luaopen_package = F(\"luaopen_package\", int_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8520 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8521 /* open all previous libraries */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8522 C.luaL_openlibs = F(\"luaL_openlibs\", void_t, [lua_State]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8523 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8524 C.lua_assert = function() { }; // Do nothing.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8525 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8526 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8527 // lauxlib.h.js: Lua 5.1 C API, lauxlib.h definitions (fragment file)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8528 // This file is a part of lua5.1.js project:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8529 // Copyright (c) LogicEditor <info@logiceditor.com>\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8530 // Copyright (c) lua5.1.js authors\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8531 // See file `COPYRIGHT` for the license\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8532 // Based on original Lua 5.1.5 header files:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8533 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8534 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8535 // Note: Keeping this file as close to Lua sources as possible.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8536 // This includes avoiding breaking lines at 80 char limit\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8537 // to keep original formatting despite JS code being somewhat longer.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8538 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8539 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8540 C.luaL_getn = function(L,i) { return C.lua_objlen(L, i); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8541 C.luaL_setn = function(L,i,j) { }; /* no op! */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8542 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8543 // C.luaI_openlib defined below\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8544 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8545 /* extra error code for `luaL_load' */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8546 C.LUA_ERRFILE = (C.LUA_ERRERR+1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8547 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8548 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8549 // TODO: Support these.\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8550 typedef struct luaL_Reg {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8551 const char *name;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8552 lua_CFunction func;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8553 } luaL_Reg;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8554 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8555 LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8556 const luaL_Reg *l, int nup);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8557 LUALIB_API void (luaL_register) (lua_State *L, const char *libname,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8558 const luaL_Reg *l);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8559 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8560 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8561 C.luaL_getmetafield = F(\"luaL_getmetafield\", int_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8562 C.luaL_callmeta = F(\"luaL_callmeta\", int_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8563 C.luaL_typerror = F(\"luaL_typerror\", int_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8564 C.luaL_argerror = F(\"luaL_argerror\", int_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8565 C.luaL_checklstring = F(\"luaL_checklstring\", const_char_ptr_t, [lua_State, int_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8566 size_t_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8567 C.luaL_optlstring = F(\"luaL_optlstring\", const_char_ptr_t, [lua_State, int_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8568 const_char_ptr_t, size_t_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8569 C.luaL_checknumber = F(\"luaL_checknumber\", lua_Number, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8570 C.luaL_optnumber = F(\"luaL_optnumber\", lua_Number, [lua_State, int_t, lua_Number]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8571 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8572 C.luaL_checkinteger = F(\"luaL_checkinteger\", lua_Integer, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8573 C.luaL_optinteger = F(\"luaL_optinteger\", lua_Integer, [lua_State, int_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8574 lua_Integer]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8575 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8576 C.luaL_checkstack = F(\"luaL_checkstack\", void_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8577 C.luaL_checktype = F(\"luaL_checktype\", void_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8578 C.luaL_checkany = F(\"luaL_checkany\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8579 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8580 C.luaL_newmetatable = F(\"luaL_newmetatable\", int_t, [lua_State, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8581 C.luaL_checkudata = F(\"luaL_checkudata\", void_ptr_t, [lua_State, int_t, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8582 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8583 C.luaL_where = F(\"luaL_where\", void_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8584 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8585 // TODO: Support these\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8586 LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8587 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8588 LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8589 const char *const lst[]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8590 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8591 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8592 C.luaL_ref = F(\"luaL_ref\", int_t, [lua_State, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8593 C.luaL_unref = F(\"luaL_unref\", void_t, [lua_State, int_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8594 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8595 C.luaL_loadfile = F(\"luaL_loadfile\", int_t, [lua_State, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8596 C.luaL_loadbuffer = F(\"luaL_loadbuffer\", int_t, [lua_State, const_char_ptr_t, size_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8597 const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8598 C.luaL_loadstring = F(\"luaL_loadstring\", int_t, [lua_State, const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8599 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8600 C.luaL_newstate = F(\"luaL_newstate\", lua_State, []);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8601 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8602 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8603 C.luaL_gsub = F(\"luaL_gsub\", const_char_ptr_t, [lua_State, const_char_ptr_t, const_char_ptr_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8604 const_char_ptr_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8605 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8606 C.luaL_findtable = F(\"luaL_findtable\", const_char_ptr_t, [lua_State, int_t,\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8607 const_char_ptr_t, int_t]);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8608 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8609 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8610 ** ===============================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8611 ** some useful macros\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8612 ** ===============================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8613 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8614 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8615 C.luaL_argcheck = function(L, cond,numarg,extramsg) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8616 if (!cond) { C.luaL_argerror(L, (numarg), (extramsg)); } };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8617 C.luaL_checkstring = function(L,n) { return C.luaL_checklstring(L, (n), NULL); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8618 C.luaL_optstring = function(L,n,d) { return C.luaL_optlstring(L, (n), (d), NULL); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8619 C.luaL_checkint = C.luaL_checkinteger;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8620 C.luaL_optint = C.luaL_optinteger;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8621 C.luaL_checklong = C.luaL_checkinteger;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8622 C.luaL_optlong = C.luaL_optinteger;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8623 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8624 C.luaL_typename = function(L,i) { return C.lua_typename(L, C.lua_type(L,(i))); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8625 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8626 C.luaL_dofile = function(L, fn) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8627 return (C.luaL_loadfile(L, fn) || C.lua_pcall(L, 0, C.LUA_MULTRET, 0)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8628 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8629 C.luaL_dostring = function(L, s) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8630 return (C.luaL_loadstring(L, s) || C.lua_pcall(L, 0, C.LUA_MULTRET, 0)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8631 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8632 C.luaL_getmetatable = function(L,n) { return (C.lua_getfield(L, C.LUA_REGISTRYINDEX, (n))); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8633 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8634 C.luaL_opt = function(L,f,n,d) { return (C.lua_isnoneornil(L,(n)) ? (d) : f(L,(n))); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8635 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8636 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8637 ** {======================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8638 ** Generic Buffer manipulation\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8639 ** =======================================================\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8640 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8641 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8642 /*\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8643 // TODO: Support these\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8644 typedef struct luaL_Buffer {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8645 char *p; /* current position in buffer * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8646 int lvl; /* number of strings in the stack (level) * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8647 lua_State *L;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8648 char buffer[LUAL_BUFFERSIZE];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8649 } luaL_Buffer;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8650 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8651 #define luaL_addchar(B,c) \\\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8652 ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \\\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8653 (*(B)->p++ = (char)(c)))\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8654 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8655 /* compatibility only * /\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8656 #define luaL_putchar(B,c) luaL_addchar(B,c)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8657 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8658 #define luaL_addsize(B,n) ((B)->p += (n))\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8659 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8660 LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8661 LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8662 LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8663 LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8664 LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8665 LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8666 */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8667 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8668 /* }====================================================== */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8669 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8670 /* compatibility with ref system */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8671 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8672 /* pre-defined references */\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8673 C.LUA_NOREF = (-2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8674 C.LUA_REFNIL = (-1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8675 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8676 C.lua_ref = function(L,lock)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8677 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8678 if (lock)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8679 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8680 return C.luaL_ref(L, C.LUA_REGISTRYINDEX);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8681 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8682 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8683 C.lua_pushstring(L, \"unlocked references are obsolete\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8684 C.lua_error(L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8685 return 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8686 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8687 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8688 C.lua_unref = function(L,ref) { return C.luaL_unref(L, C.LUA_REGISTRYINDEX, (ref)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8689 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8690 C.lua_getref = function(L,ref) { return C.lua_rawgeti(L, C.LUA_REGISTRYINDEX, (ref)); };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8691 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8692 C.luaL_reg = C.luaL_Reg;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8693 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8694 ////////////////////////////////////////////////////////////////////////////////\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8695 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8696 Lua5_1.C = C;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8697 Lua5_1.Runtime = Runtime;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8698 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8699 Lua5_1.provide_file = function(parent, name, data, can_read, can_write)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8700 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8701 if (typeof(parent) === \"string\" && parent !== \"/\")\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8702 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8703 if (parent.charAt(0) !== \"/\")\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8704 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8705 throw new Error(\"can't create relative path: `\" + parent + \"'\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8706 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8707 parent = parent.substr(1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8708 parent = FS.createPath(\"/\", parent, true, true);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8709 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8710 return FS.createDataFile(parent, name, data, can_read, can_write);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8711 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8712 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8713 })(Lua5_1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8714 "e["LuaState.js"]="LuaState = (function () {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8715 var C = Lua5_1.C;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8716 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8717 function push_jsfunction(L, func, return_type, args) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8718 var arg_getters = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8719 for(var i = 0; i < args.length; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8720 arg_getters.push(\"C.luaL_check\"+args[i]+\"(L, \"+(i+1)+\")\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8721 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8722 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8723 var wrapper = eval(\"(function (func, return_type) { return (function (L) { \\\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8724 var ret = func(\"+arg_getters.join(\", \")+\"); \\\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8725 C.lua_push\"+return_type+\"(L, ret); \\\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8726 return 1; \\\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8727 }); })\")(func, return_type);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8728 C.lua_pushcfunction(L, Lua5_1.Runtime.addFunction(wrapper));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8729 return 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8730 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8731 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8732 function push_jsobject(L, obj) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8733 C.lua_newtable(L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8734 for (var key in obj) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8735 var val = obj[key];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8736 if (obj.hasOwnProperty(key)) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8737 switch(typeof val) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8738 case \"string\":\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8739 C.lua_pushstring(L, val);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8740 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8741 case \"number\":\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8742 C.lua_pushnumber(L, val);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8743 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8744 case \"object\":\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8745 push_jsobject(L, val);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8746 break;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8747 default:\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8748 C.luaL_pushfstring(L, \"Unable to convert field '%s' from type '%s'\", key, typeof val);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8749 return C.lua_error(L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8750 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8751 C.lua_setfield(L, key, -2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8752 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8753 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8754 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8755 // TODO: metatable for __index if obj.constructor !== Object?\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8756 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8757 return 1;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8758 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8759 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8760 function JSFunction(L) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8761 var funcname = C.luaL_checkstring(L, 1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8762 var ret = C.luaL_checkstring(L, 2);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8763 var n_args = C.lua_gettop(L)-2;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8764 var args = [];\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8765 for(var i = 0; i < n_args; i++) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8766 args.push(C.luaL_checkstring(L, i+3));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8767 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8768 var func = eval(funcname);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8769 if(funcname.indexOf(\".\")!=-1) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8770 func = func.bind(eval(funcname.substr(0, funcname.lastIndexOf(\".\"))));\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8771 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8772 return push_jsfunction(L, func, ret, args);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8773 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8774 var JSFunction_ptr = Lua5_1.Runtime.addFunction(JSFunction);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8775 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8776 return (function() {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8777 var L = C.lua_open();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8778 C.luaL_openlibs(L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8779 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8780 C.lua_pushcfunction(L, JSFunction_ptr);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8781 C.lua_setglobal(L, \"JSFunction\");\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8782 \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8783 return {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8784 run: function (s) {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8785 if(L == 0) throw new Error(\"Lua state is invalid\"); // FIXME\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8786 if (C.luaL_dostring(L, s) != 0)\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8787 {\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8788 var err = C.lua_tostring(L, -1);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8789 C.lua_close(L);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8790 L = 0;\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8791 throw new Error(\"Lua error: \" + err);\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8792 } \
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8793 }\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8794 };\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8795 });\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8796 })();\
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8797 "function require_resource(t)return e[t]or error("resource '"..tostring(t).."' not found");end end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8798 pcall(require,"luarocks.require");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8799 local o={v="verbose",vv="very_verbose",o="output",q="quiet",qq="very_quiet",g="debug"}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8800 local e={use_http=false};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8801 for t,a in ipairs(arg)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8802 if a:match("^%-")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8803 local t=a:match("^%-%-?([^%s=]+)()")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8804 t=(o[t]or t):gsub("%-+","_");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8805 if t:match("^no_")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8806 t=t:sub(4,-1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8807 e[t]=false;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8808 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8809 e[t]=a:match("=(.*)$")or true;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8810 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8811 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8812 base_path=a;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8813 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8814 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8815 if e.very_verbose then e.verbose=true;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8816 if e.very_quiet then e.quiet=true;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8817 local t=function()end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8818 local t,o,h,s=t,t,t,t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8819 if not e.very_quiet then t=print;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8820 if not e.quiet then o=print;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8821 if e.verbose or e.very_verbose then h=print;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8822 if e.very_verbose then s=print;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8823 print=h;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8824 local i,d,n={},{},{};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8825 function Module(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8826 if i[e]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8827 h("Ignoring duplicate module definition for "..e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8828 return function()end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8829 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8830 local t=#i+1;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8831 i[t]={name=e,url=___fetch_url};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8832 i[e]=i[t];
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8833 return function(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8834 i[t].path=e;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8835 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8836 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8837 function Resource(e,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8838 local t=#n+1;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8839 n[t]={name=e,path=a or e};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8840 return function(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8841 n[t].path=e;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8842 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8843 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8844 function AutoFetchURL(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8845 ___fetch_url=e;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8846 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8847 function Main(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8848 table.insert(d,e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8849 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8850 function Output(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8851 if e.output==nil then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8852 out_fn=t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8853 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8854 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8855 function Option(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8856 t=t:gsub("%-","_");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8857 if e[t]==nil then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8858 e[t]=true;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8859 return function(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8860 e[t]=a;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8861 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8862 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8863 return function()end;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8864 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8865 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8866 function GetOption(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8867 return e[t:gsub('%-','_')];
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8868 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8869 function Message(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8870 if not e.quiet then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8871 o(t);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8872 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8873 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8874 function Error(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8875 if not e.very_quiet then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8876 t(a);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8877 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8878 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8879 function Exit()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8880 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8881 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8882 base_path=(base_path or"."):gsub("/$","").."/"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8883 squishy_file=base_path.."squishy";
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8884 out_fn=e.output;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8885 local a,r=pcall(dofile,squishy_file);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8886 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8887 t("Couldn't read squishy file: "..r);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8888 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8889 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8890 if not out_fn then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8891 t("No output file specified by user or squishy file");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8892 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8893 elseif#d==0 and#i==0 and#n==0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8894 t("No files, modules or resources. Not going to generate an empty file.");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8895 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8896 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8897 local r={};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8898 function r.filesystem(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8899 local e,t=io.open(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8900 if not e then return false,t;end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8901 local t=e:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8902 e:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8903 return t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8904 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8905 if e.use_http then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8906 function r.http(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8907 local t=require"socket.http";
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8908 local t,e=t.request(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8909 if e==200 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8910 return t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8911 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8912 return false,"HTTP status code: "..tostring(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8913 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8914 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8915 function r.http(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8916 return false,"Module not found. Re-squish with --use-http option to fetch it from "..e;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8917 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8918 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8919 h("Resolving modules...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8920 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8921 local e=package.config:sub(1,1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8922 local n=package.config:sub(5,5);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8923 local o=package.path:gsub("[^;]+",function(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8924 if not t:match("^%"..e)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8925 return base_path..t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8926 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8927 end):gsub("/%./","/");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8928 local a=package.cpath:gsub("[^;]+",function(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8929 if not t:match("^%"..e)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8930 return base_path..t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8931 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8932 end):gsub("/%./","/");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8933 function resolve_module(t,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8934 t=t:gsub("%.",e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8935 for e in a:gmatch("[^;]+")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8936 e=e:gsub("%"..n,t);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8937 s("Looking for "..e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8938 local t=io.open(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8939 if t then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8940 s("Found!");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8941 t:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8942 return e;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8943 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8944 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8945 return nil;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8946 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8947 for a,e in ipairs(i)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8948 if not e.path then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8949 e.path=resolve_module(e.name,o);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8950 if not e.path then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8951 t("Couldn't resolve module: "..e.name);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8952 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8953 e.path=e.path:gsub("^"..base_path:gsub("%p","%%%1"),"");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8954 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8955 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8956 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8957 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8958 for a,e in ipairs(i)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8959 if not e.path then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8960 t("Exiting due to missing modules without a path");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8961 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8962 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8963 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8964 if e.list_files or e.list_missing_files then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8965 local function t(t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8966 if e.list_missing_files then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8967 local e=io.open(t);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8968 if e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8969 e:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8970 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8971 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8972 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8973 io.write(t,"\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8974 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8975 for a,e in pairs(d)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8976 t(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8977 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8978 for a,e in ipairs(i)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8979 t(e.path);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8980 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8981 for a,e in ipairs(n)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8982 t(e.path);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8983 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8984 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8985 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8986 o("Writing "..out_fn.."...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8987 local a,l=io.open(out_fn,"w+");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8988 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8989 t("Couldn't open output file: "..tostring(l));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8990 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8991 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8992 if e.executable then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8993 if e.executable==true then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8994 a:write("#!/usr/bin/env lua\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8995 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8996 a:write(e.executable,"\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8997 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8998 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8999 h("Packing modules...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9000 for o,i in ipairs(i)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9001 local h,d=i.name,i.path;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9002 if i.path:sub(1,1)~="/"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9003 d=base_path..i.path;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9004 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9005 s("Packing "..h.." ("..d..")...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9006 local o,n=r.filesystem(d);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9007 if(not o)and i.url then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9008 local e=i.url:gsub("%?",i.path);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9009 s("Fetching: "..e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9010 if e:match("^https?://")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9011 o,n=r.http(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9012 elseif e:match("^file://")or e:match("^[/%.]")then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9013 local e,t=io.open((e:gsub("^file://","")));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9014 if e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9015 o,n=e:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9016 e:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9017 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9018 o,n=nil,t;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9019 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9020 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9021 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9022 if o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9023 o=o:gsub("^#[^\r\n]*\r?\n","");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9024 if not e.debug then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9025 a:write("package.preload['",h,"'] = (function (...)\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9026 a:write(o);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9027 a:write(" end)\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9028 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9029 a:write("package.preload['",h,"'] = assert(loadstring(\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9030 a:write(("%q\n"):format(o));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9031 a:write(", ",("%q"):format("@"..d),"))\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9032 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9033 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9034 t("Couldn't pack module '"..h.."': "..(n or"unknown error... path to module file correct?"));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9035 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9036 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9037 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9038 if#n>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9039 h("Packing resources...")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9040 a:write("do local resources = {};\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9041 for o,e in ipairs(n)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9042 local o,e=e.name,e.path;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9043 local e,i=io.open(base_path..e,"rb");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9044 if not e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9045 t("Couldn't load resource: "..tostring(i));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9046 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9047 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9048 local t=e:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9049 local e=0;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9050 t:gsub("(=+)",function(t)e=math.max(e,#t);end);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9051 a:write(("resources[%q] = %q"):format(o,t));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9052 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9053 if e.virtual_io then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9054 local e=require_resource("vio");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9055 if not e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9056 t("Virtual IO requested but is not enabled in this build of squish");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9057 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9058 a:write(e,"\n")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9059 a:write[[local io_open, io_lines = io.open, io.lines; function io.open(fn, mode)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9060 if not resources[fn] then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9061 return io_open(fn, mode);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9062 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9063 return vio.open(resources[fn]);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9064 end end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9065 function io.lines(fn)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9066 if not resources[fn] then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9067 return io_lines(fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9068 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9069 return vio.open(resources[fn]):lines()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9070 end end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9071 local _dofile = dofile;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9072 function dofile(fn)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9073 if not resources[fn] then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9074 return _dofile(fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9075 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9076 return assert(loadstring(resources[fn]))();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9077 end end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9078 local _loadfile = loadfile;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9079 function loadfile(fn)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9080 if not resources[fn] then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9081 return _loadfile(fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9082 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9083 return loadstring(resources[fn], "@"..fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9084 end end ]]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9085 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9086 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9087 a:write[[function require_resource(name) return resources[name] or error("resource '"..tostring(name).."' not found"); end end ]]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9088 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9089 s("Finalising...")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9090 for e,o in pairs(d)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9091 local e,i=io.open(base_path..o);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9092 if not e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9093 t("Failed to open "..o..": "..i);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9094 os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9095 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9096 a:write((e:read("*a"):gsub("^#.-\n","")));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9097 e:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9098 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9099 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9100 a:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9101 o("OK!");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9102 local s=require"optlex"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9103 local h=require"optparser"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9104 local a=require"llex"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9105 local r=require"lparser"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9106 local i={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9107 none={};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9108 debug={"whitespace","locals","entropy","comments","numbers"};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9109 default={"comments","whitespace","emptylines","numbers","locals"};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9110 basic={"comments","whitespace","emptylines"};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9111 full={"comments","whitespace","emptylines","eols","strings","numbers","locals","entropy"};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9112 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9113 if e.minify_level and not i[e.minify_level]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9114 t("Unknown minify level: "..e.minify_level);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9115 t("Available minify levels: none, basic, default, full, debug");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9116 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9117 for a,t in ipairs(i[e.minify_level or"default"]or{})do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9118 if e["minify_"..t]==nil then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9119 e["minify_"..t]=true;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9120 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9121 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9122 local n={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9123 ["opt-locals"]=e.minify_locals;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9124 ["opt-comments"]=e.minify_comments;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9125 ["opt-entropy"]=e.minify_entropy;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9126 ["opt-whitespace"]=e.minify_whitespace;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9127 ["opt-emptylines"]=e.minify_emptylines;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9128 ["opt-eols"]=e.minify_eols;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9129 ["opt-strings"]=e.minify_strings;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9130 ["opt-numbers"]=e.minify_numbers;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9131 }
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9132 local function i(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9133 t("minify: "..e);os.exit(1);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9134 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9135 local function l(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9136 local t=io.open(e,"rb")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9137 if not t then i("cannot open \""..e.."\" for reading")end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9138 local a=t:read("*a")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9139 if not a then i("cannot read from \""..e.."\"")end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9140 t:close()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9141 return a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9142 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9143 local function d(e,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9144 local t=io.open(e,"wb")
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9145 if not t then i("cannot open \""..e.."\" for writing")end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9146 local a=t:write(a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9147 if not a then i("cannot write to \""..e.."\"")end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9148 t:close()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9149 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9150 function minify_string(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9151 a.init(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9152 a.llex()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9153 local t,e,a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9154 =a.tok,a.seminfo,a.tokln
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9155 if n["opt-locals"]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9156 h.print=print
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9157 r.init(t,e,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9158 local o,a=r.parser()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9159 h.optimize(n,t,e,o,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9160 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9161 s.print=print
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9162 t,e,a
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9163 =s.optimize(n,t,e,a)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9164 local e=table.concat(e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9165 if string.find(e,"\r\n",1,1)or
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9166 string.find(e,"\n\r",1,1)then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9167 s.warn.mixedeol=true
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9168 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9169 return e;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9170 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9171 function minify_file(e,t)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9172 local e=l(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9173 e=minify_string(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9174 d(t,e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9175 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9176 if e.minify~=false then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9177 o("Minifying "..out_fn.."...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9178 minify_file(out_fn,out_fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9179 o("OK!");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9180 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9181 local s=require"llex"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9182 local i=128;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9183 local n={"and","break","do","else","elseif",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9184 "end","false","for","function","if",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9185 "in","local","nil","not","or","repeat",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9186 "return","then","true","until","while"}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9187 function uglify_file(l,o)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9188 local h,a=io.open(l);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9189 if not h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9190 t("Can't open input file for reading: "..tostring(a));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9191 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9192 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9193 local a,r=io.open(o..".uglified","wb+");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9194 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9195 t("Can't open output file for writing: "..tostring(r));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9196 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9197 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9198 local d=h:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9199 h:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9200 local h,t=d:match("^(#.-\n)(.+)$");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9201 local t=t or d;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9202 if h then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9203 a:write(h)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9204 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9205 while i+#n<=255 and t:find("["..string.char(i).."-"..string.char(i+#n-1).."]")do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9206 i=i+1;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9207 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9208 if i+#n>255 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9209 a:write(t);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9210 a:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9211 os.rename(o..".uglified",o);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9212 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9213 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9214 local r={}
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9215 for e,t in ipairs(n)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9216 r[t]=string.char(i+e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9217 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9218 local h=0;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9219 d:gsub("(=+)",function(e)h=math.max(h,#e);end);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9220 s.init(t,"@"..l);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9221 s.llex()
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9222 local t=s.seminfo;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9223 if e.uglify_level=="full"and i+#n<255 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9224 local e={};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9225 for i,o in ipairs(s.tok)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9226 if o=="TK_NAME"or o=="TK_STRING"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9227 local a=string.format("%q,%q",o,t[i]);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9228 if not e[a]then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9229 e[a]={type=o,value=t[i],count=0};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9230 e[#e+1]=e[a];
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9231 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9232 e[a].count=e[a].count+1;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9233 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9234 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9235 for t=1,#e do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9236 local e=e[t];
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9237 e.score=(e.count)*(#e.value-1)-#string.format("%q",e.value)-1;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9238 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9239 table.sort(e,function(t,e)return t.score>e.score;end);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9240 local t=255-(i+#n);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9241 for t=t+1,#e do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9242 e[t]=nil;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9243 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9244 local t=#n;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9245 for a,e in ipairs(e)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9246 if e.score>0 then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9247 table.insert(n,e.value);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9248 r[e.value]=string.char(i+t+a);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9249 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9250 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9251 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9252 a:write("local base_char,keywords=",tostring(i),",{");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9253 for t,e in ipairs(n)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9254 a:write(string.format("%q",e),',');
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9255 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9256 a:write[[}; function prettify(code) return code:gsub("["..string.char(base_char).."-"..string.char(base_char+#keywords).."]",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9257 function (c) return keywords[c:byte()-base_char]; end) end ]]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9258 a:write[[return assert(loadstring(prettify]]
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9259 a:write("[",string.rep("=",h+1),"[");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9260 for o,e in ipairs(s.tok)do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9261 if e=="TK_KEYWORD"or e=="TK_NAME"or e=="TK_STRING"then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9262 local e=r[t[o]];
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9263 if e then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9264 a:write(e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9265 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9266 a:write(t[o]);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9267 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9268 else
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9269 a:write(t[o]);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9270 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9271 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9272 a:write("]",string.rep("=",h+1),"]");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9273 a:write(", '@",o,"'))()");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9274 a:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9275 os.rename(o..".uglified",o);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9276 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9277 if e.uglify then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9278 o("Uglifying "..out_fn.."...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9279 uglify_file(out_fn,out_fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9280 o("OK!");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9281 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9282 function gzip_file(a,e)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9283 local o,a=io.open(a);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9284 if not o then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9285 t("Can't open input file for reading: "..tostring(a));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9286 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9287 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9288 local a,i=io.open(e..".gzipped","wb+");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9289 if not a then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9290 t("Can't open output file for writing: "..tostring(i));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9291 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9292 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9293 local i=o:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9294 o:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9295 local n,o=i:match("^(#.-\n)(.+)$");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9296 local o=o or i;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9297 if n then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9298 a:write(n)
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9299 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9300 local i,n=io.open(e..".pregzip","wb+");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9301 if not i then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9302 t("Can't open temp file for writing: "..tostring(n));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9303 return;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9304 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9305 i:write(o);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9306 i:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9307 local t=io.popen("gzip -c '"..e..".pregzip'");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9308 o=t:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9309 t:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9310 os.remove(e..".pregzip");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9311 local t=0;
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9312 o:gsub("(=+)",function(e)t=math.max(t,#e);end);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9313 a:write("local ungz = (function ()",require_resource"gunzip.lua"," end)()\n");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9314 a:write[[return assert(loadstring((function (i)local o={} ungz{input=i,output=function(b)table.insert(o,string.char(b))end}return table.concat(o)end) ]];
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9315 a:write((string.format("%q",o):gsub("\026","\\026")));
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9316 a:write(", '@",e,"'))()");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9317 a:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9318 os.rename(e..".gzipped",e);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9319 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9320 if e.gzip then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9321 o("Gzipping "..out_fn.."...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9322 gzip_file(out_fn,out_fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9323 o("OK!");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9324 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9325 if e.js then
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9326 o("Generating Javascript for "..out_fn.."...");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9327 local e={
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9328 ["\""]="\\\"",["\\"]="\\\\",["\b"]="\\b",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9329 ["\f"]="\\f",["\n"]="\\\n",["\r"]="\\r",["\t"]="\\t"};
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9330 for t=0,31 do
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9331 local a=string.char(t);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9332 if not e[a]then e[a]=("\\u%.4X"):format(t);end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9333 end
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9334 local t=io.open(out_fn);
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9335 local a=t:read("*a");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9336 t:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9337 local t=io.open(out_fn,"w+");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9338 t:write("(function(){\n",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9339 require_resource("lua5.1.min.js"),"\n",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9340 require_resource("LuaState.js"),"\n",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9341 "LuaState().run(\""..a:gsub(".",e).."\")\n",
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9342 "})()"
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9343 );
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9344 t:close();
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9345 o("OK!");
b3f2711684a7 Add Makefile and other files for building
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9346 end

mercurial