Software /
code /
verse
Annotate
buildscripts/squish @ 370:75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 31 Dec 2015 21:12:00 +0000 |
child | 428:bde804b01f28 |
rev | line source |
---|---|
370
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env lua |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 package.preload['optlex']=(function(...) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local s=_G |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local u=require"string" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 module"optlex" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local i=u.match |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local e=u.sub |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local r=u.find |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 local d=u.rep |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 local c |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 error=s.error |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 warn={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local n,o,l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local p={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 TK_KEYWORD=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 TK_NAME=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 TK_NUMBER=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 TK_STRING=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 TK_LSTRING=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 TK_OP=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 TK_EOS=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 local y={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 TK_COMMENT=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 TK_LCOMMENT=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 TK_EOL=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 TK_SPACE=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 local h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 local function w(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 local t=n[e-1] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 if e<=1 or t=="TK_EOL"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 return true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 elseif t==""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 return w(e-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 return false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 local function g(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 local t=n[e+1] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 if e>=#n or t=="TK_EOL"or t=="TK_EOS"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 return true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 elseif t==""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 return g(e+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 return false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 local function _(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 local t=#i(a,"^%-%-%[=*%[") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 local a=e(a,t+1,-(t-1)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 local e,t=1,0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 local o,n,i,a=r(a,"([\r\n])([\r\n]?)",e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 if not o then break end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 e=o+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 if#a>0 and i~=a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 e=e+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 return t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 local function v(s,h) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 local a=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 local t,e=n[s],n[h] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 if t=="TK_STRING"or t=="TK_LSTRING"or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 e=="TK_STRING"or e=="TK_LSTRING"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 return"" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 elseif t=="TK_OP"or e=="TK_OP"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 if(t=="TK_OP"and(e=="TK_KEYWORD"or e=="TK_NAME"))or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 (e=="TK_OP"and(t=="TK_KEYWORD"or t=="TK_NAME"))then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 return"" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 if t=="TK_OP"and e=="TK_OP"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 local t,e=o[s],o[h] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 if(a(t,"^%.%.?$")and a(e,"^%."))or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 (a(t,"^[~=<>]$")and e=="=")or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 (t=="["and(e=="["or e=="="))then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 return" " |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 return"" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 local t=o[s] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 if e=="TK_OP"then t=o[h]end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 if a(t,"^%.%.?%.?$")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 return" " |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 return"" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 return" " |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 local function b() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 local s,i,a={},{},{} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 local e=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 for t=1,#n do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 local n=n[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 if n~=""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 s[e],i[e],a[e]=n,o[t],l[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 e=e+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 n,o,l=s,i,a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 local function A(r) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 local t=o[r] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 local t=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 local n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 if i(t,"^0[xX]")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 local e=s.tostring(s.tonumber(t)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 if#e<=#t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 t=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 if i(t,"^%d+%.?0*$")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 t=i(t,"^(%d+)%.?0*$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 if t+0>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 t=i(t,"^0*([1-9]%d*)$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 local a=#i(t,"0*$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 local o=s.tostring(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 if a>#o+1 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 t=e(t,1,#t-a).."e"..o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 n=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 n="0" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 elseif not i(t,"[eE]")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 local a,t=i(t,"^(%d*)%.(%d+)$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 if a==""then a=0 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 if t+0==0 and a==0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 n="0" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 local o=#i(t,"0*$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 if o>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 t=e(t,1,#t-o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 if a+0>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 n=a.."."..t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 n="."..t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 local a=#i(t,"^0*") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 local a=#t-a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 local o=s.tostring(#t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 if a+2+#o<1+#t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 n=e(t,-a).."e-"..o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 local t,a=i(t,"^([^eE]+)[eE]([%+%-]?%d+)$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
154 a=s.tonumber(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 local h,o=i(t,"^(%d*)%.(%d*)$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
156 if h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
157 a=a-#o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 t=h..o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
159 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
160 if t+0==0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
161 n="0" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
162 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
163 local o=#i(t,"^0*") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
164 t=e(t,o+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
165 o=#i(t,"0*$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
166 if o>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
167 t=e(t,1,#t-o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
168 a=a+o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
169 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 local i=s.tostring(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 if a==0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
172 n=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 elseif a>0 and(a<=1+#i)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 n=t..d("0",a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
175 elseif a<0 and(a>=-#t)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
176 o=#t+a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
177 n=e(t,1,o).."."..e(t,o+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
178 elseif a<0 and(#i>=-a-#t)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
179 o=-a-#t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
180 n="."..d("0",o)..t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
181 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
182 n=t.."e"..a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
183 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
184 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
185 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
186 if n and n~=o[r]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
187 if h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
188 c("<number> (line "..l[r]..") "..o[r].." -> "..n) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
189 h=h+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
190 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
191 o[r]=n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
192 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
193 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
194 local function O(m) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
195 local t=o[m] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
196 local s=e(t,1,1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
197 local f=(s=="'")and'"'or"'" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
198 local t=e(t,2,-2) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
199 local a=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
200 local d,n=0,0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
201 while a<=#t do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
202 local c=e(t,a,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
203 if c=="\\"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
204 local o=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
205 local l=e(t,o,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
206 local h=r("abfnrtv\\\n\r\"\'0123456789",l,1,true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
207 if not h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
208 t=e(t,1,a-1)..e(t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
209 a=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
210 elseif h<=8 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
211 a=a+2 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
212 elseif h<=10 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
213 local i=e(t,o,o+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
214 if i=="\r\n"or i=="\n\r"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
215 t=e(t,1,a).."\n"..e(t,o+2) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
216 elseif h==10 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
217 t=e(t,1,a).."\n"..e(t,o+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
218 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
219 a=a+2 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
220 elseif h<=12 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
221 if l==s then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
222 d=d+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
223 a=a+2 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
224 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
225 n=n+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
226 t=e(t,1,a-1)..e(t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
227 a=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
228 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
229 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
230 local i=i(t,"^(%d%d?%d?)",o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
231 o=a+1+#i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
232 local l=i+0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
233 local h=u.char(l) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
234 local r=r("\a\b\f\n\r\t\v",h,1,true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
235 if r then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
236 i="\\"..e("abfnrtv",r,r) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
237 elseif l<32 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
238 i="\\"..l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
239 elseif h==s then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
240 i="\\"..h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
241 d=d+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
242 elseif h=="\\"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
243 i="\\\\" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
244 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
245 i=h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
246 if h==f then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
247 n=n+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
248 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
249 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
250 t=e(t,1,a-1)..i..e(t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
251 a=a+#i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
252 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
253 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
254 a=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
255 if c==f then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
256 n=n+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
257 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
258 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
259 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
260 if d>n then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
261 a=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
262 while a<=#t do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
263 local o,n,i=r(t,"([\'\"])",a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
264 if not o then break end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
265 if i==s then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
266 t=e(t,1,o-2)..e(t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
267 a=o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
268 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
269 t=e(t,1,o-1).."\\"..e(t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
270 a=o+2 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
271 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
272 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
273 s=f |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
274 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
275 t=s..t..s |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
276 if t~=o[m]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
277 if h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
278 c("<string> (line "..l[m]..") "..o[m].." -> "..t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
279 h=h+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
280 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
281 o[m]=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
282 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
283 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
284 local function I(u) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
285 local t=o[u] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
286 local s=i(t,"^%[=*%[") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
287 local a=#s |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
288 local c=e(t,-a,-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
289 local h=e(t,a+1,-(a+1)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
290 local n="" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
291 local t=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
292 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
293 local a,o,r,s=r(h,"([\r\n])([\r\n]?)",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
294 local o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
295 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
296 o=e(h,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
297 elseif a>=t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
298 o=e(h,t,a-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
299 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
300 if o~=""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
301 if i(o,"%s+$")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
302 warn.lstring="trailing whitespace in long string near line "..l[u] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
303 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
304 n=n..o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
305 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
306 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
307 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
308 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
309 t=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
310 if a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
311 if#s>0 and r~=s then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
312 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
313 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
314 if not(t==1 and t==a)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
315 n=n.."\n" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
316 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
317 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
318 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
319 if a>=3 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
320 local e,t=a-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
321 while e>=2 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
322 local a="%]"..d("=",e-2).."%]" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
323 if not i(n,a)then t=e end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
324 e=e-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
325 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
326 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
327 a=d("=",t-2) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
328 s,c="["..a.."[","]"..a.."]" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
329 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
330 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
331 o[u]=s..n..c |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
332 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
333 local function j(l) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
334 local a=o[l] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
335 local h=i(a,"^%-%-%[=*%[") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
336 local t=#h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
337 local u=e(a,-t,-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
338 local s=e(a,t+1,-(t-1)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
339 local n="" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
340 local a=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
341 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
342 local o,t,r,h=r(s,"([\r\n])([\r\n]?)",a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
343 local t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
344 if not o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
345 t=e(s,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
346 elseif o>=a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
347 t=e(s,a,o-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
348 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
349 if t~=""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
350 local a=i(t,"%s*$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
351 if#a>0 then t=e(t,1,-(a+1))end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
352 n=n..t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
353 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
354 if not o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
355 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
356 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
357 a=o+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
358 if o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
359 if#h>0 and r~=h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
360 a=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
361 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
362 n=n.."\n" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
363 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
364 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
365 t=t-2 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
366 if t>=3 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
367 local e,a=t-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
368 while e>=2 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
369 local t="%]"..d("=",e-2).."%]" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
370 if not i(n,t)then a=e end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
371 e=e-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
372 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
373 if a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
374 t=d("=",a-2) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
375 h,u="--["..t.."[","]"..t.."]" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
376 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
377 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
378 o[l]=h..n..u |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
379 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
380 local function q(n) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
381 local t=o[n] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
382 local a=i(t,"%s*$") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
383 if#a>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
384 t=e(t,1,-(a+1)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
385 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
386 o[n]=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
387 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
388 local function x(o,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
389 if not o then return false end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
390 local t=i(a,"^%-%-%[=*%[") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
391 local t=#t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
392 local i=e(a,-t,-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
393 local e=e(a,t+1,-(t-1)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
394 if r(e,o,1,true)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
395 return true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
396 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
397 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
398 function optimize(t,a,i,r) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
399 local f=t["opt-comments"] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
400 local u=t["opt-whitespace"] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
401 local m=t["opt-emptylines"] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
402 local k=t["opt-eols"] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
403 local E=t["opt-strings"] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
404 local T=t["opt-numbers"] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
405 local z=t.KEEP |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
406 h=t.DETAILS and 0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
407 c=c or s.print |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
408 if k then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
409 f=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
410 u=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
411 m=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
412 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
413 n,o,l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
414 =a,i,r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
415 local t=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
416 local a,r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
417 local s |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
418 local function i(a,i,e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
419 e=e or t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
420 n[e]=a or"" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
421 o[e]=i or"" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
422 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
423 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
424 a,r=n[t],o[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
425 local h=w(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
426 if h then s=nil end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
427 if a=="TK_EOS"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
428 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
429 elseif a=="TK_KEYWORD"or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
430 a=="TK_NAME"or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
431 a=="TK_OP"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
432 s=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
433 elseif a=="TK_NUMBER"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
434 if T then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
435 A(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
436 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
437 s=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
438 elseif a=="TK_STRING"or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
439 a=="TK_LSTRING"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
440 if E then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
441 if a=="TK_STRING"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
442 O(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
443 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
444 I(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
445 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
446 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
447 s=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
448 elseif a=="TK_COMMENT"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
449 if f then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
450 if t==1 and e(r,1,1)=="#"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
451 q(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
452 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
453 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
454 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
455 elseif u then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
456 q(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
457 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
458 elseif a=="TK_LCOMMENT"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
459 if x(z,r)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
460 if u then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
461 j(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
462 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
463 s=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
464 elseif f then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
465 local e=_(r) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
466 if y[n[t+1]]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
467 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
468 a="" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
469 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
470 i("TK_SPACE"," ") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
471 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
472 if not m and e>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
473 i("TK_EOL",d("\n",e)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
474 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
475 if u and a~=""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
476 t=t-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
477 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
478 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
479 if u then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
480 j(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
481 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
482 s=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
483 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
484 elseif a=="TK_EOL"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
485 if h and m then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
486 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
487 elseif r=="\r\n"or r=="\n\r"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
488 i("TK_EOL","\n") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
489 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
490 elseif a=="TK_SPACE"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
491 if u then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
492 if h or g(t)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
493 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
494 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
495 local a=n[s] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
496 if a=="TK_LCOMMENT"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
497 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
498 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
499 local e=n[t+1] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
500 if y[e]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
501 if(e=="TK_COMMENT"or e=="TK_LCOMMENT")and |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
502 a=="TK_OP"and o[s]=="-"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
503 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
504 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
505 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
506 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
507 local e=v(s,t+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
508 if e==""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
509 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
510 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
511 i("TK_SPACE"," ") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
512 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
513 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
514 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
515 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
516 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
517 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
518 error("unidentified token encountered") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
519 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
520 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
521 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
522 b() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
523 if k then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
524 t=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
525 if n[1]=="TK_COMMENT"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
526 t=3 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
527 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
528 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
529 a,r=n[t],o[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
530 if a=="TK_EOS"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
531 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
532 elseif a=="TK_EOL"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
533 local a,e=n[t-1],n[t+1] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
534 if p[a]and p[e]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
535 local e=v(t-1,t+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
536 if e==""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
537 i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
538 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
539 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
540 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
541 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
542 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
543 b() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
544 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
545 if h and h>0 then c()end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
546 return n,o,l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
547 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
548 end) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
549 package.preload['optparser']=(function(...) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
550 local e=_G |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
551 local a=require"string" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
552 local f=require"table" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
553 module"optparser" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
554 local s="etaoinshrdlucmfwypvbgkqjxz_ETAOINSHRDLUCMFWYPVBGKQJXZ" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
555 local r="etaoinshrdlucmfwypvbgkqjxz_0123456789ETAOINSHRDLUCMFWYPVBGKQJXZ" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
556 local w={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
557 for e in a.gmatch([[ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
558 and break do else elseif end false for function if in |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
559 local nil not or repeat return then true until while |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
560 self]],"%S+")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
561 w[e]=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
562 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
563 local h,m, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
564 u,o, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
565 l,y, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
566 d, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
567 n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
568 local function c(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
569 local o={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
570 for n=1,#e do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
571 local e=e[n] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
572 local i=e.name |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
573 if not o[i]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
574 o[i]={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
575 decl=0,token=0,size=0, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
576 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
577 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
578 local t=o[i] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
579 t.decl=t.decl+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
580 local o=e.xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
581 local a=#o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
582 t.token=t.token+a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
583 t.size=t.size+a*#i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
584 if e.decl then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
585 e.id=n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
586 e.xcount=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
587 if a>1 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
588 e.first=o[2] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
589 e.last=o[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
590 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
591 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
592 t.id=n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
593 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
594 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
595 return o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
596 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
597 local function v(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
598 local n=a.byte |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
599 local d=a.char |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
600 local a={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
601 TK_KEYWORD=true,TK_NAME=true,TK_NUMBER=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
602 TK_STRING=true,TK_LSTRING=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
603 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
604 if not e["opt-comments"]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
605 a.TK_COMMENT=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
606 a.TK_LCOMMENT=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
607 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
608 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
609 for e=1,#h do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
610 t[e]=m[e] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
611 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
612 for e=1,#o do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
613 local e=o[e] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
614 local a=e.xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
615 for e=1,e.xcount do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
616 local e=a[e] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
617 t[e]="" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
618 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
619 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
620 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
621 for t=0,255 do e[t]=0 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
622 for o=1,#h do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
623 local o,t=h[o],t[o] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
624 if a[o]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
625 for a=1,#t do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
626 local t=n(t,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
627 e[t]=e[t]+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
628 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
629 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
630 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
631 local function i(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
632 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
633 for o=1,#a do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
634 local a=n(a,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
635 t[o]={c=a,freq=e[a],} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
636 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
637 f.sort(t, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
638 function(t,e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
639 return t.freq>e.freq |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
640 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
641 ) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
642 local a={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
643 for e=1,#t do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
644 a[e]=d(t[e].c) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
645 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
646 return f.concat(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
647 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
648 s=i(s) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
649 r=i(r) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
650 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
651 local function p() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
652 local t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
653 local n,h=#s,#r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
654 local e=d |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
655 if e<n then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
656 e=e+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
657 t=a.sub(s,e,e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
658 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
659 local o,i=n,1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
660 repeat |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
661 e=e-o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
662 o=o*h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
663 i=i+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
664 until o>e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
665 local o=e%n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
666 e=(e-o)/n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
667 o=o+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
668 t=a.sub(s,o,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
669 while i>1 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
670 local o=e%h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
671 e=(e-o)/h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
672 o=o+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
673 t=t..a.sub(r,o,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
674 i=i-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
675 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
676 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
677 d=d+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
678 return t,l[t]~=nil |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
679 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
680 function optimize(e,a,s,i,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
681 h,m,u,o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
682 =a,s,i,t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
683 d=0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
684 n={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
685 l=c(u) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
686 y=c(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
687 if e["opt-entropy"]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
688 v(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
689 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
690 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
691 for t=1,#o do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
692 e[t]=o[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
693 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
694 f.sort(e, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
695 function(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
696 return e.xcount>t.xcount |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
697 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
698 ) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
699 local a,t,r={},1,false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
700 for o=1,#e do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
701 local e=e[o] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
702 if not e.isself then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
703 a[t]=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
704 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
705 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
706 r=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
707 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
708 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
709 e=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
710 local s=#e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
711 while s>0 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
712 local h,t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
713 repeat |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
714 h,t=p() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
715 until not w[h] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
716 n[#n+1]=h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
717 local a=s |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
718 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
719 local i=u[l[h].id].xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
720 local h=#i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
721 for t=1,s do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
722 local t=e[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
723 local n,e=t.act,t.rem |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
724 while e<0 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
725 e=o[-e].rem |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
726 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
727 local o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
728 for t=1,h do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
729 local t=i[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
730 if t>=n and t<=e then o=true end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
731 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
732 if o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
733 t.skip=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
734 a=a-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
735 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
736 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
737 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
738 while a>0 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
739 local t=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
740 while e[t].skip do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
741 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
742 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
743 a=a-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
744 local i=e[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
745 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
746 i.newname=h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
747 i.skip=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
748 i.done=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
749 local s,r=i.first,i.last |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
750 local h=i.xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
751 if s and a>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
752 local n=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
753 while n>0 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
754 while e[t].skip do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
755 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
756 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
757 n=n-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
758 local e=e[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
759 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
760 local n,t=e.act,e.rem |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
761 while t<0 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
762 t=o[-t].rem |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
763 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
764 if not(r<n or s>t)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
765 if n>=i.act then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
766 for o=1,i.xcount do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
767 local o=h[o] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
768 if o>=n and o<=t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
769 a=a-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
770 e.skip=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
771 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
772 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
773 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
774 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
775 if e.last and e.last>=i.act then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
776 a=a-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
777 e.skip=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
778 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
779 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
780 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
781 if a==0 then break end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
782 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
783 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
784 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
785 local a,t={},1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
786 for o=1,s do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
787 local e=e[o] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
788 if not e.done then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
789 e.skip=false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
790 a[t]=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
791 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
792 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
793 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
794 e=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
795 s=#e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
796 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
797 for e=1,#o do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
798 local e=o[e] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
799 local t=e.xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
800 if e.newname then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
801 for a=1,e.xcount do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
802 local t=t[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
803 m[t]=e.newname |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
804 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
805 e.name,e.oldname |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
806 =e.newname,e.name |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
807 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
808 e.oldname=e.name |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
809 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
810 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
811 if r then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
812 n[#n+1]="self" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
813 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
814 local e=c(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
815 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
816 end) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
817 package.preload['llex']=(function(...) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
818 local f=_G |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
819 local r=require"string" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
820 module"llex" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
821 local l=r.find |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
822 local c=r.match |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
823 local i=r.sub |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
824 local m={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
825 for e in r.gmatch([[ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
826 and break do else elseif end false for function if in |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
827 local nil not or repeat return then true until while]],"%S+")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
828 m[e]=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
829 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
830 local e, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
831 d, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
832 a, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
833 n, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
834 h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
835 local function o(t,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
836 local e=#tok+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
837 tok[e]=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
838 seminfo[e]=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
839 tokln[e]=h |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
840 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
841 local function s(t,s) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
842 local n=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
843 local i=n(e,t,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
844 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
845 local e=n(e,t,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
846 if(e=="\n"or e=="\r")and(e~=i)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
847 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
848 i=i..e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
849 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
850 if s then o("TK_EOL",i)end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
851 h=h+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
852 a=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
853 return t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
854 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
855 function init(t,i) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
856 e=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
857 d=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
858 a=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
859 h=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
860 tok={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
861 seminfo={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
862 tokln={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
863 local i,n,e,t=l(e,"^(#[^\r\n]*)(\r?\n?)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
864 if i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
865 a=a+#e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
866 o("TK_COMMENT",e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
867 if#t>0 then s(a,true)end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
868 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
869 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
870 function chunkid() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
871 if d and c(d,"^[=@]")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
872 return i(d,2) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
873 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
874 return"[string]" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
875 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
876 function errorline(a,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
877 local e=error or f.error |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
878 e(r.format("%s:%d: %s",chunkid(),t or h,a)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
879 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
880 local r=errorline |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
881 local function u(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
882 local i=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
883 local n=i(e,t,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
884 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
885 local o=#c(e,"=*",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
886 t=t+o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
887 a=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
888 return(i(e,t,t)==n)and o or(-o)-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
889 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
890 local function w(h,d) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
891 local t=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
892 local i=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
893 local o=i(e,t,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
894 if o=="\r"or o=="\n"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
895 t=s(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
896 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
897 local o=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
898 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
899 local o,c,l=l(e,"([\r\n%]])",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
900 if not o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
901 r(h and"unfinished long string"or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
902 "unfinished long comment") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
903 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
904 t=o |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
905 if l=="]"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
906 if u(t)==d then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
907 n=i(e,n,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
908 a=a+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
909 return n |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
910 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
911 t=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
912 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
913 n=n.."\n" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
914 t=s(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
915 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
916 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
917 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
918 local function y(u) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
919 local t=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
920 local h=l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
921 local d=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
922 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
923 local i,l,o=h(e,"([\n\r\\\"\'])",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
924 if i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
925 if o=="\n"or o=="\r"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
926 r("unfinished string") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
927 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
928 t=i |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
929 if o=="\\"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
930 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
931 o=d(e,t,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
932 if o==""then break end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
933 i=h("abfnrtv\n\r",o,1,true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
934 if i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
935 if i>7 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
936 t=s(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
937 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
938 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
939 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
940 elseif h(o,"%D")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
941 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
942 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
943 local o,e,a=h(e,"^(%d%d?%d?)",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
944 t=e+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
945 if a+1>256 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
946 r("escape sequence too large") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
947 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
948 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
949 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
950 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
951 if o==u then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
952 a=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
953 return d(e,n,t-1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
954 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
955 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
956 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
957 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
958 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
959 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
960 r("unfinished string") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
961 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
962 function llex() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
963 local h=l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
964 local l=c |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
965 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
966 local t=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
967 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
968 local c,p,d=h(e,"^([_%a][_%w]*)",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
969 if c then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
970 a=t+#d |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
971 if m[d]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
972 o("TK_KEYWORD",d) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
973 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
974 o("TK_NAME",d) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
975 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
976 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
977 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
978 local d,m,c=h(e,"^(%.?)%d",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
979 if d then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
980 if c=="."then t=t+1 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
981 local u,s,n=h(e,"^%d*[%.%d]*([eE]?)",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
982 t=s+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
983 if#n==1 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
984 if l(e,"^[%+%-]",t)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
985 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
986 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
987 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
988 local n,t=h(e,"^[_%w]*",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
989 a=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
990 local e=i(e,d,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
991 if not f.tonumber(e)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
992 r("malformed number") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
993 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
994 o("TK_NUMBER",e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
995 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
996 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
997 local c,m,f,d=h(e,"^((%s)[ \t\v\f]*)",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
998 if c then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
999 if d=="\n"or d=="\r"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1000 s(t,true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1001 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1002 a=m+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1003 o("TK_SPACE",f) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1004 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1005 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1006 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1007 local s=l(e,"^%p",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1008 if s then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1009 n=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1010 local d=h("-[\"\'.=<>~",s,1,true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1011 if d then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1012 if d<=2 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1013 if d==1 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1014 local r=l(e,"^%-%-(%[?)",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1015 if r then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1016 t=t+2 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1017 local s=-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1018 if r=="["then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1019 s=u(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1020 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1021 if s>=0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1022 o("TK_LCOMMENT",w(false,s)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1023 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1024 a=h(e,"[\n\r]",t)or(#e+1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1025 o("TK_COMMENT",i(e,n,a-1)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1026 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1027 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1028 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1029 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1030 local e=u(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1031 if e>=0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1032 o("TK_LSTRING",w(true,e)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1033 elseif e==-1 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1034 o("TK_OP","[") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1035 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1036 r("invalid long string delimiter") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1037 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1038 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1039 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1040 elseif d<=5 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1041 if d<5 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1042 a=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1043 o("TK_STRING",y(s)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1044 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1045 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1046 s=l(e,"^%.%.?%.?",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1047 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1048 s=l(e,"^%p=?",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1049 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1050 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1051 a=t+#s |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1052 o("TK_OP",s) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1053 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1054 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1055 local e=i(e,t,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1056 if e~=""then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1057 a=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1058 o("TK_OP",e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1059 break |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1060 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1061 o("TK_EOS","") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1062 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1063 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1064 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1065 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1066 return _M |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1067 end) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1068 package.preload['lparser']=(function(...) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1069 local R=_G |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1070 local p=require"string" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1071 module"lparser" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1072 local _, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1073 q, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1074 z, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1075 S, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1076 u, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1077 r, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1078 V, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1079 t,k,l,f, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1080 w, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1081 a, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1082 K, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1083 j, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1084 I, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1085 d, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1086 b, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1087 A |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1088 local v,h,y,E,T,x |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1089 local e=p.gmatch |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1090 local D={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1091 for e in e("else elseif end until <eof>","%S+")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1092 D[e]=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1093 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1094 local B={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1095 for e in e("if while do for repeat function local return break","%S+")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1096 B[e]=e.."_stat" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1097 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1098 local L={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1099 local G={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1100 for e,t,a in e([[ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1101 {+ 6 6}{- 6 6}{* 7 7}{/ 7 7}{% 7 7} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1102 {^ 10 9}{.. 5 4} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1103 {~= 3 3}{== 3 3} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1104 {< 3 3}{<= 3 3}{> 3 3}{>= 3 3} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1105 {and 2 2}{or 1 1} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1106 ]],"{(%S+)%s(%d+)%s(%d+)}")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1107 L[e]=t+0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1108 G[e]=a+0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1109 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1110 local Z={["not"]=true,["-"]=true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1111 ["#"]=true,} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1112 local X=8 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1113 local function o(a,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1114 local e=error or R.error |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1115 e(p.format("(source):%d: %s",t or l,a)) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1116 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1117 local function e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1118 V=z[u] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1119 t,k,l,f |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1120 =_[u],q[u],z[u],S[u] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1121 u=u+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1122 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1123 local function J() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1124 return _[u] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1125 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1126 local function n(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1127 local e=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1128 if e~="<number>"and e~="<string>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1129 if e=="<name>"then e=k end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1130 e="'"..e.."'" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1131 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1132 o(a.." near "..e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1133 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1134 local function c(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1135 n("'"..e.."' expected") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1136 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1137 local function o(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1138 if t==a then e();return true end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1139 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1140 local function O(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1141 if t~=e then c(e)end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1142 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1143 local function i(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1144 O(t);e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1145 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1146 local function Q(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1147 if not e then n(t)end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1148 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1149 local function s(e,a,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1150 if not o(e)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1151 if t==l then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1152 c(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1153 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1154 n("'"..e.."' expected (to close '"..a.."' at line "..t..")") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1155 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1156 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1157 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1158 local function m() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1159 O("<name>") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1160 local t=k |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1161 w=f |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1162 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1163 return t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1164 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1165 local function N(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1166 e.k="VK" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1167 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1168 local function U(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1169 N(e,m()) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1170 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1171 local function c(o,i) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1172 local t=a.bl |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1173 local e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1174 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1175 e=t.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1176 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1177 e=a.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1178 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1179 local t=#d+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1180 d[t]={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1181 name=o, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1182 xref={w}, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1183 decl=w, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1184 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1185 if i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1186 d[t].isself=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1187 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1188 local a=#b+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1189 b[a]=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1190 A[a]=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1191 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1192 local function g(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1193 local t=#b |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1194 while e>0 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1195 e=e-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1196 local t=t-e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1197 local a=b[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1198 local e=d[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1199 local o=e.name |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1200 e.act=f |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1201 b[t]=nil |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1202 local i=A[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1203 A[t]=nil |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1204 local t=i[o] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1205 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1206 e=d[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1207 e.rem=-a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1208 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1209 i[o]=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1210 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1211 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1212 local function H() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1213 local t=a.bl |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1214 local e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1215 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1216 e=t.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1217 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1218 e=a.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1219 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1220 for t,e in R.pairs(e)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1221 local e=d[e] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1222 e.rem=f |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1223 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1224 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1225 local function f(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1226 if p.sub(e,1,1)=="("then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1227 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1228 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1229 c(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1230 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1231 local function R(o,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1232 local t=o.bl |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1233 local e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1234 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1235 e=t.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1236 while e do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1237 if e[a]then return e[a]end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1238 t=t.prev |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1239 e=t and t.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1240 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1241 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1242 e=o.locallist |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1243 return e[a]or-1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1244 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1245 local function p(t,o,e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1246 if t==nil then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1247 e.k="VGLOBAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1248 return"VGLOBAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1249 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1250 local a=R(t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1251 if a>=0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1252 e.k="VLOCAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1253 e.id=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1254 return"VLOCAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1255 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1256 if p(t.prev,o,e)=="VGLOBAL"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1257 return"VGLOBAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1258 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1259 e.k="VUPVAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1260 return"VUPVAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1261 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1262 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1263 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1264 local function W(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1265 local t=m() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1266 p(a,t,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1267 if o.k=="VGLOBAL"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1268 local e=I[t] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1269 if not e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1270 e=#j+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1271 j[e]={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1272 name=t, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1273 xref={w}, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1274 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1275 I[t]=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1276 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1277 local e=j[e].xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1278 e[#e+1]=w |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1279 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1280 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1281 local e=o.id |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1282 local e=d[e].xref |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1283 e[#e+1]=w |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1284 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1285 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1286 local function p(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1287 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1288 e.isbreakable=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1289 e.prev=a.bl |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1290 e.locallist={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1291 a.bl=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1292 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1293 local function w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1294 local e=a.bl |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1295 H() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1296 a.bl=e.prev |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1297 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1298 local function C() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1299 local e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1300 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1301 e=K |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1302 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1303 e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1304 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1305 e.prev=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1306 e.bl=nil |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1307 e.locallist={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1308 a=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1309 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1310 local function M() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1311 H() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1312 a=a.prev |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1313 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1314 local function H(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1315 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1316 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1317 U(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1318 a.k="VINDEXED" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1319 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1320 local function F(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1321 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1322 h(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1323 i("]") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1324 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1325 local function R(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1326 local e,a={},{} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1327 if t=="<name>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1328 U(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1329 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1330 F(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1331 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1332 i("=") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1333 h(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1334 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1335 local function Y(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1336 if e.v.k=="VVOID"then return end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1337 e.v.k="VVOID" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1338 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1339 local function Y(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1340 h(e.v) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1341 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1342 local function P(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1343 local n=l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1344 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1345 e.v={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1346 e.t=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1347 a.k="VRELOCABLE" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1348 e.v.k="VVOID" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1349 i("{") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1350 repeat |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1351 if t=="}"then break end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1352 local t=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1353 if t=="<name>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1354 if J()~="="then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1355 Y(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1356 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1357 R(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1358 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1359 elseif t=="["then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1360 R(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1361 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1362 Y(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1363 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1364 until not o(",")and not o(";") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1365 s("}","{",n) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1366 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1367 local function J() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1368 local i=0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1369 if t~=")"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1370 repeat |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1371 local t=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1372 if t=="<name>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1373 c(m()) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1374 i=i+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1375 elseif t=="..."then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1376 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1377 a.is_vararg=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1378 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1379 n("<name> or '...' expected") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1380 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1381 until a.is_vararg or not o(",") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1382 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1383 g(i) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1384 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1385 local function Y(h) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1386 local a={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1387 local i=l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1388 local o=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1389 if o=="("then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1390 if i~=V then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1391 n("ambiguous syntax (function call x new statement)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1392 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1393 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1394 if t==")"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1395 a.k="VVOID" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1396 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1397 v(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1398 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1399 s(")","(",i) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1400 elseif o=="{"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1401 P(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1402 elseif o=="<string>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1403 N(a,k) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1404 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1405 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1406 n("function arguments expected") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1407 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1408 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1409 h.k="VCALL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1410 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1411 local function V(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1412 local t=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1413 if t=="("then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1414 local t=l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1415 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1416 h(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1417 s(")","(",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1418 elseif t=="<name>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1419 W(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1420 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1421 n("unexpected symbol") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1422 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1423 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1424 local function R(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1425 V(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1426 while true do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1427 local t=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1428 if t=="."then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1429 H(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1430 elseif t=="["then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1431 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1432 F(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1433 elseif t==":"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1434 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1435 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1436 U(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1437 Y(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1438 elseif t=="("or t=="<string>"or t=="{"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1439 Y(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1440 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1441 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1442 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1443 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1444 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1445 local function U(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1446 local t=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1447 if t=="<number>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1448 o.k="VKNUM" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1449 elseif t=="<string>"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1450 N(o,k) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1451 elseif t=="nil"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1452 o.k="VNIL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1453 elseif t=="true"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1454 o.k="VTRUE" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1455 elseif t=="false"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1456 o.k="VFALSE" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1457 elseif t=="..."then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1458 Q(a.is_vararg==true, |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1459 "cannot use '...' outside a vararg function"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1460 o.k="VVARARG" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1461 elseif t=="{"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1462 P(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1463 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1464 elseif t=="function"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1465 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1466 T(o,false,l) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1467 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1468 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1469 R(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1470 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1471 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1472 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1473 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1474 local function k(o,n) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1475 local a=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1476 local i=Z[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1477 if i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1478 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1479 k(o,X) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1480 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1481 U(o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1482 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1483 a=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1484 local t=L[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1485 while t and t>n do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1486 local o={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1487 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1488 local e=k(o,G[a]) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1489 a=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1490 t=L[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1491 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1492 return a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1493 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1494 function h(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1495 k(e,0) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1496 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1497 local function N(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1498 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1499 local e=e.v.k |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1500 Q(e=="VLOCAL"or e=="VUPVAL"or e=="VGLOBAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1501 or e=="VINDEXED","syntax error") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1502 if o(",")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1503 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1504 e.v={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1505 R(e.v) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1506 N(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1507 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1508 i("=") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1509 v(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1510 return |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1511 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1512 t.k="VNONRELOC" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1513 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1514 local function k(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1515 i("do") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1516 p(false) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1517 g(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1518 y() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1519 w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1520 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1521 local function L(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1522 local t=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1523 f("(for index)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1524 f("(for limit)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1525 f("(for step)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1526 c(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1527 i("=") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1528 E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1529 i(",") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1530 E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1531 if o(",")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1532 E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1533 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1534 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1535 k(1,true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1536 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1537 local function F(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1538 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1539 f("(for generator)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1540 f("(for state)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1541 f("(for control)") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1542 c(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1543 local e=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1544 while o(",")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1545 c(m()) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1546 e=e+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1547 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1548 i("in") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1549 local a=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1550 v(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1551 k(e,false) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1552 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1553 local function U(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1554 local a=false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1555 W(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1556 while t=="."do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1557 H(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1558 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1559 if t==":"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1560 a=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1561 H(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1562 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1563 return a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1564 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1565 function E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1566 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1567 h(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1568 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1569 local function k() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1570 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1571 h(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1572 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1573 local function E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1574 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1575 k() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1576 i("then") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1577 y() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1578 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1579 local function H() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1580 local e,t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1581 c(m()) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1582 e.k="VLOCAL" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1583 g(1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1584 T(t,false,l) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1585 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1586 local function W() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1587 local e=0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1588 local t={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1589 repeat |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1590 c(m()) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1591 e=e+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1592 until not o(",") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1593 if o("=")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1594 v(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1595 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1596 t.k="VVOID" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1597 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1598 g(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1599 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1600 function v(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1601 h(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1602 while o(",")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1603 h(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1604 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1605 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1606 function T(a,t,e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1607 C() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1608 i("(") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1609 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1610 f("self",true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1611 g(1) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1612 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1613 J() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1614 i(")") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1615 x() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1616 s("end","function",e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1617 M() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1618 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1619 function y() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1620 p(false) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1621 x() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1622 w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1623 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1624 function for_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1625 local o=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1626 p(true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1627 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1628 local a=m() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1629 local e=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1630 if e=="="then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1631 L(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1632 elseif e==","or e=="in"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1633 F(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1634 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1635 n("'=' or 'in' expected") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1636 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1637 s("end","for",o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1638 w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1639 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1640 function while_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1641 local t=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1642 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1643 k() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1644 p(true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1645 i("do") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1646 y() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1647 s("end","while",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1648 w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1649 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1650 function repeat_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1651 local t=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1652 p(true) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1653 p(false) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1654 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1655 x() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1656 s("until","repeat",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1657 k() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1658 w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1659 w() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1660 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1661 function if_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1662 local a=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1663 local o={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1664 E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1665 while t=="elseif"do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1666 E() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1667 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1668 if t=="else"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1669 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1670 y() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1671 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1672 s("end","if",a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1673 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1674 function return_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1675 local a={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1676 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1677 local e=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1678 if D[e]or e==";"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1679 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1680 v(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1681 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1682 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1683 function break_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1684 local t=a.bl |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1685 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1686 while t and not t.isbreakable do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1687 t=t.prev |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1688 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1689 if not t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1690 n("no loop to break") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1691 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1692 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1693 function expr_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1694 local e={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1695 e.v={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1696 R(e.v) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1697 if e.v.k=="VCALL"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1698 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1699 e.prev=nil |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1700 N(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1701 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1702 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1703 function function_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1704 local o=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1705 local a,t={},{} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1706 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1707 local e=U(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1708 T(t,e,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1709 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1710 function do_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1711 local t=r |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1712 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1713 y() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1714 s("end","do",t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1715 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1716 function local_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1717 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1718 if o("function")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1719 H() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1720 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1721 W() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1722 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1723 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1724 local function i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1725 r=l |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1726 local e=t |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1727 local t=B[e] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1728 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1729 _M[t]() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1730 if e=="return"or e=="break"then return true end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1731 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1732 expr_stat() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1733 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1734 return false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1735 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1736 function x() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1737 local e=false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1738 while not e and not D[t]do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1739 e=i() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1740 o(";") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1741 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1742 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1743 function parser() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1744 C() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1745 a.is_vararg=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1746 e() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1747 x() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1748 O("<eof>") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1749 M() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1750 return j,d |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1751 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1752 function init(e,o,n) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1753 u=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1754 K={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1755 local t=1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1756 _,q,z,S={},{},{},{} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1757 for a=1,#e do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1758 local e=e[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1759 local i=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1760 if e=="TK_KEYWORD"or e=="TK_OP"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1761 e=o[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1762 elseif e=="TK_NAME"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1763 e="<name>" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1764 q[t]=o[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1765 elseif e=="TK_NUMBER"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1766 e="<number>" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1767 q[t]=0 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1768 elseif e=="TK_STRING"or e=="TK_LSTRING"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1769 e="<string>" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1770 q[t]="" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1771 elseif e=="TK_EOS"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1772 e="<eof>" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1773 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1774 i=false |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1775 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1776 if i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1777 _[t]=e |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1778 z[t]=n[a] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1779 S[t]=a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1780 t=t+1 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1781 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1782 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1783 j,I,d={},{},{} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1784 b,A={},{} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1785 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1786 return _M |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1787 end) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1788 do local e={}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1789 e["vio"]="local vio = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1790 vio.__index = vio; \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1791 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1792 function vio.open(string)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1793 return setmetatable({ pos = 1, data = string }, vio);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1794 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1795 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1796 function vio:read(format, ...)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1797 if self.pos >= #self.data then return; end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1798 if format == \"*a\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1799 local oldpos = self.pos;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1800 self.pos = #self.data;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1801 return self.data:sub(oldpos, self.pos);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1802 elseif format == \"*l\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1803 local data;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1804 data, self.pos = self.data:match(\"([^\\r\\n]*)\\r?\\n?()\", self.pos)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1805 return data;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1806 elseif format == \"*n\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1807 local data;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1808 data, self.pos = self.data:match(\"(%d+)()\", self.pos)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1809 return tonumber(data); \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1810 elseif type(format) == \"number\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1811 local oldpos = self.pos;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1812 self.pos = self.pos + format;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1813 return self.data:sub(oldpos, self.pos-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1814 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1815 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1816 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1817 function vio:seek(whence, offset)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1818 if type(whence) == \"number\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1819 whence, offset = \"cur\", whence;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1820 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1821 offset = offset or 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1822 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1823 if whence == \"cur\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1824 self.pos = self.pos + offset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1825 elseif whence == \"set\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1826 self.pos = offset + 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1827 elseif whence == \"end\" then\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1828 self.pos = #self.data - offset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1829 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1830 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1831 return self.pos;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1832 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1833 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1834 local function _readline(f) return f:read(\"*l\"); end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1835 function vio:lines()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1836 return _readline, self;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1837 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1838 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1839 function vio:write(...)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1840 for i=1,select('#', ...) do\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1841 local dat = tostring(select(i, ...));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1843 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1844 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1845 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1846 function vio:close()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1847 self.pos, self.data = nil, nil;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1848 end\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1849 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)..\"]\", \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1852 n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1853 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1854 e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1855 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1856 l(n,l)l=l 1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1857 h({n},l+1)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1858 _(n) l={}l.outbs=n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1859 l.wnd={}l.=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1860 l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1861 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1862 t(l,e) n=l.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1863 l.outbs(e)l.wnd[n]=e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1864 l.=n%32768+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1865 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1866 n(l) i(l,'unexpected end of file')\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1867 o(n,l) n%(l+l)>=l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1868 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1869 a=p((l) 2^l ) c=e({},{__mode='k'}) g(o) l=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1870 e={} e:() n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1871 l<=#o \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1872 n=o:byte(l)l=l+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1873 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1874 n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1875 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1876 e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1877 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1878 l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1879 s(d) n,l,o=0,0,{}; o:() l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1880 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1881 o:(e)e=e 1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1882 l<e \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1883 e=d:() e \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1884 n=n+a[l]*e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1885 l=l+8\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1886 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1887 o=a[e] a=n%o\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1888 n=(n-a)/o\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1889 l=l-e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1890 a\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1891 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1892 c[o]=\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1893 o\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1894 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1895 f(l) c[l] l s(g(l))\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1896 s(l) n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1897 y.type(l)=='file'\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1898 n=(n)l:write(v(n))\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1899 d(l)=='function'\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1900 n=l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1901 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1902 n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1903 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1904 d(e,o) l={} o \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1905 e,n m(e)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1906 n~=0 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1907 l[#l+1]={=e,=n}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1908 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1909 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1910 n=1,#e-2,2 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1911 o,n,e=e[n],e[n+1],e[n+2] n~=0 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1912 e=o,e-1 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1913 l[#l+1]={=e,=n}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1914 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1915 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1916 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1917 w(l,(n,l) n.==l. n.<l. n.<l.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1918 ) e=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1919 o=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1920 n,l b(l)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1921 l.~=o \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1922 e=e*a[l.-o]o=l.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1923 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1924 l.code=e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1925 e=e+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1926 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1927 e=r.huge\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1928 c={} n,l b(l)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1929 e=r.min(e,l.)c[l.code]=l.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1930 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1931 o(n,e) l=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1932 e=1,e \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1933 e=n%2\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1934 n=(n-e)/2\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1935 l=l*2+e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1936 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1937 l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1938 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1939 d=p((l) a[e]+o(l,e)) l:(a) o,l=1,0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1940 1 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1941 l==0 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1942 o=d[n(a:(e))]l=l+e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1943 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1944 n=n(a:())l=l+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1945 o=o*2+n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1946 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1947 l=c[o] l \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1948 l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1949 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1950 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1951 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1952 l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1953 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1954 b(l) a=2^1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1955 e=2^2\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1956 c=2^3\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1957 d=2^4\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1959 n=l:(16) e=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1960 n=1,n \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1961 e=l:(8)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1962 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1963 o(n,c)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1964 l:(8)~=0 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1965 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1966 o(n,d)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1967 l:(8)~=0 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1968 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1969 o(n,a)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1970 l:(16)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1971 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1972 p(l) f=l:(5) i=l:(5) e=n(l:(4)) a=e+4\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1974 l=l:(3) n=o[n]e[n]=l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1975 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1976 e=d(e,) r(o) t={} a\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1977 c=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1978 c<o \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1979 o=e:(l) e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1980 o<=15 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1981 e=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1982 a=o\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1983 o==16 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1984 e=3+n(l:(2)) o==17 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1985 e=3+n(l:(3))a=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1986 o==18 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1987 e=11+n(l:(7))a=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1988 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1989 h'ASSERT'\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1990 l=1,e \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1991 t[c]=a\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1992 c=c+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1993 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1994 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1995 l=d(t,) l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1996 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1997 n=f+257\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1998 l=i+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1999 n=r(n) l=r(l) n,l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2000 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2001 a\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2002 o\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2003 c\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2004 r\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2005 h(e,n,l,d) l=l:(e) l<256 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2006 t(n,l) l==256 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2007 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2008 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2009 a \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2010 l={[257]=3} e=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2011 n=258,285,4 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2012 n=n,n+3 l[n]=l[n-1]+e \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2013 n~=258 e=e*2 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2014 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2015 l[285]=258\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2016 a=l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2017 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2018 o \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2019 l={} e=257,285 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2020 n=u(e-261,0)l[e]=(n-(n%4))/4\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2021 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2022 l[285]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2023 o=l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2024 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2025 a=a[l] l=o[l] l=e:(l) o=a+l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2026 c \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2027 e={[0]=1} l=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2028 n=1,29,2 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2029 n=n,n+1 e[n]=e[n-1]+l \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2030 n~=1 l=l*2 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2031 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2032 c=e\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2033 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2034 r \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2035 n={} e=0,29 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2036 l=u(e-2,0)n[e]=(l-(l%2))/2\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2037 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2038 r=n\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2039 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2040 l=d:(e) a=c[l] l=r[l] l=e:(l) l=a+l\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2041 e=1,o \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2042 l=(n.-1-l)%32768+1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2043 t(n,i(n.wnd[l],'invalid distance'))\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2044 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2045 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2046 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2047 u(l,a) i=l:(1) e=l:(2) r=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2048 o=1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2049 c=2\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2050 f=3\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2051 e==r \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2052 l:(l:()) e=l:(16) o=n(l:(16)) e=1,e \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2053 l=n(l:(8))t(a,l)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2054 e==o e==c \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2055 n,o\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2056 e==c \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2057 n,o=p(l)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2059 h(l,a,n,o);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2060 i~=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2061 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2062 e(l) n,l=f(l.),_(s(l.)) u(n,l)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2063 (n) l=f(n.) n=s(n.)b(l)e{=l,=n}l:(l:())l:()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2064 ]===], '@gunzip.lua'))()"e["lua5.1.min.js"]="////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2065 // lua5.1.5.js: Lua 5.1.5 in JavaScript\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2066 // This file is a part of lua5.1.js project:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2067 // https://github.com/logiceditor-com/lua5.1.js/\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2068 // Copyright (c) LogicEditor <info@logiceditor.com>\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2069 // Copyright (c) lua5.1.js authors\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2070 // Distributed under the terms of the MIT license:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2071 // https://github.com/logiceditor-com/lua5.1.js/tree/master/COPYRIGHT\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2072 // Based on original Lua 5.1.5 header files:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2073 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2074 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2075 // WARNING: Emscriptenized code does not like minification.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2076 // Keep this file as is and enable compression in your HTTP server.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2077 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2078 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2079 var Lua5_1 = Lua5_1 || { };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2080 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2081 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2082 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2083 (function(Lua5_1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2084 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2085 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2086 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2088 // Note: Some Emscripten settings may limit the speed of the generated code.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2089 // The Module object: Our interface to the outside world. We import\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2090 // and export values on it, and do the work to get that through\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2091 // closure compiler if necessary. There are various ways Module can be used:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2092 // 1. Not defined. We create it here\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2093 // 2. A function parameter, function(Module) { ..generated code.. }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2094 // 3. pre-run appended it, var Module = {}; ..generated code..\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2095 // 4. External script tag defines var Module.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2096 // We need to do an eval in order to handle the closure compiler\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2097 // case, where this code here is minified but Module was defined\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2098 // elsewhere (e.g. case 4 above). We also need to check if Module\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2099 // already exists (e.g. case 3 above).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2100 // Note that if you want to run closure, and also to use Module\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2101 // after the generated code, you will need to define var Module = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2102 // before the code. Then that object will be used in the code, and you\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2103 // can continue to use Module afterwards as well.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2104 var Module;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2105 if (!Module) Module = eval('(function() { try { return Module || {} } catch(e) { return {} } })()');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2106 // Sometimes an existing Module object exists with properties\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2107 // meant to overwrite the default module functionality. Here\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2108 // we collect those properties and reapply _after_ we configure\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2109 // the current environment's defaults to avoid having to be so\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2110 // defensive during initialization.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2111 var moduleOverrides = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2112 for (var key in Module) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2113 if (Module.hasOwnProperty(key)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2114 moduleOverrides[key] = Module[key];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2115 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2116 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2117 // The environment setup code below is customized to use Module.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2118 // *** Environment setup code ***\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2119 var ENVIRONMENT_IS_NODE = typeof process === 'object' && typeof require === 'function';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2120 var ENVIRONMENT_IS_WEB = typeof window === 'object';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2121 var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2122 var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2123 if (ENVIRONMENT_IS_NODE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2124 // Expose functionality in the same simple way that the shells work\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2125 // Note that we pollute the global namespace here, otherwise we break in node\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2126 Module['print'] = function(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2127 process['stdout'].write(x + '\\n');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2128 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2129 Module['printErr'] = function(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2130 process['stderr'].write(x + '\\n');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2131 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2132 var nodeFS = require('fs');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2133 var nodePath = require('path');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2134 Module['read'] = function(filename, binary) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2135 filename = nodePath['normalize'](filename);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2136 var ret = nodeFS['readFileSync'](filename);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2137 // The path is absolute if the normalized version is the same as the resolved.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2138 if (!ret && filename != nodePath['resolve'](filename)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2139 filename = path.join(__dirname, '..', 'src', filename);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2140 ret = nodeFS['readFileSync'](filename);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2141 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2142 if (ret && !binary) ret = ret.toString();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2143 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2144 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2145 Module['readBinary'] = function(filename) { return Module['read'](filename, true) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2146 Module['load'] = function(f) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2147 globalEval(read(f));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2148 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2149 Module['arguments'] = process['argv'].slice(2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2150 module.exports = Module;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2151 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2152 else if (ENVIRONMENT_IS_SHELL) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2153 Module['print'] = print;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2154 if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2155 if (typeof read != 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2156 Module['read'] = read;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2157 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2158 Module['read'] = function() { throw 'no read() available (jsc?)' };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2159 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2160 Module['readBinary'] = function(f) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2161 return read(f, 'binary');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2162 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2163 if (typeof scriptArgs != 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2164 Module['arguments'] = scriptArgs;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2165 } else if (typeof arguments != 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2166 Module['arguments'] = arguments;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2167 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2168 this['Module'] = Module;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2169 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2170 else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2171 Module['read'] = function(url) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2172 var xhr = new XMLHttpRequest();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2173 xhr.open('GET', url, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2174 xhr.send(null);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2175 return xhr.responseText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2176 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2177 if (typeof arguments != 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2178 Module['arguments'] = arguments;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2179 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2180 if (ENVIRONMENT_IS_WEB) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2181 Module['print'] = function(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2182 console.log(x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2183 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2184 Module['printErr'] = function(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2185 console.log(x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2186 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2187 this['Module'] = Module;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2188 } else if (ENVIRONMENT_IS_WORKER) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2189 // We can do very little here...\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2190 var TRY_USE_DUMP = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2191 Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== \"undefined\") ? (function(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2192 dump(x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2193 }) : (function(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2194 // self.postMessage(x); // enable this if you want stdout to be sent as messages\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2195 }));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2196 Module['load'] = importScripts;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2197 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2198 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2199 else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2200 // Unreachable because SHELL is dependant on the others\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2201 throw 'Unknown runtime environment. Where are we?';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2202 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2203 function globalEval(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2204 eval.call(null, x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2205 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2206 if (!Module['load'] == 'undefined' && Module['read']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2207 Module['load'] = function(f) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2208 globalEval(Module['read'](f));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2209 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2210 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2211 if (!Module['print']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2212 Module['print'] = function(){};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2213 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2214 if (!Module['printErr']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2215 Module['printErr'] = Module['print'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2216 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2217 if (!Module['arguments']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2218 Module['arguments'] = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2219 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2220 // *** Environment setup code ***\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2221 // Closure helpers\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2222 Module.print = Module['print'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2223 Module.printErr = Module['printErr'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2224 // Callbacks\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2225 Module['preRun'] = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2226 Module['postRun'] = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2227 // Merge back in the overrides\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2228 for (var key in moduleOverrides) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2229 if (moduleOverrides.hasOwnProperty(key)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2230 Module[key] = moduleOverrides[key];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2231 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2232 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2233 // === Auto-generated preamble library stuff ===\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2234 //========================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2235 // Runtime code shared with compiler\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2236 //========================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2237 var Runtime = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2238 stackSave: function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2239 return STACKTOP;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2240 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2241 stackRestore: function (stackTop) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2242 STACKTOP = stackTop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2243 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2244 forceAlign: function (target, quantum) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2245 quantum = quantum || 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2246 if (quantum == 1) return target;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2247 if (isNumber(target) && isNumber(quantum)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2248 return Math.ceil(target/quantum)*quantum;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2249 } else if (isNumber(quantum) && isPowerOfTwo(quantum)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2250 var logg = log2(quantum);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2251 return '((((' +target + ')+' + (quantum-1) + ')>>' + logg + ')<<' + logg + ')';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2252 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2253 return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2254 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2255 isNumberType: function (type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2256 return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2257 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2258 isPointerType: function isPointerType(type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2259 return type[type.length-1] == '*';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2260 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2261 isStructType: function isStructType(type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2262 if (isPointerType(type)) return false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2263 if (isArrayType(type)) return true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2264 if (/<?{ ?[^}]* ?}>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2265 // See comment in isStructPointerType()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2266 return type[0] == '%';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2267 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2268 INT_TYPES: {\"i1\":0,\"i8\":0,\"i16\":0,\"i32\":0,\"i64\":0},\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2269 FLOAT_TYPES: {\"float\":0,\"double\":0},\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2270 or64: function (x, y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2271 var l = (x | 0) | (y | 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2272 var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2273 return l + h;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2274 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2275 and64: function (x, y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2276 var l = (x | 0) & (y | 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2277 var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2278 return l + h;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2279 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2280 xor64: function (x, y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2281 var l = (x | 0) ^ (y | 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2282 var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2283 return l + h;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2284 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2285 getNativeTypeSize: function (type, quantumSize) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2286 if (Runtime.QUANTUM_SIZE == 1) return 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2287 var size = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2288 '%i1': 1,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2289 '%i8': 1,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2290 '%i16': 2,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2291 '%i32': 4,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2292 '%i64': 8,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2293 \"%float\": 4,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2294 \"%double\": 8\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2296 if (!size) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2297 if (type.charAt(type.length-1) == '*') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2298 size = Runtime.QUANTUM_SIZE; // A pointer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2299 } else if (type[0] == 'i') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2300 var bits = parseInt(type.substr(1));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2301 assert(bits % 8 == 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2302 size = bits/8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2303 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2304 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2305 return size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2306 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2307 getNativeFieldSize: function (type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2308 return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2309 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2310 dedup: function dedup(items, ident) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2311 var seen = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2312 if (ident) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2313 return items.filter(function(item) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2314 if (seen[item[ident]]) return false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2315 seen[item[ident]] = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2316 return true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2317 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2318 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2319 return items.filter(function(item) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2320 if (seen[item]) return false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2321 seen[item] = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2322 return true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2323 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2324 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2325 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2326 set: function set() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2327 var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2328 var ret = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2329 for (var i = 0; i < args.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2330 ret[args[i]] = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2331 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2332 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2333 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2334 STACK_ALIGN: 8,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2335 getAlignSize: function (type, size, vararg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2336 // we align i64s and doubles on 64-bit boundaries, unlike x86\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2337 if (type == 'i64' || type == 'double' || vararg) return 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2338 if (!type) return Math.min(size, 8); // align structures internally to 64 bits\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2339 return Math.min(size || (type ? Runtime.getNativeFieldSize(type) : 0), Runtime.QUANTUM_SIZE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2340 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2341 calculateStructAlignment: function calculateStructAlignment(type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2342 type.flatSize = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2343 type.alignSize = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2344 var diffs = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2345 var prev = -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2346 var index = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2347 type.flatIndexes = type.fields.map(function(field) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2348 index++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2349 var size, alignSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2350 if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2351 size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2352 alignSize = Runtime.getAlignSize(field, size);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2353 } else if (Runtime.isStructType(field)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2354 if (field[1] === '0') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2356 // and it adds no size\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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!');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2358 size = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2359 if (Types.types[field]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2360 alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2361 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2362 alignSize = type.alignSize || QUANTUM_SIZE;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2363 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2364 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2365 size = Types.types[field].flatSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2366 alignSize = Runtime.getAlignSize(null, Types.types[field].alignSize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2367 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2368 } else if (field[0] == 'b') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2369 // bN, large number field, like a [N x i8]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2370 size = field.substr(1)|0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2371 alignSize = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2372 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2373 throw 'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Types.types[type.name_]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2374 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2375 if (type.packed) alignSize = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2376 type.alignSize = Math.max(type.alignSize, alignSize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2377 var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2378 type.flatSize = curr + size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2379 if (prev >= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2380 diffs.push(curr-prev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2381 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2382 prev = curr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2383 return curr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2384 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2385 type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2386 if (diffs.length == 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2387 type.flatFactor = type.flatSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2388 } else if (Runtime.dedup(diffs).length == 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2389 type.flatFactor = diffs[0];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2390 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2391 type.needsFlattening = (type.flatFactor != 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2392 return type.flatIndexes;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2393 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2394 generateStructInfo: function (struct, typeName, offset) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2395 var type, alignment;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2396 if (typeName) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2397 offset = offset || 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2398 type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2399 if (!type) return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2400 if (type.fields.length != struct.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2402 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2403 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2404 alignment = type.flatIndexes;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2405 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2406 var type = { fields: struct.map(function(item) { return item[0] }) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2407 alignment = Runtime.calculateStructAlignment(type);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2408 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2409 var ret = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2410 __size__: type.flatSize\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2411 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2412 if (typeName) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2413 struct.forEach(function(item, i) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2414 if (typeof item === 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2415 ret[item] = alignment[i] + offset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2416 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2417 // embedded struct\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2418 var key;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2419 for (var k in item) key = k;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2420 ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2421 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2422 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2423 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2424 struct.forEach(function(item, i) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2425 ret[item[1]] = alignment[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2426 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2427 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2428 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2429 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2430 dynCall: function (sig, ptr, args) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2431 if (args && args.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2432 if (!args.splice) args = Array.prototype.slice.call(args);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2433 args.splice(0, 0, ptr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2434 return Module['dynCall_' + sig].apply(null, args);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2435 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2436 return Module['dynCall_' + sig].call(null, ptr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2437 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2438 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2440 addFunction: function (func) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2441 for (var i = 0; i < Runtime.functionPointers.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2442 if (!Runtime.functionPointers[i]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2443 Runtime.functionPointers[i] = func;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2444 return 2 + 2*i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2445 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2446 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2447 throw 'Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS.';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2448 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2449 removeFunction: function (index) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2450 Runtime.functionPointers[(index-2)/2] = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2451 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2452 warnOnce: function (text) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2453 if (!Runtime.warnOnce.shown) Runtime.warnOnce.shown = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2454 if (!Runtime.warnOnce.shown[text]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2455 Runtime.warnOnce.shown[text] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2456 Module.printErr(text);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2457 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2458 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2459 funcWrappers: {},\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2460 getFuncWrapper: function (func, sig) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2461 assert(sig);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2462 if (!Runtime.funcWrappers[func]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2463 Runtime.funcWrappers[func] = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2464 return Runtime.dynCall(sig, func, arguments);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2465 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2466 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2467 return Runtime.funcWrappers[func];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2468 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2469 UTF8Processor: function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2470 var buffer = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2471 var needed = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2472 this.processCChar = function (code) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2473 code = code & 0xFF;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2474 if (buffer.length == 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2475 if ((code & 0x80) == 0x00) { // 0xxxxxxx\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2476 return String.fromCharCode(code);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2477 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2478 buffer.push(code);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2479 if ((code & 0xE0) == 0xC0) { // 110xxxxx\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2480 needed = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2481 } else if ((code & 0xF0) == 0xE0) { // 1110xxxx\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2482 needed = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2483 } else { // 11110xxx\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2484 needed = 3;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2485 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2486 return '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2487 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2488 if (needed) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2489 buffer.push(code);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2490 needed--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2491 if (needed > 0) return '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2492 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2493 var c1 = buffer[0];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2494 var c2 = buffer[1];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2495 var c3 = buffer[2];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2496 var c4 = buffer[3];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2497 var ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2498 if (buffer.length == 2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2499 ret = String.fromCharCode(((c1 & 0x1F) << 6) | (c2 & 0x3F));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2500 } else if (buffer.length == 3) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2501 ret = String.fromCharCode(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2502 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2503 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2504 var codePoint = ((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) |\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2505 ((c3 & 0x3F) << 6) | (c4 & 0x3F);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2506 ret = String.fromCharCode(\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2507 Math.floor((codePoint - 0x10000) / 0x400) + 0xD800,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2508 (codePoint - 0x10000) % 0x400 + 0xDC00);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2509 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2510 buffer.length = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2511 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2512 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2513 this.processJSString = function(string) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2514 string = unescape(encodeURIComponent(string));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2515 var ret = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2516 for (var i = 0; i < string.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2517 ret.push(string.charCodeAt(i));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2518 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2519 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2520 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2521 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2527 GLOBAL_BASE: 8,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2528 QUANTUM_SIZE: 4,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2529 __dummy__: 0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2530 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2531 function jsCall() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2532 var args = Array.prototype.slice.call(arguments);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2533 return Runtime.functionPointers[args[0]].apply(null, args.slice(1));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2534 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2535 //========================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2536 // Runtime essentials\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2537 //========================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2538 var __THREW__ = 0; // Used in checking for thrown exceptions.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2540 var EXITSTATUS = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2541 var undef = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2542 // tempInt is used for 32-bit signed values or smaller. tempBigInt is used\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2544 var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2545 var tempI64, tempI64b;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2546 var tempRet0, tempRet1, tempRet2, tempRet3, tempRet4, tempRet5, tempRet6, tempRet7, tempRet8, tempRet9;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2547 function assert(condition, text) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2548 if (!condition) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2549 abort('Assertion failed: ' + text);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2550 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2551 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2552 var globalScope = this;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2553 // C calling interface. A convenient way to call C functions (in C files, or\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2554 // defined with extern \"C\").\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2555 //\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2556 // Note: LLVM optimizations can inline and remove functions, after which you will not be\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2558 // the exports using something like\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2559 //\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2560 // -s EXPORTED_FUNCTIONS='[\"_main\", \"_myfunc\"]'\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2561 //\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\")\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2564 // 'array' for JavaScript arrays and typed arrays; note that arrays are 8-bit).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2569 // @return The return value, as a native JS value (as in returnType)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2570 function ccall(ident, returnType, argTypes, args) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2571 return ccallFunc(getCFunc(ident), returnType, argTypes, args);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2572 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2573 Module[\"ccall\"] = ccall;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2575 function getCFunc(ident) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2576 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2577 var func = Module['_' + ident]; // closure exported function\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2578 if (!func) func = eval('_' + ident); // explicit lookup\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2579 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2580 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2581 assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2582 return func;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2583 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2584 // Internal function that does a C call using a function, not an identifier\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2585 function ccallFunc(func, returnType, argTypes, args) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2586 var stack = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2587 function toC(value, type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2588 if (type == 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2589 if (value === null || value === undefined || value === 0) return 0; // null string\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2590 if (!stack) stack = Runtime.stackSave();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2591 var ret = Runtime.stackAlloc(value.length+1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2592 writeStringToMemory(value, ret);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2593 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2594 } else if (type == 'array') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2595 if (!stack) stack = Runtime.stackSave();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2596 var ret = Runtime.stackAlloc(value.length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2597 writeArrayToMemory(value, ret);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2598 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2599 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2600 return value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2601 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2602 function fromC(value, type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2603 if (type == 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2604 return Pointer_stringify(value);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2605 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2606 assert(type != 'array');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2607 return value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2608 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2609 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2610 var cArgs = args ? args.map(function(arg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2611 return toC(arg, argTypes[i++]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2612 }) : [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2613 var ret = fromC(func.apply(null, cArgs), returnType);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2614 if (stack) Runtime.stackRestore(stack);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2615 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2616 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2617 // Returns a native JS wrapper for a C function. This is similar to ccall, but\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2618 // returns a function you can call repeatedly in a normal way. For example:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2619 //\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2620 // var my_function = cwrap('my_c_function', 'number', ['number', 'number']);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2621 // alert(my_function(5, 22));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2622 // alert(my_function(99, 12));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2623 //\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2624 function cwrap(ident, returnType, argTypes) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2625 var func = getCFunc(ident);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2626 return function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2627 return ccallFunc(func, returnType, argTypes, Array.prototype.slice.call(arguments));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2628 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2629 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2630 Module[\"cwrap\"] = cwrap;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2631 // Sets a value in memory in a dynamic way at run-time. Uses the\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2632 // type data. This is the same as makeSetValue, except that\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2633 // makeSetValue is done at compile-time and generates the needed\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2634 // code then, whereas this function picks the right code at\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2635 // run-time.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2636 // Note that setValue and getValue only do *aligned* writes and reads!\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2637 // Note that ccall uses JS types as for defining types, while setValue and\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2638 // getValue need LLVM types ('i8', 'i32') - this is a lower-level operation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2639 function setValue(ptr, value, type, noSafe) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2640 type = type || 'i8';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2641 if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2642 switch(type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2643 case 'i1': HEAP8[(ptr)]=value; break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2644 case 'i8': HEAP8[(ptr)]=value; break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2645 case 'i16': HEAP16[((ptr)>>1)]=value; break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2646 case 'i32': HEAP32[((ptr)>>2)]=value; break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2648 case 'float': HEAPF32[((ptr)>>2)]=value; break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2649 case 'double': HEAPF64[((ptr)>>3)]=value; break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2650 default: abort('invalid type for setValue: ' + type);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2651 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2652 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2653 Module['setValue'] = setValue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2654 // Parallel to setValue.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2655 function getValue(ptr, type, noSafe) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2656 type = type || 'i8';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2657 if (type.charAt(type.length-1) === '*') type = 'i32'; // pointers are 32-bit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2658 switch(type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2659 case 'i1': return HEAP8[(ptr)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2660 case 'i8': return HEAP8[(ptr)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2661 case 'i16': return HEAP16[((ptr)>>1)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2662 case 'i32': return HEAP32[((ptr)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2663 case 'i64': return HEAP32[((ptr)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2664 case 'float': return HEAPF32[((ptr)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2665 case 'double': return HEAPF64[((ptr)>>3)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2666 default: abort('invalid type for setValue: ' + type);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2667 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2668 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2669 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2670 Module['getValue'] = getValue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2671 var ALLOC_NORMAL = 0; // Tries to use _malloc()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2672 var ALLOC_STACK = 1; // Lives for the duration of the current function call\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2673 var ALLOC_STATIC = 2; // Cannot be freed\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2674 var ALLOC_DYNAMIC = 3; // Cannot be freed except through sbrk\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2675 var ALLOC_NONE = 4; // Do not allocate\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2676 Module['ALLOC_NORMAL'] = ALLOC_NORMAL;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2677 Module['ALLOC_STACK'] = ALLOC_STACK;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2678 Module['ALLOC_STATIC'] = ALLOC_STATIC;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2679 Module['ALLOC_DYNAMIC'] = ALLOC_DYNAMIC;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2680 Module['ALLOC_NONE'] = ALLOC_NONE;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2682 // is a little tricky (see docs right below). The reason is that it is optimized\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2683 // for multiple syntaxes to save space in generated code. So you should\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2684 // normally not use allocate(), and instead allocate memory using _malloc(),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2685 // initialize it with setValue(), and so forth.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2687 // in *bytes* (note that this is sometimes confusing: the next parameter does not\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2688 // affect this!)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2692 // ignored.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2693 // @allocator: How to allocate memory, see ALLOC_*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2694 function allocate(slab, types, allocator, ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2695 var zeroinit, size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2696 if (typeof slab === 'number') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2697 zeroinit = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2698 size = slab;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2699 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2700 zeroinit = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2701 size = slab.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2702 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2703 var singleType = typeof types === 'string' ? types : null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2704 var ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2705 if (allocator == ALLOC_NONE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2706 ret = ptr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2707 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2709 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2710 if (zeroinit) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2711 var ptr = ret, stop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2712 assert((ret & 3) == 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2713 stop = ret + (size & ~3);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2714 for (; ptr < stop; ptr += 4) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2715 HEAP32[((ptr)>>2)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2716 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2717 stop = ret + size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2718 while (ptr < stop) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2719 HEAP8[((ptr++)|0)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2720 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2721 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2722 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2723 if (singleType === 'i8') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2724 if (slab.subarray || slab.slice) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2725 HEAPU8.set(slab, ret);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2726 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2727 HEAPU8.set(new Uint8Array(slab), ret);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2728 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2729 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2730 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2731 var i = 0, type, typeSize, previousType;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2732 while (i < size) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2733 var curr = slab[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2734 if (typeof curr === 'function') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2735 curr = Runtime.getFunctionIndex(curr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2736 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2737 type = singleType || types[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2738 if (type === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2739 i++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2740 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2741 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2743 setValue(ret+i, curr, type);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2744 // no need to look up size unless type changes, so cache it\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2745 if (previousType !== type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2746 typeSize = Runtime.getNativeTypeSize(type);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2747 previousType = type;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2748 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2749 i += typeSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2750 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2751 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2752 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2753 Module['allocate'] = allocate;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2754 function Pointer_stringify(ptr, /* optional */ length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2755 // TODO: use TextDecoder\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2756 // Find the length, and check for UTF while doing so\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2757 var hasUtf = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2758 var t;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2759 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2760 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2761 t = HEAPU8[(((ptr)+(i))|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2762 if (t >= 128) hasUtf = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2763 else if (t == 0 && !length) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2764 i++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2765 if (length && i == length) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2766 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2767 if (!length) length = i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2768 var ret = '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2769 if (!hasUtf) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2771 var curr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2772 while (length > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2773 curr = String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + Math.min(length, MAX_CHUNK)));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2774 ret = ret ? ret + curr : curr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2775 ptr += MAX_CHUNK;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2776 length -= MAX_CHUNK;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2777 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2778 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2779 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2780 var utf8 = new Runtime.UTF8Processor();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2781 for (i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2782 t = HEAPU8[(((ptr)+(i))|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2783 ret += utf8.processCChar(t);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2784 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2785 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2786 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2787 Module['Pointer_stringify'] = Pointer_stringify;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2789 // a copy of that string as a Javascript String object.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2790 function UTF16ToString(ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2791 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2792 var str = '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2793 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2794 var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2795 if (codeUnit == 0)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2796 return str;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2797 ++i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2799 str += String.fromCharCode(codeUnit);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2800 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2801 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2802 Module['UTF16ToString'] = UTF16ToString;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2803 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2805 function stringToUTF16(str, outPtr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2806 for(var i = 0; i < str.length; ++i) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2808 var codeUnit = str.charCodeAt(i); // possibly a lead surrogate\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2809 HEAP16[(((outPtr)+(i*2))>>1)]=codeUnit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2810 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2811 // Null-terminate the pointer to the HEAP.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2812 HEAP16[(((outPtr)+(str.length*2))>>1)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2813 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2814 Module['stringToUTF16'] = stringToUTF16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2816 // a copy of that string as a Javascript String object.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2817 function UTF32ToString(ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2818 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2819 var str = '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2820 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2821 var utf32 = HEAP32[(((ptr)+(i*4))>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2822 if (utf32 == 0)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2823 return str;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2824 ++i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2826 if (utf32 >= 0x10000) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2827 var ch = utf32 - 0x10000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2828 str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2829 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2830 str += String.fromCharCode(utf32);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2831 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2832 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2833 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2834 Module['UTF32ToString'] = UTF32ToString;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2835 // Copies the given Javascript String object 'str' to the emscripten HEAP at address 'outPtr', \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2838 function stringToUTF32(str, outPtr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2839 var iChar = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2840 for(var iCodeUnit = 0; iCodeUnit < str.length; ++iCodeUnit) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2842 var codeUnit = str.charCodeAt(iCodeUnit); // possibly a lead surrogate\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2843 if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2844 var trailSurrogate = str.charCodeAt(++iCodeUnit);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2845 codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2846 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2847 HEAP32[(((outPtr)+(iChar*4))>>2)]=codeUnit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2848 ++iChar;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2849 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2850 // Null-terminate the pointer to the HEAP.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2851 HEAP32[(((outPtr)+(iChar*4))>>2)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2852 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2853 Module['stringToUTF32'] = stringToUTF32;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2854 // Memory management\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2855 var PAGE_SIZE = 4096;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2856 function alignMemoryPage(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2857 return ((x+4095)>>12)<<12;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2858 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2859 var HEAP;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2860 var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2861 var STATIC_BASE = 0, STATICTOP = 0, staticSealed = false; // static area\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2862 var STACK_BASE = 0, STACKTOP = 0, STACK_MAX = 0; // stack area\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2863 var DYNAMIC_BASE = 0, DYNAMICTOP = 0; // dynamic area handled by sbrk\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2864 function enlargeMemory() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2866 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2867 var TOTAL_STACK = Module['TOTAL_STACK'] || 5242880;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2868 var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 16777216;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2869 var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2870 // Initialize the runtime's memory\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2871 // check for full engine support (use string 'subarray' to avoid closure compiler confusion)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2872 assert(!!Int32Array && !!Float64Array && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2873 'Cannot fallback to non-typed array case: Code is too specialized');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2874 var buffer = new ArrayBuffer(TOTAL_MEMORY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2875 HEAP8 = new Int8Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2876 HEAP16 = new Int16Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2877 HEAP32 = new Int32Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2878 HEAPU8 = new Uint8Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2879 HEAPU16 = new Uint16Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2880 HEAPU32 = new Uint32Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2881 HEAPF32 = new Float32Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2882 HEAPF64 = new Float64Array(buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2883 // Endianness check (note: assumes compiler arch was little-endian)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2884 HEAP32[0] = 255;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2886 Module['HEAP'] = HEAP;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2887 Module['HEAP8'] = HEAP8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2888 Module['HEAP16'] = HEAP16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2889 Module['HEAP32'] = HEAP32;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2890 Module['HEAPU8'] = HEAPU8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2891 Module['HEAPU16'] = HEAPU16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2892 Module['HEAPU32'] = HEAPU32;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2893 Module['HEAPF32'] = HEAPF32;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2894 Module['HEAPF64'] = HEAPF64;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2895 function callRuntimeCallbacks(callbacks) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2896 while(callbacks.length > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2897 var callback = callbacks.shift();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2898 if (typeof callback == 'function') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2899 callback();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2900 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2901 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2902 var func = callback.func;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2903 if (typeof func === 'number') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2904 if (callback.arg === undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2905 Runtime.dynCall('v', func);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2906 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2907 Runtime.dynCall('vi', func, [callback.arg]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2908 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2909 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2910 func(callback.arg === undefined ? null : callback.arg);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2911 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2912 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2913 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2914 var __ATPRERUN__ = []; // functions called before the runtime is initialized\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2915 var __ATINIT__ = []; // functions called during startup\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2916 var __ATMAIN__ = []; // functions called when main() is to be run\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2917 var __ATEXIT__ = []; // functions called during shutdown\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2918 var __ATPOSTRUN__ = []; // functions called after the runtime has exited\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2919 var runtimeInitialized = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2920 function preRun() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2921 // compatibility - merge in anything from Module['preRun'] at this time\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2922 if (Module['preRun']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2923 if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2924 while (Module['preRun'].length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2925 addOnPreRun(Module['preRun'].shift());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2926 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2927 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2928 callRuntimeCallbacks(__ATPRERUN__);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2929 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2930 function ensureInitRuntime() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2931 if (runtimeInitialized) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2932 runtimeInitialized = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2933 callRuntimeCallbacks(__ATINIT__);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2934 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2935 function preMain() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2936 callRuntimeCallbacks(__ATMAIN__);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2937 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2938 function exitRuntime() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2939 callRuntimeCallbacks(__ATEXIT__);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2940 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2941 function postRun() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2942 // compatibility - merge in anything from Module['postRun'] at this time\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2943 if (Module['postRun']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2944 if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2945 while (Module['postRun'].length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2946 addOnPostRun(Module['postRun'].shift());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2947 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2948 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2949 callRuntimeCallbacks(__ATPOSTRUN__);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2950 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2951 function addOnPreRun(cb) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2952 __ATPRERUN__.unshift(cb);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2953 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2954 Module['addOnPreRun'] = Module.addOnPreRun = addOnPreRun;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2955 function addOnInit(cb) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2956 __ATINIT__.unshift(cb);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2957 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2958 Module['addOnInit'] = Module.addOnInit = addOnInit;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2959 function addOnPreMain(cb) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2960 __ATMAIN__.unshift(cb);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2961 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2962 Module['addOnPreMain'] = Module.addOnPreMain = addOnPreMain;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2963 function addOnExit(cb) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2964 __ATEXIT__.unshift(cb);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2965 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2966 Module['addOnExit'] = Module.addOnExit = addOnExit;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2967 function addOnPostRun(cb) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2968 __ATPOSTRUN__.unshift(cb);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2969 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2970 Module['addOnPostRun'] = Module.addOnPostRun = addOnPostRun;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2971 // Tools\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2972 // This processes a JS string into a C-line array of numbers, 0-terminated.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2973 // For LLVM-originating strings, see parser.js:parseLLVMString function\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2974 function intArrayFromString(stringy, dontAddNull, length /* optional */) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2975 var ret = (new Runtime.UTF8Processor()).processJSString(stringy);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2976 if (length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2977 ret.length = length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2978 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2979 if (!dontAddNull) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2980 ret.push(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2981 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2982 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2983 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2984 Module['intArrayFromString'] = intArrayFromString;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2985 function intArrayToString(array) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2986 var ret = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2987 for (var i = 0; i < array.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2988 var chr = array[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2989 if (chr > 0xFF) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2990 chr &= 0xFF;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2991 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2992 ret.push(String.fromCharCode(chr));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2993 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2994 return ret.join('');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2995 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2996 Module['intArrayToString'] = intArrayToString;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2997 // Write a Javascript array to somewhere in the heap\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2998 function writeStringToMemory(string, buffer, dontAddNull) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2999 var array = intArrayFromString(string, dontAddNull);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3000 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3001 while (i < array.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3002 var chr = array[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3003 HEAP8[(((buffer)+(i))|0)]=chr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3004 i = i + 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3005 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3006 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3007 Module['writeStringToMemory'] = writeStringToMemory;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3008 function writeArrayToMemory(array, buffer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3009 for (var i = 0; i < array.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3010 HEAP8[(((buffer)+(i))|0)]=array[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3011 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3012 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3013 Module['writeArrayToMemory'] = writeArrayToMemory;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3014 function unSign(value, bits, ignore, sig) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3015 if (value >= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3016 return value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3017 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3019 : Math.pow(2, bits) + value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3020 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3021 function reSign(value, bits, ignore, sig) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3022 if (value <= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3023 return value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3024 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3025 var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3026 : Math.pow(2, bits-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3029 // TODO: In i64 mode 1, resign the two parts separately and safely\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3031 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3032 return value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3033 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3034 if (!Math['imul']) Math['imul'] = function(a, b) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3035 var ah = a >>> 16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3036 var al = a & 0xffff;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3037 var bh = b >>> 16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3038 var bl = b & 0xffff;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3039 return (al*bl + ((ah*bl + al*bh) << 16))|0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3040 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3041 Math.imul = Math['imul'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3042 // A counter of dependencies for calling run(). If we need to\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3043 // do asynchronous work before running, increment this and\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3044 // decrement it. Incrementing must happen in a place like\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3045 // PRE_RUN_ADDITIONS (used by emcc to add file preloading).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3046 // Note that you can add dependencies in preRun, even though\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3047 // it happens right before run - run will be postponed until\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3048 // the dependencies are met.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3049 var runDependencies = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3050 var runDependencyTracking = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3051 var calledInit = false, calledRun = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3052 var runDependencyWatcher = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3053 function addRunDependency(id) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3054 runDependencies++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3055 if (Module['monitorRunDependencies']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3056 Module['monitorRunDependencies'](runDependencies);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3057 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3058 if (id) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3059 assert(!runDependencyTracking[id]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3060 runDependencyTracking[id] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3061 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3062 Module.printErr('warning: run dependency added without ID');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3063 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3064 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3065 Module['addRunDependency'] = addRunDependency;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3066 function removeRunDependency(id) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3067 runDependencies--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3068 if (Module['monitorRunDependencies']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3069 Module['monitorRunDependencies'](runDependencies);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3070 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3071 if (id) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3072 assert(runDependencyTracking[id]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3073 delete runDependencyTracking[id];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3074 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3075 Module.printErr('warning: run dependency removed without ID');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3076 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3077 if (runDependencies == 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3078 if (runDependencyWatcher !== null) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3079 clearInterval(runDependencyWatcher);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3080 runDependencyWatcher = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3081 } \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3083 if (!calledRun && shouldRunNow) run();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3084 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3085 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3086 Module['removeRunDependency'] = removeRunDependency;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3087 Module[\"preloadedImages\"] = {}; // maps url to image data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3088 Module[\"preloadedAudios\"] = {}; // maps url to audio data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3089 function loadMemoryInitializer(filename) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3090 function applyData(data) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3091 HEAPU8.set(data, STATIC_BASE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3092 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3093 // always do this asynchronously, to keep shell and web as similar as possible\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3094 addOnPreRun(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3095 if (ENVIRONMENT_IS_NODE || ENVIRONMENT_IS_SHELL) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3096 applyData(Module['readBinary'](filename));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3097 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3098 Browser.asyncLoad(filename, function(data) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3099 applyData(data);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3100 }, function(data) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3101 throw 'could not load memory initializer ' + filename;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3102 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3103 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3104 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3105 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3106 // === Body ===\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3107 STATIC_BASE = 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3108 STATICTOP = STATIC_BASE + 11056;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3109 /* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3110 var _stdout;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3111 var _stdin;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3112 var _stderr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3113 var _stdout = _stdout=allocate([0,0,0,0,0,0,0,0], \"i8\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3114 var _stdin = _stdin=allocate([0,0,0,0,0,0,0,0], \"i8\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3115 var _stderr = _stderr=allocate([0,0,0,0,0,0,0,0], \"i8\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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])\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3117 , \"i8\", ALLOC_NONE, Runtime.GLOBAL_BASE)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3118 var tempDoublePtr = Runtime.alignMemory(allocate(12, \"i8\", ALLOC_STATIC), 8);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3119 assert(tempDoublePtr % 8 == 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3120 function copyTempFloat(ptr) { // functions, because inlining this code increases code size too much\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3121 HEAP8[tempDoublePtr] = HEAP8[ptr];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3122 HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3123 HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3124 HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3125 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3126 function copyTempDouble(ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3127 HEAP8[tempDoublePtr] = HEAP8[ptr];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3128 HEAP8[tempDoublePtr+1] = HEAP8[ptr+1];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3129 HEAP8[tempDoublePtr+2] = HEAP8[ptr+2];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3130 HEAP8[tempDoublePtr+3] = HEAP8[ptr+3];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3131 HEAP8[tempDoublePtr+4] = HEAP8[ptr+4];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3132 HEAP8[tempDoublePtr+5] = HEAP8[ptr+5];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3133 HEAP8[tempDoublePtr+6] = HEAP8[ptr+6];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3134 HEAP8[tempDoublePtr+7] = HEAP8[ptr+7];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3135 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3136 Module[\"_strlen\"] = _strlen;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3137 var _llvm_va_start=undefined;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3138 function _llvm_va_end() {}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3139 Module[\"_memcpy\"] = _memcpy;var _llvm_memcpy_p0i8_p0i8_i32=_memcpy;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3140 var _floor=Math.floor;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3141 var _llvm_pow_f64=Math.pow;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3142 function _llvm_lifetime_start() {}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3143 function _llvm_lifetime_end() {}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3144 function _strchr(ptr, chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3145 ptr--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3146 do {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3147 ptr++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3148 var val = HEAP8[(ptr)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3149 if (val == chr) return ptr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3150 } while (val);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3151 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3152 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\"};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3155 var ___errno_state=0;function ___setErrNo(value) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3156 // For convenient setting and returning of errno.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3157 HEAP32[((___errno_state)>>2)]=value\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3158 return value;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3159 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3160 var VFS=undefined;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3161 var PATH={splitPath:function (filename) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3162 var splitPathRe = /^(\\/?|)([\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3163 return splitPathRe.exec(filename).slice(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3164 },normalizeArray:function (parts, allowAboveRoot) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3165 // if the path tries to go above the root, `up` ends up > 0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3166 var up = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3167 for (var i = parts.length - 1; i >= 0; i--) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3168 var last = parts[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3169 if (last === '.') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3170 parts.splice(i, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3171 } else if (last === '..') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3172 parts.splice(i, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3173 up++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3174 } else if (up) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3175 parts.splice(i, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3176 up--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3177 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3178 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3179 // if the path is allowed to go above the root, restore leading ..s\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3180 if (allowAboveRoot) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3181 for (; up--; up) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3182 parts.unshift('..');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3183 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3184 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3185 return parts;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3186 },normalize:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3187 var isAbsolute = path.charAt(0) === '/',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3188 trailingSlash = path.substr(-1) === '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3189 // Normalize the path\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3190 path = PATH.normalizeArray(path.split('/').filter(function(p) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3191 return !!p;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3192 }), !isAbsolute).join('/');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3193 if (!path && !isAbsolute) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3194 path = '.';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3195 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3196 if (path && trailingSlash) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3197 path += '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3198 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3199 return (isAbsolute ? '/' : '') + path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3200 },dirname:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3201 var result = PATH.splitPath(path),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3202 root = result[0],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3203 dir = result[1];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3204 if (!root && !dir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3205 // No dirname whatsoever\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3206 return '.';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3207 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3208 if (dir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3209 // It has a dirname, strip trailing slash\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3210 dir = dir.substr(0, dir.length - 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3211 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3212 return root + dir;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3213 },basename:function (path, ext) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3214 // EMSCRIPTEN return '/'' for '/', not an empty string\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3215 if (path === '/') return '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3216 var f = PATH.splitPath(path)[2];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3217 if (ext && f.substr(-1 * ext.length) === ext) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3218 f = f.substr(0, f.length - ext.length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3219 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3220 return f;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3221 },extname:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3222 return PATH.splitPath(path)[3];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3223 },join:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3224 var paths = Array.prototype.slice.call(arguments, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3225 return PATH.normalize(paths.filter(function(p, index) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3226 if (typeof p !== 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3227 throw new TypeError('Arguments to path.join must be strings');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3228 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3229 return p;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3230 }).join('/'));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3231 },resolve:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3232 var resolvedPath = '',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3233 resolvedAbsolute = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3234 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3235 var path = (i >= 0) ? arguments[i] : FS.cwd();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3236 // Skip empty and invalid entries\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3237 if (typeof path !== 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3238 throw new TypeError('Arguments to path.resolve must be strings');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3239 } else if (!path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3240 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3241 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3242 resolvedPath = path + '/' + resolvedPath;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3243 resolvedAbsolute = path.charAt(0) === '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3244 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3245 // At this point the path should be resolved to a full absolute path, but\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3246 // handle relative paths to be safe (might happen when process.cwd() fails)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3247 resolvedPath = PATH.normalizeArray(resolvedPath.split('/').filter(function(p) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3248 return !!p;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3249 }), !resolvedAbsolute).join('/');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3250 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3251 },relative:function (from, to) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3252 from = PATH.resolve(from).substr(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3253 to = PATH.resolve(to).substr(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3254 function trim(arr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3255 var start = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3256 for (; start < arr.length; start++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3257 if (arr[start] !== '') break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3258 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3259 var end = arr.length - 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3260 for (; end >= 0; end--) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3261 if (arr[end] !== '') break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3262 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3263 if (start > end) return [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3264 return arr.slice(start, end - start + 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3265 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3266 var fromParts = trim(from.split('/'));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3267 var toParts = trim(to.split('/'));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3268 var length = Math.min(fromParts.length, toParts.length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3269 var samePartsLength = length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3270 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3271 if (fromParts[i] !== toParts[i]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3272 samePartsLength = i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3273 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3274 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3275 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3276 var outputParts = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3277 for (var i = samePartsLength; i < fromParts.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3278 outputParts.push('..');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3279 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3280 outputParts = outputParts.concat(toParts.slice(samePartsLength));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3281 return outputParts.join('/');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3282 }};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3283 var TTY={ttys:[],init:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3284 // https://github.com/kripken/emscripten/pull/1555\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3285 // if (ENVIRONMENT_IS_NODE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3286 // // currently, FS.init does not distinguish if process.stdin is a file or TTY\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3287 // // device, it always assumes it's a TTY device. because of this, we're forcing\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3288 // // process.stdin to UTF8 encoding to at least make stdin reading compatible\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3289 // // with text files until FS.init can be refactored.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3290 // process['stdin']['setEncoding']('utf8');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3291 // }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3292 },shutdown:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3293 // https://github.com/kripken/emscripten/pull/1555\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3294 // if (ENVIRONMENT_IS_NODE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3300 // process['stdin']['pause']();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3301 // }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3302 },register:function (dev, ops) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3303 TTY.ttys[dev] = { input: [], output: [], ops: ops };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3304 FS.registerDevice(dev, TTY.stream_ops);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3305 },stream_ops:{open:function (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3306 var tty = TTY.ttys[stream.node.rdev];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3307 if (!tty) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3308 throw new FS.ErrnoError(ERRNO_CODES.ENODEV);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3309 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3310 stream.tty = tty;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3311 stream.seekable = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3312 },close:function (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3313 // flush any pending line data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3314 if (stream.tty.output.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3315 stream.tty.ops.put_char(stream.tty, 10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3316 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3317 },read:function (stream, buffer, offset, length, pos /* ignored */) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3318 if (!stream.tty || !stream.tty.ops.get_char) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3319 throw new FS.ErrnoError(ERRNO_CODES.ENXIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3320 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3321 var bytesRead = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3322 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3323 var result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3324 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3325 result = stream.tty.ops.get_char(stream.tty);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3326 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3327 throw new FS.ErrnoError(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3328 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3329 if (result === undefined && bytesRead === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3330 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3331 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3332 if (result === null || result === undefined) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3333 bytesRead++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3334 buffer[offset+i] = result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3335 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3336 if (bytesRead) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3337 stream.node.timestamp = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3338 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3339 return bytesRead;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3340 },write:function (stream, buffer, offset, length, pos) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3341 if (!stream.tty || !stream.tty.ops.put_char) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3342 throw new FS.ErrnoError(ERRNO_CODES.ENXIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3343 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3344 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3345 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3346 stream.tty.ops.put_char(stream.tty, buffer[offset+i]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3347 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3348 throw new FS.ErrnoError(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3349 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3350 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3351 if (length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3352 stream.node.timestamp = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3353 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3354 return i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3355 }},default_tty_ops:{get_char:function (tty) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3356 if (!tty.input.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3357 var result = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3358 if (ENVIRONMENT_IS_NODE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3359 result = process['stdin']['read']();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3360 if (!result) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3361 if (process['stdin']['_readableState'] && process['stdin']['_readableState']['ended']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3362 return null; // EOF\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3363 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3364 return undefined; // no data available\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3365 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3366 } else if (typeof window != 'undefined' &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3367 typeof window.prompt == 'function') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3368 // Browser.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3369 result = window.prompt('Input: '); // returns null on cancel\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3370 if (result !== null) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3371 result += '\\n';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3372 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3373 } else if (typeof readline == 'function') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3374 // Command line.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3375 result = readline();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3376 if (result !== null) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3377 result += '\\n';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3378 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3379 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3380 if (!result) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3381 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3382 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3383 tty.input = intArrayFromString(result, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3384 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3385 return tty.input.shift();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3386 },put_char:function (tty, val) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3387 if (val === null || val === 10) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3388 Module['print'](tty.output.join(''));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3389 tty.output = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3390 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3391 tty.output.push(TTY.utf8.processCChar(val));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3392 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3393 }},default_tty1_ops:{put_char:function (tty, val) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3394 if (val === null || val === 10) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3395 Module['printErr'](tty.output.join(''));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3396 tty.output = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3397 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3398 tty.output.push(TTY.utf8.processCChar(val));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3399 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3400 }}};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3401 var MEMFS={CONTENT_OWNING:1,CONTENT_FLEXIBLE:2,CONTENT_FIXED:3,ensureFlexible:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3402 if (node.contentMode !== MEMFS.CONTENT_FLEXIBLE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3403 var contents = node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3404 node.contents = Array.prototype.slice.call(contents);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3405 node.contentMode = MEMFS.CONTENT_FLEXIBLE;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3406 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3407 },mount:function (mount) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3408 return MEMFS.create_node(null, '/', 0040000 | 0777, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3409 },create_node:function (parent, name, mode, dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3410 if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3411 // no supported\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3412 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3413 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3414 var node = FS.createNode(parent, name, mode, dev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3415 if (FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3416 node.node_ops = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3417 getattr: MEMFS.node_ops.getattr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3418 setattr: MEMFS.node_ops.setattr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3419 lookup: MEMFS.node_ops.lookup,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3420 mknod: MEMFS.node_ops.mknod,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3421 mknod: MEMFS.node_ops.mknod,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3422 rename: MEMFS.node_ops.rename,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3423 unlink: MEMFS.node_ops.unlink,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3424 rmdir: MEMFS.node_ops.rmdir,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3425 readdir: MEMFS.node_ops.readdir,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3426 symlink: MEMFS.node_ops.symlink\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3427 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3428 node.stream_ops = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3429 llseek: MEMFS.stream_ops.llseek\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3430 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3431 node.contents = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3432 } else if (FS.isFile(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3433 node.node_ops = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3434 getattr: MEMFS.node_ops.getattr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3435 setattr: MEMFS.node_ops.setattr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3436 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3437 node.stream_ops = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3438 llseek: MEMFS.stream_ops.llseek,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3439 read: MEMFS.stream_ops.read,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3440 write: MEMFS.stream_ops.write,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3441 allocate: MEMFS.stream_ops.allocate,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3442 mmap: MEMFS.stream_ops.mmap\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3443 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3444 node.contents = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3445 node.contentMode = MEMFS.CONTENT_FLEXIBLE;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3446 } else if (FS.isLink(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3447 node.node_ops = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3448 getattr: MEMFS.node_ops.getattr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3449 setattr: MEMFS.node_ops.setattr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3450 readlink: MEMFS.node_ops.readlink\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3451 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3452 node.stream_ops = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3453 } else if (FS.isChrdev(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3454 node.node_ops = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3455 getattr: MEMFS.node_ops.getattr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3456 setattr: MEMFS.node_ops.setattr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3457 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3458 node.stream_ops = FS.chrdev_stream_ops;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3459 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3460 node.timestamp = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3461 // add the new node to the parent\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3462 if (parent) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3463 parent.contents[name] = node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3464 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3465 return node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3466 },node_ops:{getattr:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3467 var attr = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3468 // device numbers reuse inode numbers.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3469 attr.dev = FS.isChrdev(node.mode) ? node.id : 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3470 attr.ino = node.id;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3471 attr.mode = node.mode;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3472 attr.nlink = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3473 attr.uid = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3474 attr.gid = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3475 attr.rdev = node.rdev;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3476 if (FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3477 attr.size = 4096;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3478 } else if (FS.isFile(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3479 attr.size = node.contents.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3480 } else if (FS.isLink(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3481 attr.size = node.link.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3482 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3483 attr.size = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3484 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3485 attr.atime = new Date(node.timestamp);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3486 attr.mtime = new Date(node.timestamp);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3487 attr.ctime = new Date(node.timestamp);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3488 // NOTE: In our implementation, st_blocks = Math.ceil(st_size/st_blksize),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3489 // but this is not required by the standard.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3490 attr.blksize = 4096;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3491 attr.blocks = Math.ceil(attr.size / attr.blksize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3492 return attr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3493 },setattr:function (node, attr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3494 if (attr.mode !== undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3495 node.mode = attr.mode;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3496 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3497 if (attr.timestamp !== undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3498 node.timestamp = attr.timestamp;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3499 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3500 if (attr.size !== undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3501 MEMFS.ensureFlexible(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3502 var contents = node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3503 if (attr.size < contents.length) contents.length = attr.size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3504 else while (attr.size > contents.length) contents.push(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3505 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3506 },lookup:function (parent, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3507 throw new FS.ErrnoError(ERRNO_CODES.ENOENT);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3508 },mknod:function (parent, name, mode, dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3509 return MEMFS.create_node(parent, name, mode, dev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3510 },rename:function (old_node, new_dir, new_name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3511 // if we're overwriting a directory at new_name, make sure it's empty.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3512 if (FS.isDir(old_node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3513 var new_node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3514 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3515 new_node = FS.lookupNode(new_dir, new_name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3516 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3517 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3518 if (new_node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3519 for (var i in new_node.contents) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3520 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3521 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3522 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3523 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3524 // do the internal rewiring\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3525 delete old_node.parent.contents[old_node.name];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3526 old_node.name = new_name;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3527 new_dir.contents[new_name] = old_node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3528 },unlink:function (parent, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3529 delete parent.contents[name];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3530 },rmdir:function (parent, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3531 var node = FS.lookupNode(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3532 for (var i in node.contents) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3533 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3534 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3535 delete parent.contents[name];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3536 },readdir:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3537 var entries = ['.', '..']\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3538 for (var key in node.contents) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3539 if (!node.contents.hasOwnProperty(key)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3540 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3541 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3542 entries.push(key);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3543 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3544 return entries;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3545 },symlink:function (parent, newname, oldpath) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3546 var node = MEMFS.create_node(parent, newname, 0777 | 0120000, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3547 node.link = oldpath;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3548 return node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3549 },readlink:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3550 if (!FS.isLink(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3551 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3552 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3553 return node.link;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3554 }},stream_ops:{read:function (stream, buffer, offset, length, position) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3555 var contents = stream.node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3556 var size = Math.min(contents.length - position, length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3557 if (size > 8 && contents.subarray) { // non-trivial, and typed array\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3558 buffer.set(contents.subarray(position, position + size), offset);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3559 } else\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3560 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3561 for (var i = 0; i < size; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3562 buffer[offset + i] = contents[position + i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3563 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3564 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3565 return size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3566 },write:function (stream, buffer, offset, length, position, canOwn) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3567 var node = stream.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3568 node.timestamp = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3569 var contents = node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3570 if (length && contents.length === 0 && position === 0 && buffer.subarray) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3571 // just replace it with the new data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3572 assert(buffer.length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3573 if (canOwn && buffer.buffer === HEAP8.buffer && offset === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3574 node.contents = buffer; // this is a subarray of the heap, and we can own it\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3575 node.contentMode = MEMFS.CONTENT_OWNING;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3576 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3577 node.contents = new Uint8Array(buffer.subarray(offset, offset+length));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3578 node.contentMode = MEMFS.CONTENT_FIXED;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3579 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3580 return length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3581 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3582 MEMFS.ensureFlexible(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3583 var contents = node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3584 while (contents.length < position) contents.push(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3585 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3586 contents[position + i] = buffer[offset + i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3587 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3588 return length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3589 },llseek:function (stream, offset, whence) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3590 var position = offset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3591 if (whence === 1) { // SEEK_CUR.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3592 position += stream.position;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3593 } else if (whence === 2) { // SEEK_END.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3594 if (FS.isFile(stream.node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3595 position += stream.node.contents.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3596 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3597 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3598 if (position < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3599 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3600 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3601 stream.ungotten = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3602 stream.position = position;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3603 return position;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3604 },allocate:function (stream, offset, length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3605 MEMFS.ensureFlexible(stream.node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3606 var contents = stream.node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3607 var limit = offset + length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3608 while (limit > contents.length) contents.push(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3609 },mmap:function (stream, buffer, offset, length, position, prot, flags) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3610 if (!FS.isFile(stream.node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3611 throw new FS.ErrnoError(ERRNO_CODES.ENODEV);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3612 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3613 var ptr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3614 var allocated;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3615 var contents = stream.node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3616 // Only make a new copy when MAP_PRIVATE is specified.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3617 if ( !(flags & 0x02) &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3618 (contents.buffer === buffer || contents.buffer === buffer.buffer) ) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3619 // We can't emulate MAP_SHARED when the file is not backed by the buffer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3620 // we're mapping to (e.g. the HEAP buffer).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3621 allocated = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3622 ptr = contents.byteOffset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3623 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3624 // Try to avoid unnecessary slices.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3625 if (position > 0 || position + length < contents.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3626 if (contents.subarray) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3627 contents = contents.subarray(position, position + length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3628 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3629 contents = Array.prototype.slice.call(contents, position, position + length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3630 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3631 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3632 allocated = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3633 ptr = _malloc(length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3634 if (!ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3635 throw new FS.ErrnoError(ERRNO_CODES.ENOMEM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3636 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3637 buffer.set(contents, ptr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3638 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3639 return { ptr: ptr, allocated: allocated };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3640 }}};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3641 var _stdin=allocate(1, \"i32*\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3642 var _stdout=allocate(1, \"i32*\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3643 var _stderr=allocate(1, \"i32*\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3644 function _fflush(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3645 // int fflush(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3646 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fflush.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3647 // we don't currently perform any user-space buffering of data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3649 this.errno = errno;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3650 for (var key in ERRNO_CODES) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3651 if (ERRNO_CODES[key] === errno) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3652 this.code = key;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3653 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3654 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3655 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3656 this.message = ERRNO_MESSAGES[errno];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3657 },handleFSError:function (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3658 if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + new Error().stack;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3659 return ___setErrNo(e.errno);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3660 },cwd:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3661 return FS.currentPath;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3662 },lookupPath:function (path, opts) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3663 path = PATH.resolve(FS.currentPath, path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3664 opts = opts || { recurse_count: 0 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3665 if (opts.recurse_count > 8) { // max recursive lookup of 8\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3666 throw new FS.ErrnoError(ERRNO_CODES.ELOOP);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3667 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3668 // split the path\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3669 var parts = PATH.normalizeArray(path.split('/').filter(function(p) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3670 return !!p;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3671 }), false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3672 // start at the root\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3673 var current = FS.root;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3674 var current_path = '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3675 for (var i = 0; i < parts.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3676 var islast = (i === parts.length-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3677 if (islast && opts.parent) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3678 // stop resolving\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3679 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3680 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3681 current = FS.lookupNode(current, parts[i]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3682 current_path = PATH.join(current_path, parts[i]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3683 // jump to the mount's root node if this is a mountpoint\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3684 if (FS.isMountpoint(current)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3685 current = current.mount.root;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3686 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3687 // follow symlinks\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3688 // by default, lookupPath will not follow a symlink if it is the final path component.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3689 // setting opts.follow = true will override this behavior.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3690 if (!islast || opts.follow) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3691 var count = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3692 while (FS.isLink(current.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3693 var link = FS.readlink(current_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3694 current_path = PATH.resolve(PATH.dirname(current_path), link);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3695 var lookup = FS.lookupPath(current_path, { recurse_count: opts.recurse_count });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3696 current = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3697 if (count++ > 40) { // limit max consecutive symlinks to 40 (SYMLOOP_MAX).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3698 throw new FS.ErrnoError(ERRNO_CODES.ELOOP);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3699 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3700 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3701 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3702 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3703 return { path: current_path, node: current };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3704 },getPath:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3705 var path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3706 while (true) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3707 if (FS.isRoot(node)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3708 return path ? PATH.join(node.mount.mountpoint, path) : node.mount.mountpoint;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3709 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3710 path = path ? PATH.join(node.name, path) : node.name;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3711 node = node.parent;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3712 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3713 },hashName:function (parentid, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3714 var hash = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3715 for (var i = 0; i < name.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3716 hash = ((hash << 5) - hash + name.charCodeAt(i)) | 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3717 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3718 return ((parentid + hash) >>> 0) % FS.nameTable.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3719 },hashAddNode:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3720 var hash = FS.hashName(node.parent.id, node.name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3721 node.name_next = FS.nameTable[hash];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3722 FS.nameTable[hash] = node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3723 },hashRemoveNode:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3724 var hash = FS.hashName(node.parent.id, node.name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3725 if (FS.nameTable[hash] === node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3726 FS.nameTable[hash] = node.name_next;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3727 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3728 var current = FS.nameTable[hash];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3729 while (current) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3730 if (current.name_next === node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3731 current.name_next = node.name_next;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3732 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3733 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3734 current = current.name_next;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3735 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3736 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3737 },lookupNode:function (parent, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3738 var err = FS.mayLookup(parent);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3739 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3740 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3741 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3742 var hash = FS.hashName(parent.id, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3743 for (var node = FS.nameTable[hash]; node; node = node.name_next) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3744 if (node.parent.id === parent.id && node.name === name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3745 return node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3746 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3747 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3748 // if we failed to find it in the cache, call into the VFS\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3749 return FS.lookup(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3750 },createNode:function (parent, name, mode, rdev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3751 var node = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3752 id: FS.nextInode++,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3753 name: name,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3754 mode: mode,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3755 node_ops: {},\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3756 stream_ops: {},\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3757 rdev: rdev,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3758 parent: null,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3759 mount: null\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3760 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3761 if (!parent) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3762 parent = node; // root node sets parent to itself\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3763 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3764 node.parent = parent;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3765 node.mount = parent.mount;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3766 // compatibility\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3767 var readMode = 292 | 73;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3768 var writeMode = 146;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3769 // NOTE we must use Object.defineProperties instead of individual calls to\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3770 // Object.defineProperty in order to make closure compiler happy\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3771 Object.defineProperties(node, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3772 read: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3773 get: function() { return (node.mode & readMode) === readMode; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3774 set: function(val) { val ? node.mode |= readMode : node.mode &= ~readMode; }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3775 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3776 write: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3777 get: function() { return (node.mode & writeMode) === writeMode; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3778 set: function(val) { val ? node.mode |= writeMode : node.mode &= ~writeMode; }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3779 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3780 isFolder: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3781 get: function() { return FS.isDir(node.mode); },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3782 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3783 isDevice: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3784 get: function() { return FS.isChrdev(node.mode); },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3785 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3786 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3787 FS.hashAddNode(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3788 return node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3789 },destroyNode:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3790 FS.hashRemoveNode(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3791 },isRoot:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3792 return node === node.parent;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3793 },isMountpoint:function (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3794 return node.mounted;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3795 },isFile:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3796 return (mode & 0170000) === 0100000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3797 },isDir:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3798 return (mode & 0170000) === 0040000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3799 },isLink:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3800 return (mode & 0170000) === 0120000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3801 },isChrdev:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3802 return (mode & 0170000) === 0020000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3803 },isBlkdev:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3804 return (mode & 0170000) === 0060000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3805 },isFIFO:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3806 return (mode & 0170000) === 0010000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3807 },isSocket:function (mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3808 return (mode & 0140000) === 0140000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3810 var flags = FS.flagModes[str];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3811 if (typeof flags === 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3812 throw new Error('Unknown file open mode: ' + str);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3813 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3814 return flags;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3815 },flagsToPermissionString:function (flag) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3816 var accmode = flag & 3;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3817 var perms = ['r', 'w', 'rw'][accmode];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3818 if ((flag & 1024)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3819 perms += 'w';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3820 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3821 return perms;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3822 },nodePermissions:function (node, perms) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3823 if (FS.ignorePermissions) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3824 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3825 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3826 // return 0 if any user, group or owner bits are set.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3827 if (perms.indexOf('r') !== -1 && !(node.mode & 292)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3828 return ERRNO_CODES.EACCES;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3829 } else if (perms.indexOf('w') !== -1 && !(node.mode & 146)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3830 return ERRNO_CODES.EACCES;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3831 } else if (perms.indexOf('x') !== -1 && !(node.mode & 73)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3832 return ERRNO_CODES.EACCES;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3833 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3834 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3835 },mayLookup:function (dir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3836 return FS.nodePermissions(dir, 'x');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3837 },mayCreate:function (dir, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3838 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3839 var node = FS.lookupNode(dir, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3840 return ERRNO_CODES.EEXIST;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3841 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3842 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3843 return FS.nodePermissions(dir, 'wx');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3844 },mayDelete:function (dir, name, isdir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3845 var node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3846 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3847 node = FS.lookupNode(dir, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3848 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3849 return e.errno;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3850 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3851 var err = FS.nodePermissions(dir, 'wx');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3852 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3853 return err;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3854 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3855 if (isdir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3856 if (!FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3857 return ERRNO_CODES.ENOTDIR;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3858 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3859 if (FS.isRoot(node) || FS.getPath(node) === FS.currentPath) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3860 return ERRNO_CODES.EBUSY;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3861 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3862 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3863 if (FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3864 return ERRNO_CODES.EISDIR;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3865 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3866 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3867 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3868 },mayOpen:function (node, flags) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3869 if (!node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3870 return ERRNO_CODES.ENOENT;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3871 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3872 if (FS.isLink(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3873 return ERRNO_CODES.ELOOP;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3874 } else if (FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3875 if ((flags & 3) !== 0 || // opening for write\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3876 (flags & 1024)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3877 return ERRNO_CODES.EISDIR;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3878 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3879 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3880 return FS.nodePermissions(node, FS.flagsToPermissionString(flags));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3881 },MAX_OPEN_FDS:4096,nextfd:function (fd_start, fd_end) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3882 fd_start = fd_start || 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3883 fd_end = fd_end || FS.MAX_OPEN_FDS;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3884 for (var fd = fd_start; fd <= fd_end; fd++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3885 if (!FS.streams[fd]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3886 return fd;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3887 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3888 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3889 throw new FS.ErrnoError(ERRNO_CODES.EMFILE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3890 },getStream:function (fd) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3891 return FS.streams[fd];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3892 },createStream:function (stream, fd_start, fd_end) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3893 var fd = FS.nextfd(fd_start, fd_end);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3894 stream.fd = fd;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3895 // compatibility\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3896 Object.defineProperties(stream, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3897 object: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3898 get: function() { return stream.node; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3899 set: function(val) { stream.node = val; }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3900 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3901 isRead: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3902 get: function() { return (stream.flags & 3) !== 1; }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3903 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3904 isWrite: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3905 get: function() { return (stream.flags & 3) !== 0; }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3906 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3907 isAppend: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3908 get: function() { return (stream.flags & 8); }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3909 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3910 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3911 FS.streams[fd] = stream;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3912 return stream;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3913 },closeStream:function (fd) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3914 FS.streams[fd] = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3915 },chrdev_stream_ops:{open:function (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3916 var device = FS.getDevice(stream.node.rdev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3917 // override node's stream ops with the device's\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3918 stream.stream_ops = device.stream_ops;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3919 // forward the open call\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3920 if (stream.stream_ops.open) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3921 stream.stream_ops.open(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3922 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3923 },llseek:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3924 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3925 }},major:function (dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3926 return ((dev) >> 8);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3927 },minor:function (dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3928 return ((dev) & 0xff);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3929 },makedev:function (ma, mi) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3930 return ((ma) << 8 | (mi));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3931 },registerDevice:function (dev, ops) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3932 FS.devices[dev] = { stream_ops: ops };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3933 },getDevice:function (dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3934 return FS.devices[dev];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3935 },mount:function (type, opts, mountpoint) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3936 var mount = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3937 type: type,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3938 opts: opts,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3939 mountpoint: mountpoint,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3940 root: null\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3941 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3942 var lookup;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3943 if (mountpoint) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3944 lookup = FS.lookupPath(mountpoint, { follow: false });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3945 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3946 // create a root node for the fs\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3947 var root = type.mount(mount);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3948 root.mount = mount;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3949 mount.root = root;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3950 // assign the mount info to the mountpoint's node\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3951 if (lookup) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3952 lookup.node.mount = mount;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3953 lookup.node.mounted = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3954 // compatibility update FS.root if we mount to /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3955 if (mountpoint === '/') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3956 FS.root = mount.root;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3957 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3958 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3959 return root;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3960 },lookup:function (parent, name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3961 return parent.node_ops.lookup(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3962 },mknod:function (path, mode, dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3963 var lookup = FS.lookupPath(path, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3964 var parent = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3965 var name = PATH.basename(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3966 var err = FS.mayCreate(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3967 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3968 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3969 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3970 if (!parent.node_ops.mknod) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3971 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3972 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3973 return parent.node_ops.mknod(parent, name, mode, dev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3974 },create:function (path, mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3975 mode = mode !== undefined ? mode : 0666;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3976 mode &= 4095;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3977 mode |= 0100000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3978 return FS.mknod(path, mode, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3979 },mkdir:function (path, mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3980 mode = mode !== undefined ? mode : 0777;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3981 mode &= 511 | 0001000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3982 mode |= 0040000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3983 return FS.mknod(path, mode, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3984 },mkdev:function (path, mode, dev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3985 if (typeof(dev) === 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3986 dev = mode;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3987 mode = 0666;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3988 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3989 mode |= 0020000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3990 return FS.mknod(path, mode, dev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3991 },symlink:function (oldpath, newpath) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3992 var lookup = FS.lookupPath(newpath, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3993 var parent = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3994 var newname = PATH.basename(newpath);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3995 var err = FS.mayCreate(parent, newname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3996 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3997 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3998 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3999 if (!parent.node_ops.symlink) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4000 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4001 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4002 return parent.node_ops.symlink(parent, newname, oldpath);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4003 },rename:function (old_path, new_path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4004 var old_dirname = PATH.dirname(old_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4005 var new_dirname = PATH.dirname(new_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4006 var old_name = PATH.basename(old_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4007 var new_name = PATH.basename(new_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4008 // parents must exist\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4009 var lookup, old_dir, new_dir;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4010 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4011 lookup = FS.lookupPath(old_path, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4012 old_dir = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4013 lookup = FS.lookupPath(new_path, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4014 new_dir = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4015 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4016 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4017 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4018 // need to be part of the same mount\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4019 if (old_dir.mount !== new_dir.mount) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4020 throw new FS.ErrnoError(ERRNO_CODES.EXDEV);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4021 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4022 // source must exist\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4023 var old_node = FS.lookupNode(old_dir, old_name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4024 // old path should not be an ancestor of the new path\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4025 var relative = PATH.relative(old_path, new_dirname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4026 if (relative.charAt(0) !== '.') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4027 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4028 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4029 // new path should not be an ancestor of the old path\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4030 relative = PATH.relative(new_path, old_dirname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4031 if (relative.charAt(0) !== '.') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4032 throw new FS.ErrnoError(ERRNO_CODES.ENOTEMPTY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4033 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4034 // see if the new path already exists\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4035 var new_node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4036 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4037 new_node = FS.lookupNode(new_dir, new_name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4038 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4039 // not fatal\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4040 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4041 // early out if nothing needs to change\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4042 if (old_node === new_node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4043 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4044 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4045 // we'll need to delete the old entry\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4046 var isdir = FS.isDir(old_node.mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4047 var err = FS.mayDelete(old_dir, old_name, isdir);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4048 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4049 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4050 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4051 // need delete permissions if we'll be overwriting.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4052 // need create permissions if new doesn't already exist.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4053 err = new_node ?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4054 FS.mayDelete(new_dir, new_name, isdir) :\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4055 FS.mayCreate(new_dir, new_name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4056 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4057 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4058 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4059 if (!old_dir.node_ops.rename) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4060 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4061 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4062 if (FS.isMountpoint(old_node) || (new_node && FS.isMountpoint(new_node))) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4063 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4064 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4065 // if we are going to change the parent, check write permissions\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4066 if (new_dir !== old_dir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4067 err = FS.nodePermissions(old_dir, 'w');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4068 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4069 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4070 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4071 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4072 // remove the node from the lookup hash\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4073 FS.hashRemoveNode(old_node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4074 // do the underlying fs rename\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4075 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4076 old_dir.node_ops.rename(old_node, new_dir, new_name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4077 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4078 throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4079 } finally {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4080 // add the node back to the hash (in case node_ops.rename\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4081 // changed its name)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4082 FS.hashAddNode(old_node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4083 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4084 },rmdir:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4085 var lookup = FS.lookupPath(path, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4086 var parent = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4087 var name = PATH.basename(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4088 var node = FS.lookupNode(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4089 var err = FS.mayDelete(parent, name, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4090 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4091 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4092 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4093 if (!parent.node_ops.rmdir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4094 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4095 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4096 if (FS.isMountpoint(node)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4097 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4098 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4099 parent.node_ops.rmdir(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4100 FS.destroyNode(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4101 },readdir:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4102 var lookup = FS.lookupPath(path, { follow: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4103 var node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4104 if (!node.node_ops.readdir) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4105 throw new FS.ErrnoError(ERRNO_CODES.ENOTDIR);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4106 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4107 return node.node_ops.readdir(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4108 },unlink:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4109 var lookup = FS.lookupPath(path, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4110 var parent = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4111 var name = PATH.basename(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4112 var node = FS.lookupNode(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4113 var err = FS.mayDelete(parent, name, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4114 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4115 // POSIX says unlink should set EPERM, not EISDIR\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4116 if (err === ERRNO_CODES.EISDIR) err = ERRNO_CODES.EPERM;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4117 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4118 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4119 if (!parent.node_ops.unlink) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4120 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4121 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4122 if (FS.isMountpoint(node)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4123 throw new FS.ErrnoError(ERRNO_CODES.EBUSY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4124 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4125 parent.node_ops.unlink(parent, name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4126 FS.destroyNode(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4127 },readlink:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4128 var lookup = FS.lookupPath(path, { follow: false });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4129 var link = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4130 if (!link.node_ops.readlink) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4131 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4132 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4133 return link.node_ops.readlink(link);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4134 },stat:function (path, dontFollow) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4135 var lookup = FS.lookupPath(path, { follow: !dontFollow });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4136 var node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4137 if (!node.node_ops.getattr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4138 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4139 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4140 return node.node_ops.getattr(node);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4141 },lstat:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4142 return FS.stat(path, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4143 },chmod:function (path, mode, dontFollow) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4144 var node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4145 if (typeof path === 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4146 var lookup = FS.lookupPath(path, { follow: !dontFollow });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4147 node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4148 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4149 node = path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4150 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4151 if (!node.node_ops.setattr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4152 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4153 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4154 node.node_ops.setattr(node, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4155 mode: (mode & 4095) | (node.mode & ~4095),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4156 timestamp: Date.now()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4157 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4158 },lchmod:function (path, mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4159 FS.chmod(path, mode, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4160 },fchmod:function (fd, mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4161 var stream = FS.getStream(fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4162 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4163 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4164 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4165 FS.chmod(stream.node, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4166 },chown:function (path, uid, gid, dontFollow) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4167 var node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4168 if (typeof path === 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4169 var lookup = FS.lookupPath(path, { follow: !dontFollow });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4170 node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4171 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4172 node = path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4173 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4174 if (!node.node_ops.setattr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4175 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4176 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4177 node.node_ops.setattr(node, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4178 timestamp: Date.now()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4179 // we ignore the uid / gid for now\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4180 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4181 },lchown:function (path, uid, gid) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4182 FS.chown(path, uid, gid, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4183 },fchown:function (fd, uid, gid) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4184 var stream = FS.getStream(fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4185 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4186 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4187 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4188 FS.chown(stream.node, uid, gid);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4189 },truncate:function (path, len) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4190 if (len < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4191 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4192 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4193 var node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4194 if (typeof path === 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4195 var lookup = FS.lookupPath(path, { follow: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4196 node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4197 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4198 node = path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4199 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4200 if (!node.node_ops.setattr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4201 throw new FS.ErrnoError(ERRNO_CODES.EPERM);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4202 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4203 if (FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4204 throw new FS.ErrnoError(ERRNO_CODES.EISDIR);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4205 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4206 if (!FS.isFile(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4207 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4208 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4209 var err = FS.nodePermissions(node, 'w');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4210 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4211 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4212 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4213 node.node_ops.setattr(node, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4214 size: len,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4215 timestamp: Date.now()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4216 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4217 },ftruncate:function (fd, len) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4218 var stream = FS.getStream(fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4219 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4220 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4221 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4222 if ((stream.flags & 3) === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4223 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4224 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4225 FS.truncate(stream.node, len);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4226 },utime:function (path, atime, mtime) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4227 var lookup = FS.lookupPath(path, { follow: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4228 var node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4229 node.node_ops.setattr(node, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4230 timestamp: Math.max(atime, mtime)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4231 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4232 },open:function (path, flags, mode, fd_start, fd_end) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4233 path = PATH.normalize(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4234 flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4235 mode = typeof mode === 'undefined' ? 0666 : mode;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4236 if ((flags & 512)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4237 mode = (mode & 4095) | 0100000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4238 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4239 mode = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4240 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4241 var node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4242 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4243 var lookup = FS.lookupPath(path, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4244 follow: !(flags & 0200000)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4245 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4246 node = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4247 path = lookup.path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4248 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4249 // ignore\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4250 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4251 // perhaps we need to create the node\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4252 if ((flags & 512)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4253 if (node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4254 // if O_CREAT and O_EXCL are set, error out if the node already exists\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4255 if ((flags & 2048)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4256 throw new FS.ErrnoError(ERRNO_CODES.EEXIST);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4257 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4258 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4259 // node doesn't exist, try to create it\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4260 node = FS.mknod(path, mode, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4261 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4262 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4263 if (!node) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4264 throw new FS.ErrnoError(ERRNO_CODES.ENOENT);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4265 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4266 // can't truncate a device\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4267 if (FS.isChrdev(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4268 flags &= ~1024;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4269 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4270 // check permissions\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4271 var err = FS.mayOpen(node, flags);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4272 if (err) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4273 throw new FS.ErrnoError(err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4274 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4275 // do truncation if necessary\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4276 if ((flags & 1024)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4277 FS.truncate(node, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4278 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4279 // register the stream with the filesystem\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4280 var stream = FS.createStream({\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4281 path: path,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4282 node: node,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4283 flags: flags,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4284 seekable: true,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4285 position: 0,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4286 stream_ops: node.stream_ops,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4287 // used by the file family libc calls (fopen, fwrite, ferror, etc.)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4288 ungotten: [],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4289 error: false\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4290 }, fd_start, fd_end);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4291 // call the new stream's open function\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4292 if (stream.stream_ops.open) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4293 stream.stream_ops.open(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4294 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4295 return stream;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4296 },close:function (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4297 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4298 if (stream.stream_ops.close) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4299 stream.stream_ops.close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4300 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4301 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4302 throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4303 } finally {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4304 FS.closeStream(stream.fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4305 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4306 },llseek:function (stream, offset, whence) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4307 if (!stream.seekable || !stream.stream_ops.llseek) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4308 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4309 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4310 return stream.stream_ops.llseek(stream, offset, whence);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4311 },read:function (stream, buffer, offset, length, position) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4312 if (length < 0 || position < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4313 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4314 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4315 if ((stream.flags & 3) === 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4316 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4317 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4318 if (FS.isDir(stream.node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4319 throw new FS.ErrnoError(ERRNO_CODES.EISDIR);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4320 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4321 if (!stream.stream_ops.read) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4322 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4323 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4324 var seeking = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4325 if (typeof position === 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4326 position = stream.position;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4327 seeking = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4328 } else if (!stream.seekable) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4329 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4330 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4331 var bytesRead = stream.stream_ops.read(stream, buffer, offset, length, position);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4332 if (!seeking) stream.position += bytesRead;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4333 return bytesRead;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4334 },write:function (stream, buffer, offset, length, position, canOwn) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4335 if (length < 0 || position < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4336 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4337 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4338 if ((stream.flags & 3) === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4339 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4340 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4341 if (FS.isDir(stream.node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4342 throw new FS.ErrnoError(ERRNO_CODES.EISDIR);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4343 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4344 if (!stream.stream_ops.write) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4345 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4346 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4347 var seeking = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4348 if (typeof position === 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4349 position = stream.position;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4350 seeking = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4351 } else if (!stream.seekable) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4352 throw new FS.ErrnoError(ERRNO_CODES.ESPIPE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4353 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4354 if (stream.flags & 8) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4355 // seek to the end before writing in append mode\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4356 FS.llseek(stream, 0, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4357 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4358 var bytesWritten = stream.stream_ops.write(stream, buffer, offset, length, position, canOwn);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4359 if (!seeking) stream.position += bytesWritten;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4360 return bytesWritten;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4361 },allocate:function (stream, offset, length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4362 if (offset < 0 || length <= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4363 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4364 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4365 if ((stream.flags & 3) === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4366 throw new FS.ErrnoError(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4367 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4368 if (!FS.isFile(stream.node.mode) && !FS.isDir(node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4369 throw new FS.ErrnoError(ERRNO_CODES.ENODEV);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4370 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4371 if (!stream.stream_ops.allocate) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4372 throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4373 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4374 stream.stream_ops.allocate(stream, offset, length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4375 },mmap:function (stream, buffer, offset, length, position, prot, flags) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4376 // TODO if PROT is PROT_WRITE, make sure we have write access\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4377 if ((stream.flags & 3) === 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4378 throw new FS.ErrnoError(ERRNO_CODES.EACCES);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4379 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4380 if (!stream.stream_ops.mmap) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4381 throw new FS.errnoError(ERRNO_CODES.ENODEV);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4382 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4383 return stream.stream_ops.mmap(stream, buffer, offset, length, position, prot, flags);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4384 },ioctl:function (stream, cmd, arg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4385 if (!stream.stream_ops.ioctl) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4386 throw new FS.ErrnoError(ERRNO_CODES.ENOTTY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4387 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4388 return stream.stream_ops.ioctl(stream, cmd, arg);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4389 },readFile:function (path, opts) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4390 opts = opts || {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4391 opts.flags = opts.flags || 'r';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4392 opts.encoding = opts.encoding || 'binary';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4393 var ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4394 var stream = FS.open(path, opts.flags);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4395 var stat = FS.stat(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4396 var length = stat.size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4397 var buf = new Uint8Array(length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4398 FS.read(stream, buf, 0, length, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4399 if (opts.encoding === 'utf8') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4400 ret = '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4401 var utf8 = new Runtime.UTF8Processor();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4402 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4403 ret += utf8.processCChar(buf[i]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4404 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4405 } else if (opts.encoding === 'binary') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4406 ret = buf;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4407 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4408 throw new Error('Invalid encoding type \"' + opts.encoding + '\"');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4409 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4410 FS.close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4411 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4412 },writeFile:function (path, data, opts) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4413 opts = opts || {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4414 opts.flags = opts.flags || 'w';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4415 opts.encoding = opts.encoding || 'utf8';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4416 var stream = FS.open(path, opts.flags, opts.mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4417 if (opts.encoding === 'utf8') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4418 var utf8 = new Runtime.UTF8Processor();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4419 var buf = new Uint8Array(utf8.processJSString(data));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4420 FS.write(stream, buf, 0, buf.length, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4421 } else if (opts.encoding === 'binary') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4422 FS.write(stream, data, 0, data.length, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4423 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4424 throw new Error('Invalid encoding type \"' + opts.encoding + '\"');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4425 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4426 FS.close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4427 },createDefaultDirectories:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4428 FS.mkdir('/tmp');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4429 },createDefaultDevices:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4430 // create /dev\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4431 FS.mkdir('/dev');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4432 // setup /dev/null\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4433 FS.registerDevice(FS.makedev(1, 3), {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4434 read: function() { return 0; },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4435 write: function() { return 0; }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4436 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4437 FS.mkdev('/dev/null', FS.makedev(1, 3));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4438 // setup /dev/tty and /dev/tty1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4439 // stderr needs to print output using Module['printErr']\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4440 // so we register a second tty just for it.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4441 TTY.register(FS.makedev(5, 0), TTY.default_tty_ops);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4442 TTY.register(FS.makedev(6, 0), TTY.default_tty1_ops);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4443 FS.mkdev('/dev/tty', FS.makedev(5, 0));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4444 FS.mkdev('/dev/tty1', FS.makedev(6, 0));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4445 // we're not going to emulate the actual shm device,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4446 // just create the tmp dirs that reside in it commonly\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4447 FS.mkdir('/dev/shm');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4448 FS.mkdir('/dev/shm/tmp');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4449 },createStandardStreams:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4450 // TODO deprecate the old functionality of a single\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4451 // input / output callback and that utilizes FS.createDevice\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4452 // and instead require a unique set of stream ops\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4453 // by default, we symlink the standard streams to the\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4454 // default tty devices. however, if the standard streams\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4455 // have been overwritten we create a unique device for\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4456 // them instead.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4457 if (Module['stdin']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4458 FS.createDevice('/dev', 'stdin', Module['stdin']);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4459 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4460 FS.symlink('/dev/tty', '/dev/stdin');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4461 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4462 if (Module['stdout']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4463 FS.createDevice('/dev', 'stdout', null, Module['stdout']);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4464 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4465 FS.symlink('/dev/tty', '/dev/stdout');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4466 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4467 if (Module['stderr']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4468 FS.createDevice('/dev', 'stderr', null, Module['stderr']);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4469 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4470 FS.symlink('/dev/tty1', '/dev/stderr');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4471 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4472 // open default streams for the stdin, stdout and stderr devices\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4473 var stdin = FS.open('/dev/stdin', 'r');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4474 HEAP32[((_stdin)>>2)]=stdin.fd;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4475 assert(stdin.fd === 1, 'invalid handle for stdin (' + stdin.fd + ')');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4476 var stdout = FS.open('/dev/stdout', 'w');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4477 HEAP32[((_stdout)>>2)]=stdout.fd;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4478 assert(stdout.fd === 2, 'invalid handle for stdout (' + stdout.fd + ')');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4479 var stderr = FS.open('/dev/stderr', 'w');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4480 HEAP32[((_stderr)>>2)]=stderr.fd;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4481 assert(stderr.fd === 3, 'invalid handle for stderr (' + stderr.fd + ')');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4482 },staticInit:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4483 FS.nameTable = new Array(4096);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4484 FS.root = FS.createNode(null, '/', 0040000 | 0777, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4485 FS.mount(MEMFS, {}, '/');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4486 FS.createDefaultDirectories();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4487 FS.createDefaultDevices();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4488 },init:function (input, output, error) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4490 FS.init.initialized = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4491 // Allow Module.stdin etc. to provide defaults, if none explicitly passed to us here\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4492 Module['stdin'] = input || Module['stdin'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4493 Module['stdout'] = output || Module['stdout'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4494 Module['stderr'] = error || Module['stderr'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4495 FS.createStandardStreams();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4496 },quit:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4497 FS.init.initialized = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4498 for (var i = 0; i < FS.streams.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4499 var stream = FS.streams[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4500 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4501 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4502 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4503 FS.close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4504 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4505 },getMode:function (canRead, canWrite) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4506 var mode = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4507 if (canRead) mode |= 292 | 73;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4508 if (canWrite) mode |= 146;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4509 return mode;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4510 },joinPath:function (parts, forceRelative) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4511 var path = PATH.join.apply(null, parts);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4512 if (forceRelative && path[0] == '/') path = path.substr(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4513 return path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4514 },absolutePath:function (relative, base) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4515 return PATH.resolve(base, relative);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4516 },standardizePath:function (path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4517 return PATH.normalize(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4518 },findObject:function (path, dontResolveLastLink) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4519 var ret = FS.analyzePath(path, dontResolveLastLink);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4520 if (ret.exists) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4521 return ret.object;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4522 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4523 ___setErrNo(ret.error);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4524 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4525 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4526 },analyzePath:function (path, dontResolveLastLink) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4527 // operate from within the context of the symlink's target\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4528 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4529 var lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4530 path = lookup.path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4531 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4532 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4533 var ret = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4534 isRoot: false, exists: false, error: 0, name: null, path: null, object: null,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4535 parentExists: false, parentPath: null, parentObject: null\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4536 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4537 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4538 var lookup = FS.lookupPath(path, { parent: true });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4539 ret.parentExists = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4540 ret.parentPath = lookup.path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4541 ret.parentObject = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4542 ret.name = PATH.basename(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4543 lookup = FS.lookupPath(path, { follow: !dontResolveLastLink });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4544 ret.exists = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4545 ret.path = lookup.path;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4546 ret.object = lookup.node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4547 ret.name = lookup.node.name;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4548 ret.isRoot = lookup.path === '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4549 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4550 ret.error = e.errno;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4551 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4552 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4553 },createFolder:function (parent, name, canRead, canWrite) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4554 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4555 var mode = FS.getMode(canRead, canWrite);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4556 return FS.mkdir(path, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4557 },createPath:function (parent, path, canRead, canWrite) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4558 parent = typeof parent === 'string' ? parent : FS.getPath(parent);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4559 var parts = path.split('/').reverse();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4560 while (parts.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4561 var part = parts.pop();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4562 if (!part) continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4563 var current = PATH.join(parent, part);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4564 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4565 FS.mkdir(current);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4566 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4567 // ignore EEXIST\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4568 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4569 parent = current;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4570 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4571 return current;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4572 },createFile:function (parent, name, properties, canRead, canWrite) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4573 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4574 var mode = FS.getMode(canRead, canWrite);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4575 return FS.create(path, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4576 },createDataFile:function (parent, name, data, canRead, canWrite, canOwn) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4577 var path = name ? PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name) : parent;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4578 var mode = FS.getMode(canRead, canWrite);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4579 var node = FS.create(path, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4580 if (data) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4581 if (typeof data === 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4582 var arr = new Array(data.length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4583 for (var i = 0, len = data.length; i < len; ++i) arr[i] = data.charCodeAt(i);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4584 data = arr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4585 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4586 // make sure we can write to the file\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4587 FS.chmod(path, mode | 146);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4588 var stream = FS.open(path, 'w');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4589 FS.write(stream, data, 0, data.length, 0, canOwn);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4590 FS.close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4591 FS.chmod(path, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4592 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4593 return node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4594 },createDevice:function (parent, name, input, output) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4595 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4596 var mode = FS.getMode(!!input, !!output);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4597 if (!FS.createDevice.major) FS.createDevice.major = 64;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4598 var dev = FS.makedev(FS.createDevice.major++, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4599 // Create a fake device that a set of stream ops to emulate\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4600 // the old behavior.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4601 FS.registerDevice(dev, {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4602 open: function(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4603 stream.seekable = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4604 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4605 close: function(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4606 // flush any pending line data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4607 if (output && output.buffer && output.buffer.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4608 output(10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4609 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4610 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4611 read: function(stream, buffer, offset, length, pos /* ignored */) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4612 var bytesRead = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4613 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4614 var result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4615 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4616 result = input();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4617 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4618 throw new FS.ErrnoError(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4619 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4620 if (result === undefined && bytesRead === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4621 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4622 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4623 if (result === null || result === undefined) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4624 bytesRead++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4625 buffer[offset+i] = result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4626 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4627 if (bytesRead) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4628 stream.node.timestamp = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4629 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4630 return bytesRead;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4631 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4632 write: function(stream, buffer, offset, length, pos) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4633 for (var i = 0; i < length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4634 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4635 output(buffer[offset+i]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4636 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4637 throw new FS.ErrnoError(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4638 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4639 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4640 if (length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4641 stream.node.timestamp = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4642 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4643 return i;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4644 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4645 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4646 return FS.mkdev(path, mode, dev);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4647 },createLink:function (parent, name, target, canRead, canWrite) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4648 var path = PATH.join(typeof parent === 'string' ? parent : FS.getPath(parent), name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4649 return FS.symlink(target, path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4650 },forceLoadFile:function (obj) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4651 if (obj.isDevice || obj.isFolder || obj.link || obj.contents) return true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4652 var success = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4653 if (typeof XMLHttpRequest !== 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4655 } else if (Module['read']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4656 // Command-line.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4657 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4658 // WARNING: Can't read binary files in V8's d8 or tracemonkey's js, as\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4659 // read() will try to parse UTF8.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4660 obj.contents = intArrayFromString(Module['read'](obj.url), true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4661 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4662 success = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4663 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4664 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4665 throw new Error('Cannot load without read() or XMLHttpRequest.');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4666 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4667 if (!success) ___setErrNo(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4668 return success;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4669 },createLazyFile:function (parent, name, url, canRead, canWrite) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4670 if (typeof XMLHttpRequest !== 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4673 var LazyUint8Array = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4674 this.lengthKnown = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4675 this.chunks = []; // Loaded chunks. Index is the chunk number\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4676 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4677 LazyUint8Array.prototype.get = function(idx) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4678 if (idx > this.length-1 || idx < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4679 return undefined;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4680 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4681 var chunkOffset = idx % this.chunkSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4682 var chunkNum = Math.floor(idx / this.chunkSize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4683 return this.getter(chunkNum)[chunkOffset];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4684 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4685 LazyUint8Array.prototype.setDataGetter = function(getter) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4686 this.getter = getter;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4687 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4688 LazyUint8Array.prototype.cacheLength = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4689 // Find length\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4690 var xhr = new XMLHttpRequest();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4691 xhr.open('HEAD', url, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4692 xhr.send(null);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4694 var datalength = Number(xhr.getResponseHeader(\"Content-length\"));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4695 var header;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4696 var hasByteServing = (header = xhr.getResponseHeader(\"Accept-Ranges\")) && header === \"bytes\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4697 var chunkSize = 1024*1024; // Chunk size in bytes\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4698 if (!hasByteServing) chunkSize = datalength;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4699 // Function to get a range from the remote URL.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4700 var doXHR = (function(from, to) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4701 if (from > to) throw new Error(\"invalid range (\" + from + \", \" + to + \") or no bytes requested!\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4702 if (to > datalength-1) throw new Error(\"only \" + datalength + \" bytes available! programmer error!\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4703 // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4704 var xhr = new XMLHttpRequest();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4705 xhr.open('GET', url, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4706 if (datalength !== chunkSize) xhr.setRequestHeader(\"Range\", \"bytes=\" + from + \"-\" + to);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4707 // Some hints to the browser that we want binary data.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4708 if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4709 if (xhr.overrideMimeType) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4710 xhr.overrideMimeType('text/plain; charset=x-user-defined');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4711 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4712 xhr.send(null);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4714 if (xhr.response !== undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4715 return new Uint8Array(xhr.response || []);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4716 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4717 return intArrayFromString(xhr.responseText || '', true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4718 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4719 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4720 var lazyArray = this;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4721 lazyArray.setDataGetter(function(chunkNum) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4722 var start = chunkNum * chunkSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4723 var end = (chunkNum+1) * chunkSize - 1; // including this byte\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4725 if (typeof(lazyArray.chunks[chunkNum]) === \"undefined\") {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4726 lazyArray.chunks[chunkNum] = doXHR(start, end);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4727 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4728 if (typeof(lazyArray.chunks[chunkNum]) === \"undefined\") throw new Error(\"doXHR failed!\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4729 return lazyArray.chunks[chunkNum];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4730 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4731 this._length = datalength;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4732 this._chunkSize = chunkSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4733 this.lengthKnown = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4734 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4735 var lazyArray = new LazyUint8Array();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4736 Object.defineProperty(lazyArray, \"length\", {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4737 get: function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4738 if(!this.lengthKnown) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4739 this.cacheLength();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4740 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4741 return this._length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4742 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4743 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4744 Object.defineProperty(lazyArray, \"chunkSize\", {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4745 get: function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4746 if(!this.lengthKnown) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4747 this.cacheLength();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4748 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4749 return this._chunkSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4750 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4751 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4752 var properties = { isDevice: false, contents: lazyArray };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4753 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4754 var properties = { isDevice: false, url: url };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4755 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4756 var node = FS.createFile(parent, name, properties, canRead, canWrite);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4759 // be its own thin LAZYFS proxying calls to MEMFS.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4760 if (properties.contents) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4761 node.contents = properties.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4762 } else if (properties.url) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4763 node.contents = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4764 node.url = properties.url;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4765 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4766 // override each stream op with one that tries to force load the lazy file first\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4767 var stream_ops = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4768 var keys = Object.keys(node.stream_ops);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4769 keys.forEach(function(key) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4770 var fn = node.stream_ops[key];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4771 stream_ops[key] = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4772 if (!FS.forceLoadFile(node)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4773 throw new FS.ErrnoError(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4774 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4775 return fn.apply(null, arguments);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4776 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4777 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4778 // use a custom read function\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4779 stream_ops.read = function(stream, buffer, offset, length, position) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4780 if (!FS.forceLoadFile(node)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4781 throw new FS.ErrnoError(ERRNO_CODES.EIO);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4782 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4783 var contents = stream.node.contents;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4784 var size = Math.min(contents.length - position, length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4785 if (contents.slice) { // normal array\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4786 for (var i = 0; i < size; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4787 buffer[offset + i] = contents[position + i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4788 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4789 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4790 for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4791 buffer[offset + i] = contents.get(position + i);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4792 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4793 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4794 return size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4795 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4796 node.stream_ops = stream_ops;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4797 return node;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4798 },createPreloadedFile:function (parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4799 Browser.init();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4800 // TODO we should allow people to just pass in a complete filename instead\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4801 // of parent and name being that we just join them anyways\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4802 var fullname = name ? PATH.resolve(PATH.join(parent, name)) : parent;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4803 function processData(byteArray) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4804 function finish(byteArray) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4805 if (!dontCreateFile) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4806 FS.createDataFile(parent, name, byteArray, canRead, canWrite, canOwn);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4807 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4808 if (onload) onload();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4809 removeRunDependency('cp ' + fullname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4810 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4811 var handled = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4812 Module['preloadPlugins'].forEach(function(plugin) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4813 if (handled) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4814 if (plugin['canHandle'](fullname)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4815 plugin['handle'](byteArray, fullname, finish, function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4816 if (onerror) onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4817 removeRunDependency('cp ' + fullname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4818 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4819 handled = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4820 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4821 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4822 if (!handled) finish(byteArray);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4823 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4824 addRunDependency('cp ' + fullname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4825 if (typeof url == 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4826 Browser.asyncLoad(url, function(byteArray) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4827 processData(byteArray);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4828 }, onerror);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4829 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4830 processData(url);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4831 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4832 },indexedDB:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4833 return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4834 },DB_NAME:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4835 return 'EM_FS_' + window.location.pathname;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4836 },DB_VERSION:20,DB_STORE_NAME:\"FILE_DATA\",saveFilesToDB:function (paths, onload, onerror) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4837 onload = onload || function(){};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4838 onerror = onerror || function(){};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4839 var indexedDB = FS.indexedDB();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4840 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4841 var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4842 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4843 return onerror(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4844 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4845 openRequest.onupgradeneeded = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4846 console.log('creating db');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4847 var db = openRequest.result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4848 db.createObjectStore(FS.DB_STORE_NAME);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4849 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4850 openRequest.onsuccess = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4851 var db = openRequest.result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4852 var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4853 var files = transaction.objectStore(FS.DB_STORE_NAME);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4854 var ok = 0, fail = 0, total = paths.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4855 function finish() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4856 if (fail == 0) onload(); else onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4857 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4858 paths.forEach(function(path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4859 var putRequest = files.put(FS.analyzePath(path).object.contents, path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4860 putRequest.onsuccess = function() { ok++; if (ok + fail == total) finish() };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4861 putRequest.onerror = function() { fail++; if (ok + fail == total) finish() };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4862 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4863 transaction.onerror = onerror;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4864 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4865 openRequest.onerror = onerror;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4866 },loadFilesFromDB:function (paths, onload, onerror) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4867 onload = onload || function(){};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4868 onerror = onerror || function(){};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4869 var indexedDB = FS.indexedDB();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4870 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4871 var openRequest = indexedDB.open(FS.DB_NAME(), FS.DB_VERSION);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4872 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4873 return onerror(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4874 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4875 openRequest.onupgradeneeded = onerror; // no database to load from\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4876 openRequest.onsuccess = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4877 var db = openRequest.result;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4878 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4879 var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4880 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4881 onerror(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4882 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4883 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4884 var files = transaction.objectStore(FS.DB_STORE_NAME);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4885 var ok = 0, fail = 0, total = paths.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4886 function finish() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4887 if (fail == 0) onload(); else onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4888 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4889 paths.forEach(function(path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4890 var getRequest = files.get(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4891 getRequest.onsuccess = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4892 if (FS.analyzePath(path).exists) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4893 FS.unlink(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4894 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4895 FS.createDataFile(PATH.dirname(path), PATH.basename(path), getRequest.result, true, true, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4896 ok++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4897 if (ok + fail == total) finish();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4898 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4899 getRequest.onerror = function() { fail++; if (ok + fail == total) finish() };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4900 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4901 transaction.onerror = onerror;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4902 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4903 openRequest.onerror = onerror;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4904 }};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4905 var SOCKFS={mount:function (mount) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4906 return FS.createNode(null, '/', 0040000 | 0777, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4907 },nextname:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4908 if (!SOCKFS.nextname.current) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4909 SOCKFS.nextname.current = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4910 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4911 return 'socket[' + (SOCKFS.nextname.current++) + ']';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4912 },createSocket:function (family, type, protocol) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4913 var streaming = type == 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4914 if (protocol) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4915 assert(streaming == (protocol == 6)); // if SOCK_STREAM, must be tcp\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4916 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4917 // create our internal socket structure\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4918 var sock = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4919 family: family,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4920 type: type,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4921 protocol: protocol,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4922 server: null,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4923 peers: {},\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4924 pending: [],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4925 recv_queue: [],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4926 sock_ops: SOCKFS.websocket_sock_ops\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4927 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4928 // create the filesystem node to store the socket structure\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4929 var name = SOCKFS.nextname();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4930 var node = FS.createNode(SOCKFS.root, name, 0140000, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4931 node.sock = sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4932 // and the wrapping stream that enables library functions such\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4933 // as read and write to indirectly interact with the socket\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4934 var stream = FS.createStream({\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4935 path: name,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4936 node: node,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4937 flags: FS.modeStringToFlags('r+'),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4938 seekable: false,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4939 stream_ops: SOCKFS.stream_ops\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4940 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4941 // map the new stream to the socket structure (sockets have a 1:1\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4942 // relationship with a stream)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4943 sock.stream = stream;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4944 return sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4945 },getSocket:function (fd) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4946 var stream = FS.getStream(fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4947 if (!stream || !FS.isSocket(stream.node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4948 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4949 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4950 return stream.node.sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4951 },stream_ops:{poll:function (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4952 var sock = stream.node.sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4953 return sock.sock_ops.poll(sock);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4954 },ioctl:function (stream, request, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4955 var sock = stream.node.sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4956 return sock.sock_ops.ioctl(sock, request, varargs);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4957 },read:function (stream, buffer, offset, length, position /* ignored */) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4958 var sock = stream.node.sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4959 var msg = sock.sock_ops.recvmsg(sock, length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4960 if (!msg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4961 // socket is closed\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4962 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4963 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4964 buffer.set(msg.buffer, offset);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4965 return msg.buffer.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4966 },write:function (stream, buffer, offset, length, position /* ignored */) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4967 var sock = stream.node.sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4968 return sock.sock_ops.sendmsg(sock, buffer, offset, length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4969 },close:function (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4970 var sock = stream.node.sock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4971 sock.sock_ops.close(sock);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4972 }},websocket_sock_ops:{createPeer:function (sock, addr, port) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4973 var ws;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4974 if (typeof addr === 'object') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4975 ws = addr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4976 addr = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4977 port = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4978 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4979 if (ws) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4980 // for sockets that've already connected (e.g. we're the server)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4981 // we can inspect the _socket property for the address\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4982 if (ws._socket) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4983 addr = ws._socket.remoteAddress;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4984 port = ws._socket.remotePort;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4985 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4986 // if we're just now initializing a connection to the remote,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4987 // inspect the url property\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4988 else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4989 var result = /ws[s]?:\\/\\/([^:]+):(\\d+)/.exec(ws.url);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4990 if (!result) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4991 throw new Error('WebSocket URL must be in the format ws(s)://address:port');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4992 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4993 addr = result[1];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4994 port = parseInt(result[2], 10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4995 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4996 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4997 // create the actual websocket object and connect\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4998 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4999 var url = 'ws://' + addr + ':' + port;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5000 // the node ws library API is slightly different than the browser's\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5001 var opts = ENVIRONMENT_IS_NODE ? {} : ['binary'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5002 ws = new WebSocket(url, opts);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5003 ws.binaryType = 'arraybuffer';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5004 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5005 throw new FS.ErrnoError(ERRNO_CODES.EHOSTUNREACH);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5006 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5007 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5008 var peer = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5009 addr: addr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5010 port: port,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5011 socket: ws,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5012 dgram_send_queue: []\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5013 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5014 SOCKFS.websocket_sock_ops.addPeer(sock, peer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5015 SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5016 // if this is a bound dgram socket, send the port number first to allow\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5017 // us to override the ephemeral port reported to us by remotePort on the\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5018 // remote end.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5019 if (sock.type === 2 && typeof sock.sport !== 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5020 peer.dgram_send_queue.push(new Uint8Array([\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5021 255, 255, 255, 255,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5022 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5023 ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5024 ]));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5025 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5026 return peer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5027 },getPeer:function (sock, addr, port) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5028 return sock.peers[addr + ':' + port];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5029 },addPeer:function (sock, peer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5030 sock.peers[peer.addr + ':' + peer.port] = peer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5031 },removePeer:function (sock, peer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5032 delete sock.peers[peer.addr + ':' + peer.port];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5033 },handlePeerEvents:function (sock, peer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5034 var first = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5035 var handleOpen = function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5036 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5037 var queued = peer.dgram_send_queue.shift();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5038 while (queued) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5039 peer.socket.send(queued);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5040 queued = peer.dgram_send_queue.shift();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5041 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5042 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5044 // lied and said this data was sent. shut it down.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5045 peer.socket.close();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5046 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5047 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5048 var handleMessage = function(data) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5049 assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5050 data = new Uint8Array(data); // make a typed array view on the array buffer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5051 // if this is the port message, override the peer's port with it\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5052 var wasfirst = first;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5053 first = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5054 if (wasfirst &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5055 data.length === 10 &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5056 data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5058 // update the peer's port and it's key in the peer map\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5059 var newport = ((data[8] << 8) | data[9]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5060 SOCKFS.websocket_sock_ops.removePeer(sock, peer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5061 peer.port = newport;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5062 SOCKFS.websocket_sock_ops.addPeer(sock, peer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5063 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5064 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5065 sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5066 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5067 if (ENVIRONMENT_IS_NODE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5068 peer.socket.on('open', handleOpen);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5069 peer.socket.on('message', function(data, flags) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5070 if (!flags.binary) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5071 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5072 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5073 handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5074 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5075 peer.socket.on('error', function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5076 // don't throw\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5077 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5078 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5079 peer.socket.onopen = handleOpen;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5080 peer.socket.onmessage = function(event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5081 handleMessage(event.data);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5082 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5083 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5084 },poll:function (sock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5085 if (sock.type === 1 && sock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5086 // listen sockets should only say they're available for reading\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5087 // if there are pending clients.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5088 return sock.pending.length ? (0 /* XXX missing C define POLLRDNORM */ | 1) : 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5089 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5090 var mask = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5092 SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5093 null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5094 if (sock.recv_queue.length ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5095 !dest || // connection-less sockets are always ready to read\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5096 (dest && dest.socket.readyState === dest.socket.CLOSING) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5097 (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5098 mask |= (0 /* XXX missing C define POLLRDNORM */ | 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5099 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5100 if (!dest || // connection-less sockets are always ready to write\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5101 (dest && dest.socket.readyState === dest.socket.OPEN)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5102 mask |= 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5103 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5104 if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5105 (dest && dest.socket.readyState === dest.socket.CLOSED)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5106 mask |= 16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5107 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5108 return mask;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5109 },ioctl:function (sock, request, arg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5110 switch (request) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5111 case 1:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5112 var bytes = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5113 if (sock.recv_queue.length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5114 bytes = sock.recv_queue[0].data.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5115 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5116 HEAP32[((arg)>>2)]=bytes;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5117 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5118 default:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5119 return ERRNO_CODES.EINVAL;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5120 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5121 },close:function (sock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5122 // if we've spawned a listen server, close it\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5123 if (sock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5124 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5125 sock.server.close();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5126 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5127 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5128 sock.server = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5129 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5130 // close any peer connections\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5131 var peers = Object.keys(sock.peers);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5132 for (var i = 0; i < peers.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5133 var peer = sock.peers[peers[i]];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5134 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5135 peer.socket.close();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5136 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5137 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5138 SOCKFS.websocket_sock_ops.removePeer(sock, peer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5139 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5140 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5141 },bind:function (sock, addr, port) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5142 if (typeof sock.saddr !== 'undefined' || typeof sock.sport !== 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5143 throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already bound\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5144 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5145 sock.saddr = addr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5146 sock.sport = port || _mkport();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5147 // in order to emulate dgram sockets, we need to launch a listen server when\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5148 // binding on a connection-less socket\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5149 // note: this is only required on the server side\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5150 if (sock.type === 2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5151 // close the existing server if it exists\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5152 if (sock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5153 sock.server.close();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5154 sock.server = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5155 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5156 // swallow error operation not supported error that occurs when binding in the\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5157 // browser where this isn't supported\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5158 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5159 sock.sock_ops.listen(sock, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5160 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5161 if (!(e instanceof FS.ErrnoError)) throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5162 if (e.errno !== ERRNO_CODES.EOPNOTSUPP) throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5163 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5164 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5165 },connect:function (sock, addr, port) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5166 if (sock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5167 throw new FS.ErrnoError(ERRNO_CODS.EOPNOTSUPP);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5168 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5169 // TODO autobind\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5170 // if (!sock.addr && sock.type == 2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5171 // }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5172 // early out if we're already connected / in the middle of connecting\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5173 if (typeof sock.daddr !== 'undefined' && typeof sock.dport !== 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5174 var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5175 if (dest) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5176 if (dest.socket.readyState === dest.socket.CONNECTING) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5177 throw new FS.ErrnoError(ERRNO_CODES.EALREADY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5178 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5179 throw new FS.ErrnoError(ERRNO_CODES.EISCONN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5180 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5181 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5182 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5183 // add the socket to our peer list and set our\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5184 // destination address / port to match\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5185 var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5186 sock.daddr = peer.addr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5187 sock.dport = peer.port;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5188 // always \"fail\" in non-blocking mode\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5189 throw new FS.ErrnoError(ERRNO_CODES.EINPROGRESS);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5190 },listen:function (sock, backlog) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5191 if (!ENVIRONMENT_IS_NODE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5192 throw new FS.ErrnoError(ERRNO_CODES.EOPNOTSUPP);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5193 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5194 if (sock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5195 throw new FS.ErrnoError(ERRNO_CODES.EINVAL); // already listening\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5196 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5197 var WebSocketServer = require('ws').Server;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5198 var host = sock.saddr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5199 sock.server = new WebSocketServer({\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5200 host: host,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5201 port: sock.sport\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5202 // TODO support backlog\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5203 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5204 sock.server.on('connection', function(ws) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5205 if (sock.type === 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5206 var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5207 // create a peer on the new socket\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5208 var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5209 newsock.daddr = peer.addr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5210 newsock.dport = peer.port;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5211 // push to queue for accept to pick up\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5212 sock.pending.push(newsock);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5213 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5214 // create a peer on the listen socket so calling sendto\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5215 // with the listen socket and an address will resolve\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5216 // to the correct client\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5217 SOCKFS.websocket_sock_ops.createPeer(sock, ws);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5218 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5219 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5220 sock.server.on('closed', function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5221 sock.server = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5222 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5223 sock.server.on('error', function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5224 // don't throw\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5225 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5226 },accept:function (listensock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5227 if (!listensock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5228 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5229 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5230 var newsock = listensock.pending.shift();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5231 newsock.stream.flags = listensock.stream.flags;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5232 return newsock;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5233 },getname:function (sock, peer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5234 var addr, port;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5235 if (peer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5236 if (sock.daddr === undefined || sock.dport === undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5237 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5238 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5239 addr = sock.daddr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5240 port = sock.dport;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5241 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5242 // TODO saddr and sport will be set for bind()'d UDP sockets, but what\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5243 // should we be returning for TCP sockets that've been connect()'d?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5244 addr = sock.saddr || 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5245 port = sock.sport || 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5246 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5247 return { addr: addr, port: port };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5248 },sendmsg:function (sock, buffer, offset, length, addr, port) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5249 if (sock.type === 2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5250 // connection-less sockets will honor the message address,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5251 // and otherwise fall back to the bound destination address\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5252 if (addr === undefined || port === undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5253 addr = sock.daddr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5254 port = sock.dport;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5255 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5256 // if there was no address to fall back to, error out\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5257 if (addr === undefined || port === undefined) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5258 throw new FS.ErrnoError(ERRNO_CODES.EDESTADDRREQ);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5259 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5260 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5261 // connection-based sockets will only use the bound\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5262 addr = sock.daddr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5263 port = sock.dport;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5264 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5265 // find the peer for the destination address\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5266 var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5267 // early out if not connected with a connection-based socket\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5268 if (sock.type === 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5269 if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5270 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5271 } else if (dest.socket.readyState === dest.socket.CONNECTING) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5272 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5273 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5274 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5275 // create a copy of the incoming data to send, as the WebSocket API\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5276 // doesn't work entirely with an ArrayBufferView, it'll just send\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5277 // the entire underlying buffer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5278 var data;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5279 if (buffer instanceof Array || buffer instanceof ArrayBuffer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5280 data = buffer.slice(offset, offset + length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5281 } else { // ArrayBufferView\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5282 data = buffer.buffer.slice(buffer.byteOffset + offset, buffer.byteOffset + offset + length);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5283 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5284 // if we're emulating a connection-less dgram socket and don't have\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5285 // a cached connection, queue the buffer to send upon connect and\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5286 // lie, saying the data was sent now.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5287 if (sock.type === 2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5288 if (!dest || dest.socket.readyState !== dest.socket.OPEN) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5289 // if we're not connected, open a new connection\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5290 if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5291 dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5292 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5293 dest.dgram_send_queue.push(data);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5294 return length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5295 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5296 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5297 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5298 // send the actual data\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5299 dest.socket.send(data);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5300 return length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5301 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5302 throw new FS.ErrnoError(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5303 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5304 },recvmsg:function (sock, length) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5305 // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5306 if (sock.type === 1 && sock.server) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5307 // tcp servers should not be recv()'ing on the listen socket\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5308 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5309 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5310 var queued = sock.recv_queue.shift();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5311 if (!queued) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5312 if (sock.type === 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5313 var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5314 if (!dest) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5315 // if we have a destination address but are not connected, error out\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5316 throw new FS.ErrnoError(ERRNO_CODES.ENOTCONN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5317 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5318 else if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5319 // return null if the socket has closed\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5320 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5321 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5322 else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5323 // else, our socket is in a valid state but truly has nothing available\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5324 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5325 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5326 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5327 throw new FS.ErrnoError(ERRNO_CODES.EAGAIN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5328 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5329 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5330 // queued.data will be an ArrayBuffer if it's unadulterated, but if it's\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5331 // requeued TCP data it'll be an ArrayBufferView\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5332 var queuedLength = queued.data.byteLength || queued.data.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5333 var queuedOffset = queued.data.byteOffset || 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5334 var queuedBuffer = queued.data.buffer || queued.data;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5335 var bytesRead = Math.min(length, queuedLength);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5336 var res = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5337 buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5338 addr: queued.addr,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5339 port: queued.port\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5340 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5341 // push back any unread data for TCP connections\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5342 if (sock.type === 1 && bytesRead < queuedLength) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5343 var bytesRemaining = queuedLength - bytesRead;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5344 queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5345 sock.recv_queue.unshift(queued);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5346 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5347 return res;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5348 }}};function _send(fd, buf, len, flags) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5349 var sock = SOCKFS.getSocket(fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5350 if (!sock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5351 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5352 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5353 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5354 // TODO honor flags\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5355 return _write(fd, buf, len);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5356 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5357 function _pwrite(fildes, buf, nbyte, offset) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5358 // ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5359 // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5360 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5361 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5362 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5363 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5364 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5365 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5366 var slab = HEAP8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5367 return FS.write(stream, slab, buf, nbyte, offset);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5368 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5369 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5370 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5371 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5372 }function _write(fildes, buf, nbyte) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5373 // ssize_t write(int fildes, const void *buf, size_t nbyte);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5374 // http://pubs.opengroup.org/onlinepubs/000095399/functions/write.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5375 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5376 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5377 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5378 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5379 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5380 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5381 var slab = HEAP8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5382 return FS.write(stream, slab, buf, nbyte);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5383 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5384 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5385 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5386 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5387 }function _fputc(c, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5388 // int fputc(int c, FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5389 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputc.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5390 var chr = unSign(c & 0xFF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5391 HEAP8[((_fputc.ret)|0)]=chr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5392 var ret = _write(stream, _fputc.ret, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5393 if (ret == -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5394 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5395 if (streamObj) streamObj.error = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5396 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5397 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5398 return chr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5399 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5400 }function _putchar(c) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5401 // int putchar(int c);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5402 // http://pubs.opengroup.org/onlinepubs/000095399/functions/putchar.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5403 return _fputc(c, HEAP32[((_stdout)>>2)]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5404 } \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5405 Module[\"_saveSetjmp\"] = _saveSetjmp;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5406 Module[\"_testSetjmp\"] = _testSetjmp;function _longjmp(env, value) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5407 asm['setThrew'](env, value || 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5408 throw 'longjmp';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5409 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5410 function __exit(status) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5411 // void _exit(int status);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5412 // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5413 Module.print('exit(' + status + ') called');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5414 Module['exit'](status);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5415 }function _exit(status) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5416 __exit(status);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5417 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5418 var _setjmp=undefined;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5419 Module[\"_memset\"] = _memset;var _llvm_memset_p0i8_i64=_memset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5420 function _iscntrl(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5421 return (0 <= chr && chr <= 0x1F) || chr === 0x7F;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5422 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5423 function _isspace(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5424 return (chr == 32) || (chr >= 9 && chr <= 13);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5425 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5426 function _isalpha(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5427 return (chr >= 97 && chr <= 122) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5428 (chr >= 65 && chr <= 90);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5429 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5430 function _isalnum(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5431 return (chr >= 48 && chr <= 57) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5432 (chr >= 97 && chr <= 122) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5433 (chr >= 65 && chr <= 90);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5434 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5435 function _localeconv() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5436 // %struct.timeval = type { char* decimal point, other stuff... }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5437 // var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5438 var me = _localeconv;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5439 if (!me.ret) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5441 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5442 return me.ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5443 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5444 function _memchr(ptr, chr, num) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5445 chr = unSign(chr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5446 for (var i = 0; i < num; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5447 if (HEAP8[(ptr)] == chr) return ptr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5448 ptr++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5449 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5450 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5451 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5452 function __parseInt(str, endptr, base, min, max, bits, unsign) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5453 // Skip space.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5454 while (_isspace(HEAP8[(str)])) str++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5455 // Check for a plus/minus sign.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5456 var multiplier = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5457 if (HEAP8[(str)] == 45) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5458 multiplier = -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5459 str++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5460 } else if (HEAP8[(str)] == 43) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5461 str++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5462 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5463 // Find base.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5464 var finalBase = base;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5465 if (!finalBase) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5466 if (HEAP8[(str)] == 48) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5467 if (HEAP8[((str+1)|0)] == 120 ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5468 HEAP8[((str+1)|0)] == 88) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5469 finalBase = 16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5470 str += 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5471 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5472 finalBase = 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5473 str++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5474 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5475 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5476 } else if (finalBase==16) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5477 if (HEAP8[(str)] == 48) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5478 if (HEAP8[((str+1)|0)] == 120 ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5479 HEAP8[((str+1)|0)] == 88) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5480 str += 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5481 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5482 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5483 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5484 if (!finalBase) finalBase = 10;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5485 // Get digits.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5486 var chr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5487 var ret = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5488 while ((chr = HEAP8[(str)]) != 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5489 var digit = parseInt(String.fromCharCode(chr), finalBase);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5490 if (isNaN(digit)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5491 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5492 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5493 ret = ret * finalBase + digit;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5494 str++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5495 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5496 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5497 // Apply sign.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5498 ret *= multiplier;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5499 // Set end pointer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5500 if (endptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5501 HEAP32[((endptr)>>2)]=str\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5502 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5503 // Unsign if needed.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5504 if (unsign) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5505 if (Math.abs(ret) > max) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5506 ret = max;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5507 ___setErrNo(ERRNO_CODES.ERANGE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5508 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5509 ret = unSign(ret, bits);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5510 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5511 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5512 // Validate range.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5513 if (ret > max || ret < min) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5514 ret = ret > max ? max : min;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5515 ___setErrNo(ERRNO_CODES.ERANGE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5516 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5517 if (bits == 64) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5519 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5520 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5521 }function _strtoul(str, endptr, base) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5522 return __parseInt(str, endptr, base, 0, 4294967295, 32, true); // ULONG_MAX.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5523 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5524 function __reallyNegative(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5525 return x < 0 || (x === 0 && (1/x) === -Infinity);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5526 }function __formatString(format, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5527 var textIndex = format;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5528 var argIndex = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5529 function getNextArg(type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5530 // NOTE: Explicitly ignoring type safety. Otherwise this fails:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5531 // int x = 4; printf(\"%c\\n\", (char)x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5532 var ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5533 if (type === 'double') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5534 ret = HEAPF64[(((varargs)+(argIndex))>>3)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5535 } else if (type == 'i64') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5536 ret = [HEAP32[(((varargs)+(argIndex))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5537 HEAP32[(((varargs)+(argIndex+8))>>2)]];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5538 argIndex += 8; // each 32-bit chunk is in a 64-bit block\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5539 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5540 type = 'i32'; // varargs are always i32, i64, or double\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5541 ret = HEAP32[(((varargs)+(argIndex))>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5542 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5543 argIndex += Math.max(Runtime.getNativeFieldSize(type), Runtime.getAlignSize(type, null, true));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5544 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5545 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5546 var ret = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5547 var curr, next, currArg;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5548 while(1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5549 var startTextIndex = textIndex;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5550 curr = HEAP8[(textIndex)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5551 if (curr === 0) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5552 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5553 if (curr == 37) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5554 // Handle flags.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5555 var flagAlwaysSigned = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5556 var flagLeftAlign = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5557 var flagAlternative = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5558 var flagZeroPad = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5559 flagsLoop: while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5560 switch (next) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5561 case 43:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5562 flagAlwaysSigned = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5563 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5564 case 45:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5565 flagLeftAlign = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5566 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5567 case 35:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5568 flagAlternative = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5569 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5570 case 48:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5571 if (flagZeroPad) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5572 break flagsLoop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5573 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5574 flagZeroPad = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5575 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5576 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5577 default:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5578 break flagsLoop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5579 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5580 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5581 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5582 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5583 // Handle width.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5584 var width = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5585 if (next == 42) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5586 width = getNextArg('i32');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5587 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5588 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5589 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5590 while (next >= 48 && next <= 57) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5591 width = width * 10 + (next - 48);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5592 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5593 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5594 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5595 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5596 // Handle precision.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5597 var precisionSet = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5598 if (next == 46) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5599 var precision = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5600 precisionSet = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5601 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5602 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5603 if (next == 42) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5604 precision = getNextArg('i32');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5605 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5606 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5607 while(1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5608 var precisionChr = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5609 if (precisionChr < 48 ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5610 precisionChr > 57) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5611 precision = precision * 10 + (precisionChr - 48);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5612 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5613 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5614 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5615 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5616 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5617 var precision = 6; // Standard default.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5618 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5619 // Handle integer sizes. WARNING: These assume a 32-bit architecture!\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5620 var argSize;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5621 switch (String.fromCharCode(next)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5622 case 'h':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5623 var nextNext = HEAP8[((textIndex+2)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5624 if (nextNext == 104) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5625 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5626 argSize = 1; // char (actually i32 in varargs)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5627 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5628 argSize = 2; // short (actually i32 in varargs)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5629 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5630 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5631 case 'l':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5632 var nextNext = HEAP8[((textIndex+2)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5633 if (nextNext == 108) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5634 textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5635 argSize = 8; // long long\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5636 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5637 argSize = 4; // long\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5638 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5639 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5640 case 'L': // long long\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5641 case 'q': // int64_t\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5642 case 'j': // intmax_t\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5643 argSize = 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5644 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5645 case 'z': // size_t\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5646 case 't': // ptrdiff_t\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5647 case 'I': // signed ptrdiff_t or unsigned size_t\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5648 argSize = 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5649 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5650 default:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5651 argSize = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5652 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5653 if (argSize) textIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5654 next = HEAP8[((textIndex+1)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5655 // Handle type specifier.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5656 switch (String.fromCharCode(next)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5657 case 'd': case 'i': case 'u': case 'o': case 'x': case 'X': case 'p': {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5658 // Integer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5659 var signed = next == 100 || next == 105;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5660 argSize = argSize || 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5661 var currArg = getNextArg('i' + (argSize * 8));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5662 var origArg = currArg;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5663 var argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5664 // Flatten i64-1 [low, high] into a (slightly rounded) double\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5665 if (argSize == 8) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5666 currArg = Runtime.makeBigInt(currArg[0], currArg[1], next == 117);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5667 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5668 // Truncate to requested size.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5669 if (argSize <= 4) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5670 var limit = Math.pow(256, argSize) - 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5671 currArg = (signed ? reSign : unSign)(currArg & limit, argSize * 8);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5672 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5673 // Format the number.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5674 var currAbsArg = Math.abs(currArg);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5675 var prefix = '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5676 if (next == 100 || next == 105) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5677 if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], null); else\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5678 argText = reSign(currArg, 8 * argSize, 1).toString(10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5679 } else if (next == 117) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5680 if (argSize == 8 && i64Math) argText = i64Math.stringify(origArg[0], origArg[1], true); else\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5681 argText = unSign(currArg, 8 * argSize, 1).toString(10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5682 currArg = Math.abs(currArg);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5683 } else if (next == 111) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5684 argText = (flagAlternative ? '0' : '') + currAbsArg.toString(8);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5685 } else if (next == 120 || next == 88) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5686 prefix = (flagAlternative && currArg != 0) ? '0x' : '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5687 if (argSize == 8 && i64Math) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5688 if (origArg[1]) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5689 argText = (origArg[1]>>>0).toString(16);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5690 var lower = (origArg[0]>>>0).toString(16);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5691 while (lower.length < 8) lower = '0' + lower;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5692 argText += lower;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5693 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5694 argText = (origArg[0]>>>0).toString(16);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5695 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5696 } else\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5697 if (currArg < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5698 // Represent negative numbers in hex as 2's complement.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5699 currArg = -currArg;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5700 argText = (currAbsArg - 1).toString(16);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5701 var buffer = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5702 for (var i = 0; i < argText.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5703 buffer.push((0xF - parseInt(argText[i], 16)).toString(16));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5704 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5705 argText = buffer.join('');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5706 while (argText.length < argSize * 2) argText = 'f' + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5707 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5708 argText = currAbsArg.toString(16);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5709 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5710 if (next == 88) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5711 prefix = prefix.toUpperCase();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5712 argText = argText.toUpperCase();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5713 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5714 } else if (next == 112) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5715 if (currAbsArg === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5716 argText = '(nil)';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5717 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5718 prefix = '0x';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5719 argText = currAbsArg.toString(16);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5720 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5721 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5722 if (precisionSet) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5723 while (argText.length < precision) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5724 argText = '0' + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5725 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5726 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5727 // Add sign if needed\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5728 if (flagAlwaysSigned) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5729 if (currArg < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5730 prefix = '-' + prefix;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5731 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5732 prefix = '+' + prefix;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5733 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5734 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5735 // Add padding.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5736 while (prefix.length + argText.length < width) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5737 if (flagLeftAlign) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5738 argText += ' ';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5739 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5740 if (flagZeroPad) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5741 argText = '0' + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5742 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5743 prefix = ' ' + prefix;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5744 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5745 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5746 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5747 // Insert the result into the buffer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5748 argText = prefix + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5749 argText.split('').forEach(function(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5750 ret.push(chr.charCodeAt(0));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5751 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5752 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5753 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5754 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G': {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5755 // Float.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5756 var currArg = getNextArg('double');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5757 var argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5758 if (isNaN(currArg)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5759 argText = 'nan';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5760 flagZeroPad = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5761 } else if (!isFinite(currArg)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5762 argText = (currArg < 0 ? '-' : '') + 'inf';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5763 flagZeroPad = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5764 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5765 var isGeneral = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5766 var effectivePrecision = Math.min(precision, 20);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5767 // Convert g/G to f/F or e/E, as per:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5768 // http://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5769 if (next == 103 || next == 71) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5770 isGeneral = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5771 precision = precision || 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5772 var exponent = parseInt(currArg.toExponential(effectivePrecision).split('e')[1], 10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5773 if (precision > exponent && exponent >= -4) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5774 next = ((next == 103) ? 'f' : 'F').charCodeAt(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5775 precision -= exponent + 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5776 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5777 next = ((next == 103) ? 'e' : 'E').charCodeAt(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5778 precision--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5779 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5780 effectivePrecision = Math.min(precision, 20);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5781 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5782 if (next == 101 || next == 69) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5783 argText = currArg.toExponential(effectivePrecision);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5784 // Make sure the exponent has at least 2 digits.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5785 if (/[eE][-+]\\d$/.test(argText)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5786 argText = argText.slice(0, -1) + '0' + argText.slice(-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5787 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5788 } else if (next == 102 || next == 70) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5789 argText = currArg.toFixed(effectivePrecision);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5790 if (currArg === 0 && __reallyNegative(currArg)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5791 argText = '-' + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5792 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5793 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5794 var parts = argText.split('e');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5795 if (isGeneral && !flagAlternative) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5796 // Discard trailing zeros and periods.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5797 while (parts[0].length > 1 && parts[0].indexOf('.') != -1 &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5798 (parts[0].slice(-1) == '0' || parts[0].slice(-1) == '.')) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5799 parts[0] = parts[0].slice(0, -1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5800 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5801 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5802 // Make sure we have a period in alternative mode.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5803 if (flagAlternative && argText.indexOf('.') == -1) parts[0] += '.';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5804 // Zero pad until required precision.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5805 while (precision > effectivePrecision++) parts[0] += '0';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5806 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5807 argText = parts[0] + (parts.length > 1 ? 'e' + parts[1] : '');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5808 // Capitalize 'E' if needed.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5809 if (next == 69) argText = argText.toUpperCase();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5810 // Add sign.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5811 if (flagAlwaysSigned && currArg >= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5812 argText = '+' + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5813 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5814 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5815 // Add padding.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5816 while (argText.length < width) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5817 if (flagLeftAlign) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5818 argText += ' ';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5819 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5820 if (flagZeroPad && (argText[0] == '-' || argText[0] == '+')) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5821 argText = argText[0] + '0' + argText.slice(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5822 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5823 argText = (flagZeroPad ? '0' : ' ') + argText;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5824 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5825 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5826 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5827 // Adjust case.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5828 if (next < 97) argText = argText.toUpperCase();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5829 // Insert the result into the buffer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5830 argText.split('').forEach(function(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5831 ret.push(chr.charCodeAt(0));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5832 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5833 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5834 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5835 case 's': {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5836 // String.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5837 var arg = getNextArg('i8*');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5838 var argLength = arg ? _strlen(arg) : '(null)'.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5839 if (precisionSet) argLength = Math.min(argLength, precision);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5840 if (!flagLeftAlign) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5841 while (argLength < width--) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5842 ret.push(32);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5843 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5844 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5845 if (arg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5846 for (var i = 0; i < argLength; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5847 ret.push(HEAPU8[((arg++)|0)]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5848 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5849 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5850 ret = ret.concat(intArrayFromString('(null)'.substr(0, argLength), true));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5851 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5852 if (flagLeftAlign) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5853 while (argLength < width--) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5854 ret.push(32);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5855 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5856 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5857 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5858 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5859 case 'c': {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5860 // Character.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5861 if (flagLeftAlign) ret.push(getNextArg('i8'));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5862 while (--width > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5863 ret.push(32);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5864 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5865 if (!flagLeftAlign) ret.push(getNextArg('i8'));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5866 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5867 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5868 case 'n': {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5869 // Write the length written so far to the next parameter.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5870 var ptr = getNextArg('i32*');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5871 HEAP32[((ptr)>>2)]=ret.length\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5872 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5873 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5874 case '%': {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5875 // Literal percent sign.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5876 ret.push(curr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5877 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5878 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5879 default: {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5880 // Unknown specifiers remain untouched.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5881 for (var i = startTextIndex; i < textIndex + 2; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5882 ret.push(HEAP8[(i)]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5883 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5884 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5885 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5886 textIndex += 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5887 // TODO: Support a/A (hex float) and m (last error) specifiers.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5888 // TODO: Support %1${specifier} for arg selection.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5889 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5890 ret.push(curr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5891 textIndex += 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5892 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5893 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5894 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5895 }function _snprintf(s, n, format, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5896 // int snprintf(char *restrict s, size_t n, const char *restrict format, ...);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5897 // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5898 var result = __formatString(format, varargs);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5899 var limit = (n === undefined) ? result.length\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5900 : Math.min(result.length, Math.max(n - 1, 0));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5901 if (s < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5902 s = -s;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5903 var buf = _malloc(limit+1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5904 HEAP32[((s)>>2)]=buf;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5905 s = buf;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5906 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5907 for (var i = 0; i < limit; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5908 HEAP8[(((s)+(i))|0)]=result[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5909 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5910 if (limit < n || (n === undefined)) HEAP8[(((s)+(i))|0)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5911 return result.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5912 }function _sprintf(s, format, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5913 // int sprintf(char *restrict s, const char *restrict format, ...);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5914 // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5915 return _snprintf(s, undefined, format, varargs);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5916 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5917 Module[\"_strncpy\"] = _strncpy;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5918 Module[\"_strcat\"] = _strcat;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5919 function _strcspn(pstr, pset) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5920 var str = pstr, set, strcurr, setcurr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5921 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5922 strcurr = HEAP8[(str)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5923 if (!strcurr) return str - pstr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5924 set = pset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5925 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5926 setcurr = HEAP8[(set)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5927 if (!setcurr || setcurr == strcurr) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5928 set++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5929 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5930 if (setcurr) return str - pstr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5931 str++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5932 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5933 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5934 function _strncat(pdest, psrc, num) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5935 var len = _strlen(pdest);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5936 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5937 while(1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5938 HEAP8[((pdest+len+i)|0)]=HEAP8[((psrc+i)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5939 if (HEAP8[(((pdest)+(len+i))|0)] == 0) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5940 i ++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5941 if (i == num) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5942 HEAP8[(((pdest)+(len+i))|0)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5943 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5944 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5945 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5946 return pdest;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5947 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5948 var _llvm_memset_p0i8_i32=_memset;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5949 Module[\"_memcmp\"] = _memcmp;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5950 function _strncmp(px, py, n) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5951 var i = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5952 while (i < n) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5953 var x = HEAPU8[(((px)+(i))|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5954 var y = HEAPU8[(((py)+(i))|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5955 if (x == y && x == 0) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5956 if (x == 0) return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5957 if (y == 0) return 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5958 if (x == y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5959 i ++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5960 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5961 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5962 return x > y ? 1 : -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5963 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5964 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5965 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5966 }function _strcmp(px, py) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5967 return _strncmp(px, py, TOTAL_MEMORY);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5968 }var _strcoll=_strcmp;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5969 function _strstr(ptr1, ptr2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5970 var check = 0, start;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5971 do {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5972 if (!check) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5973 start = ptr1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5974 check = ptr2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5975 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5976 var curr1 = HEAP8[((ptr1++)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5977 var curr2 = HEAP8[((check++)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5978 if (curr2 == 0) return start;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5979 if (curr2 != curr1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5980 // rewind to one character after start, to find ez in eeez\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5981 ptr1 = start + 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5982 check = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5983 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5984 } while (curr1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5985 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5986 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5988 // int open(const char *path, int oflag, ...);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5989 // http://pubs.opengroup.org/onlinepubs/009695399/functions/open.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5990 var mode = HEAP32[((varargs)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5991 path = Pointer_stringify(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5992 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5993 var stream = FS.open(path, oflag, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5994 return stream.fd;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5995 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5996 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5997 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5998 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5999 }function _fopen(filename, mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6000 // FILE *fopen(const char *restrict filename, const char *restrict mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6001 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fopen.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6002 var flags;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6003 mode = Pointer_stringify(mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6004 if (mode[0] == 'r') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6005 if (mode.indexOf('+') != -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6006 flags = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6007 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6008 flags = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6009 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6010 } else if (mode[0] == 'w') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6011 if (mode.indexOf('+') != -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6012 flags = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6013 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6014 flags = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6015 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6016 flags |= 512;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6017 flags |= 1024;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6018 } else if (mode[0] == 'a') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6019 if (mode.indexOf('+') != -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6020 flags = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6021 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6022 flags = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6023 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6024 flags |= 512;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6025 flags |= 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6026 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6027 ___setErrNo(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6028 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6029 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6031 return (ret == -1) ? 0 : ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6032 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6033 function _recv(fd, buf, len, flags) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6034 var sock = SOCKFS.getSocket(fd);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6035 if (!sock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6036 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6037 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6038 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6039 // TODO honor flags\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6040 return _read(fd, buf, len);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6041 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6042 function _pread(fildes, buf, nbyte, offset) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6043 // ssize_t pread(int fildes, void *buf, size_t nbyte, off_t offset);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6044 // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6045 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6046 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6047 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6048 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6049 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6050 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6051 var slab = HEAP8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6052 return FS.read(stream, slab, buf, nbyte, offset);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6053 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6054 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6055 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6056 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6057 }function _read(fildes, buf, nbyte) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6058 // ssize_t read(int fildes, void *buf, size_t nbyte);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6059 // http://pubs.opengroup.org/onlinepubs/000095399/functions/read.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6060 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6061 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6062 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6063 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6064 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6065 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6066 var slab = HEAP8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6067 return FS.read(stream, slab, buf, nbyte);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6068 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6069 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6070 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6071 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6072 }function _fread(ptr, size, nitems, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6073 // size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6074 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fread.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6075 var bytesToRead = nitems * size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6076 if (bytesToRead == 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6077 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6078 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6079 var bytesRead = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6080 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6081 while (streamObj.ungotten.length && bytesToRead > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6082 HEAP8[((ptr++)|0)]=streamObj.ungotten.pop()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6083 bytesToRead--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6084 bytesRead++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6085 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6086 var err = _read(stream, ptr, bytesToRead);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6087 if (err == -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6088 if (streamObj) streamObj.error = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6089 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6090 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6091 bytesRead += err;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6092 if (bytesRead < bytesToRead) streamObj.eof = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6093 return Math.floor(bytesRead / size);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6094 }function _fgetc(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6095 // int fgetc(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6096 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fgetc.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6097 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6098 if (!streamObj) return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6099 if (streamObj.eof || streamObj.error) return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6100 var ret = _fread(_fgetc.ret, 1, 1, stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6101 if (ret == 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6102 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6103 } else if (ret == -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6104 streamObj.error = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6105 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6106 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6107 return HEAPU8[((_fgetc.ret)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6108 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6109 }var _getc=_fgetc;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6110 function _close(fildes) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6111 // int close(int fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6112 // http://pubs.opengroup.org/onlinepubs/000095399/functions/close.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6113 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6114 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6115 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6116 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6117 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6118 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6119 FS.close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6120 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6121 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6122 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6123 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6124 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6125 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6126 function _fsync(fildes) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6127 // int fsync(int fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6128 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fsync.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6129 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6130 if (stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6131 // We write directly to the file system, so there's nothing to do here.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6132 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6133 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6134 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6135 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6136 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6137 }function _fclose(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6138 // int fclose(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6139 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fclose.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6140 _fsync(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6141 return _close(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6142 }function _freopen(filename, mode, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6143 // FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6144 // http://pubs.opengroup.org/onlinepubs/000095399/functions/freopen.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6145 if (!filename) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6146 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6147 if (!streamObj) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6148 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6149 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6150 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6151 if (_freopen.buffer) _free(_freopen.buffer);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6152 filename = intArrayFromString(streamObj.path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6153 filename = allocate(filename, 'i8', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6154 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6155 _fclose(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6156 return _fopen(filename, mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6157 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6158 function _ungetc(c, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6159 // int ungetc(int c, FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6160 // http://pubs.opengroup.org/onlinepubs/000095399/functions/ungetc.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6161 stream = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6162 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6163 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6164 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6165 if (c === -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6166 // do nothing for EOF character\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6167 return c;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6168 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6169 c = unSign(c & 0xFF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6170 stream.ungotten.push(c);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6171 stream.eof = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6172 return c;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6173 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6174 function _ferror(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6175 // int ferror(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6176 // http://pubs.opengroup.org/onlinepubs/000095399/functions/ferror.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6177 stream = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6178 return Number(stream && stream.error);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6179 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6180 function _fwrite(ptr, size, nitems, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6182 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fwrite.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6183 var bytesToWrite = nitems * size;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6184 if (bytesToWrite == 0) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6185 var bytesWritten = _write(stream, ptr, bytesToWrite);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6186 if (bytesWritten == -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6187 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6188 if (streamObj) streamObj.error = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6189 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6190 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6191 return Math.floor(bytesWritten / size);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6192 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6193 }function _fprintf(stream, format, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6194 // int fprintf(FILE *restrict stream, const char *restrict format, ...);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6195 // http://pubs.opengroup.org/onlinepubs/000095399/functions/printf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6196 var result = __formatString(format, varargs);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6197 var stack = Runtime.stackSave();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6198 var ret = _fwrite(allocate(result, 'i8', ALLOC_STACK), 1, result.length, stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6199 Runtime.stackRestore(stack);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6200 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6201 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6202 function _feof(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6203 // int feof(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6204 // http://pubs.opengroup.org/onlinepubs/000095399/functions/feof.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6205 stream = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6206 return Number(stream && stream.eof);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6207 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6208 function _strerror_r(errnum, strerrbuf, buflen) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6209 if (errnum in ERRNO_MESSAGES) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6210 if (ERRNO_MESSAGES[errnum].length > buflen - 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6211 return ___setErrNo(ERRNO_CODES.ERANGE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6212 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6213 var msg = ERRNO_MESSAGES[errnum];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6214 for (var i = 0; i < msg.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6215 HEAP8[(((strerrbuf)+(i))|0)]=msg.charCodeAt(i)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6216 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6217 HEAP8[(((strerrbuf)+(i))|0)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6218 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6219 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6220 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6221 return ___setErrNo(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6222 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6223 }function _strerror(errnum) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6224 if (!_strerror.buffer) _strerror.buffer = _malloc(256);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6225 _strerror_r(errnum, _strerror.buffer, 256);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6226 return _strerror.buffer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6227 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6228 function ___errno_location() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6229 return ___errno_state;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6230 }var ___errno=___errno_location;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6231 function _fputs(s, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6232 // int fputs(const char *restrict s, FILE *restrict stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6233 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fputs.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6234 return _write(stream, s, _strlen(s));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6235 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6236 function _fgets(s, n, stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6237 // char *fgets(char *restrict s, int n, FILE *restrict stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6238 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fgets.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6239 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6240 if (!streamObj) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6241 if (streamObj.error || streamObj.eof) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6242 var byte_;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6243 for (var i = 0; i < n - 1 && byte_ != 10; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6244 byte_ = _fgetc(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6245 if (byte_ == -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6246 if (streamObj.error || (streamObj.eof && i == 0)) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6247 else if (streamObj.eof) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6248 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6249 HEAP8[(((s)+(i))|0)]=byte_\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6250 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6251 HEAP8[(((s)+(i))|0)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6252 return s;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6253 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6254 function _tmpnam(s, dir, prefix) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6255 // char *tmpnam(char *s);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6256 // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpnam.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6257 // NOTE: The dir and prefix arguments are for internal use only.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6258 var folder = FS.findObject(dir || '/tmp');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6259 if (!folder || !folder.isFolder) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6260 dir = '/tmp';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6261 folder = FS.findObject(dir);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6262 if (!folder || !folder.isFolder) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6263 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6264 var name = prefix || 'file';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6265 do {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6266 name += String.fromCharCode(65 + Math.floor(Math.random() * 25));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6267 } while (name in folder.contents);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6268 var result = dir + '/' + name;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6269 if (!_tmpnam.buffer) _tmpnam.buffer = _malloc(256);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6270 if (!s) s = _tmpnam.buffer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6271 for (var i = 0; i < result.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6272 HEAP8[(((s)+(i))|0)]=result.charCodeAt(i);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6273 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6274 HEAP8[(((s)+(i))|0)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6275 return s;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6276 }function _tmpfile() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6277 // FILE *tmpfile(void);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6278 // http://pubs.opengroup.org/onlinepubs/000095399/functions/tmpfile.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6279 // TODO: Delete the created file on closing.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6280 if (_tmpfile.mode) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6281 _tmpfile.mode = allocate(intArrayFromString('w+'), 'i8', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6282 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6283 return _fopen(_tmpnam(0), _tmpfile.mode);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6284 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6285 function _clearerr(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6286 // void clearerr(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6287 // http://pubs.opengroup.org/onlinepubs/000095399/functions/clearerr.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6288 stream = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6289 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6290 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6291 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6292 stream.eof = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6293 stream.error = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6294 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6295 function __isFloat(text) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6296 return !!(/^[+-]?[0-9]*\\.?[0-9]+([eE][+-]?[0-9]+)?$/.exec(text));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6297 }function __scanString(format, get, unget, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6298 if (!__scanString.whiteSpace) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6299 __scanString.whiteSpace = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6300 __scanString.whiteSpace[32] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6301 __scanString.whiteSpace[9] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6302 __scanString.whiteSpace[10] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6303 __scanString.whiteSpace[11] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6304 __scanString.whiteSpace[12] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6305 __scanString.whiteSpace[13] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6306 __scanString.whiteSpace[' '] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6307 __scanString.whiteSpace['\\t'] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6308 __scanString.whiteSpace['\\n'] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6309 __scanString.whiteSpace['\\v'] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6310 __scanString.whiteSpace['\\f'] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6311 __scanString.whiteSpace['\\r'] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6312 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6313 // Supports %x, %4x, %d.%d, %lld, %s, %f, %lf.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6314 // TODO: Support all format specifiers.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6315 format = Pointer_stringify(format);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6316 var soFar = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6317 if (format.indexOf('%n') >= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6318 // need to track soFar\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6319 var _get = get;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6320 get = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6321 soFar++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6322 return _get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6323 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6324 var _unget = unget;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6325 unget = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6326 soFar--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6327 return _unget();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6328 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6329 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6330 var formatIndex = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6331 var argsi = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6332 var fields = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6333 var argIndex = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6334 var next;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6335 mainLoop:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6336 for (var formatIndex = 0; formatIndex < format.length;) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6337 if (format[formatIndex] === '%' && format[formatIndex+1] == 'n') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6338 var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6339 argIndex += Runtime.getAlignSize('void*', null, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6340 HEAP32[((argPtr)>>2)]=soFar;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6341 formatIndex += 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6342 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6343 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6344 if (format[formatIndex] === '%') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6345 var nextC = format.indexOf('c', formatIndex+1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6346 if (nextC > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6347 var maxx = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6348 if (nextC > formatIndex+1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6349 var sub = format.substring(formatIndex+1, nextC)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6350 maxx = parseInt(sub);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6351 if (maxx != sub) maxx = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6352 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6353 if (maxx) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6354 var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6355 argIndex += Runtime.getAlignSize('void*', null, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6356 fields++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6357 for (var i = 0; i < maxx; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6358 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6359 HEAP8[((argPtr++)|0)]=next;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6360 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6361 formatIndex += nextC - formatIndex + 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6362 continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6363 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6364 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6365 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6366 // remove whitespace\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6367 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6368 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6369 if (next == 0) return fields;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6370 if (!(next in __scanString.whiteSpace)) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6371 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6372 unget();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6373 if (format[formatIndex] === '%') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6374 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6375 var suppressAssignment = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6376 if (format[formatIndex] == '*') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6377 suppressAssignment = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6378 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6379 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6380 var maxSpecifierStart = formatIndex;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6381 while (format[formatIndex].charCodeAt(0) >= 48 &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6382 format[formatIndex].charCodeAt(0) <= 57) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6383 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6384 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6385 var max_;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6386 if (formatIndex != maxSpecifierStart) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6387 max_ = parseInt(format.slice(maxSpecifierStart, formatIndex), 10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6388 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6389 var long_ = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6390 var half = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6391 var longLong = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6392 if (format[formatIndex] == 'l') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6393 long_ = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6394 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6395 if (format[formatIndex] == 'l') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6396 longLong = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6397 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6398 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6399 } else if (format[formatIndex] == 'h') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6400 half = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6401 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6402 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6403 var type = format[formatIndex];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6404 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6405 var curr = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6406 var buffer = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6408 if (type == 'f' || type == 'e' || type == 'g' ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6409 type == 'F' || type == 'E' || type == 'G') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6410 var last = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6411 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6412 while (next > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6413 buffer.push(String.fromCharCode(next));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6414 if (__isFloat(buffer.join(''))) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6415 last = buffer.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6416 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6417 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6418 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6419 for (var i = 0; i < buffer.length - last + 1; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6420 unget();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6421 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6422 buffer.length = last;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6423 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6424 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6425 var first = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6426 while ((curr < max_ || isNaN(max_)) && next > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6427 if (!(next in __scanString.whiteSpace) && // stop on whitespace\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6428 (type == 's' ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6429 ((type === 'd' || type == 'u' || type == 'i') && ((next >= 48 && next <= 57) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6430 (first && next == 45))) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6431 ((type === 'x' || type === 'X') && (next >= 48 && next <= 57 ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6432 next >= 97 && next <= 102 ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6433 next >= 65 && next <= 70))) &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6435 buffer.push(String.fromCharCode(next));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6436 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6437 curr++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6438 first = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6439 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6440 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6441 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6442 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6443 unget();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6444 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6445 if (buffer.length === 0) return 0; // Failure.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6446 if (suppressAssignment) continue;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6447 var text = buffer.join('');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6448 var argPtr = HEAP32[(((varargs)+(argIndex))>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6449 argIndex += Runtime.getAlignSize('void*', null, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6450 switch (type) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6451 case 'd': case 'u': case 'i':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6452 if (half) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6453 HEAP16[((argPtr)>>1)]=parseInt(text, 10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6454 } else if (longLong) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6456 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6457 HEAP32[((argPtr)>>2)]=parseInt(text, 10);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6458 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6459 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6460 case 'X':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6461 case 'x':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6462 HEAP32[((argPtr)>>2)]=parseInt(text, 16)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6463 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6464 case 'F':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6465 case 'f':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6466 case 'E':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6467 case 'e':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6468 case 'G':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6469 case 'g':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6470 case 'E':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6471 // fallthrough intended\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6472 if (long_) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6473 HEAPF64[((argPtr)>>3)]=parseFloat(text)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6474 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6475 HEAPF32[((argPtr)>>2)]=parseFloat(text)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6476 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6477 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6478 case 's':\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6479 var array = intArrayFromString(text);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6480 for (var j = 0; j < array.length; j++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6481 HEAP8[(((argPtr)+(j))|0)]=array[j]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6482 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6483 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6484 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6485 fields++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6486 } else if (format[formatIndex] in __scanString.whiteSpace) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6487 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6488 while (next in __scanString.whiteSpace) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6489 if (next <= 0) break mainLoop; // End of input.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6490 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6491 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6492 unget(next);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6493 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6494 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6495 // Not a specifier.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6496 next = get();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6497 if (format[formatIndex].charCodeAt(0) !== next) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6498 unget(next);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6499 break mainLoop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6500 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6501 formatIndex++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6502 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6503 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6504 return fields;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6505 }function _fscanf(stream, format, varargs) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6506 // int fscanf(FILE *restrict stream, const char *restrict format, ... );\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6507 // http://pubs.opengroup.org/onlinepubs/000095399/functions/scanf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6508 var streamObj = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6509 if (!streamObj) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6510 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6511 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6512 var buffer = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6513 var get = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6514 var c = _fgetc(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6515 buffer.push(c);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6516 return c;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6517 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6518 var unget = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6519 _ungetc(buffer.pop(), stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6520 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6521 return __scanString(format, get, unget, varargs);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6522 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6523 function _setvbuf(stream, buf, type, size) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6524 // int setvbuf(FILE *restrict stream, char *restrict buf, int type, size_t size);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6525 // http://pubs.opengroup.org/onlinepubs/000095399/functions/setvbuf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6526 // TODO: Implement custom buffering.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6527 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6528 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6529 function _lseek(fildes, offset, whence) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6530 // off_t lseek(int fildes, off_t offset, int whence);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6531 // http://pubs.opengroup.org/onlinepubs/000095399/functions/lseek.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6532 var stream = FS.getStream(fildes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6533 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6534 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6535 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6536 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6537 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6538 return FS.llseek(stream, offset, whence);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6539 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6540 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6541 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6542 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6543 }function _fseek(stream, offset, whence) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6544 // int fseek(FILE *stream, long offset, int whence);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6545 // http://pubs.opengroup.org/onlinepubs/000095399/functions/fseek.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6546 var ret = _lseek(stream, offset, whence);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6547 if (ret == -1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6548 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6549 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6550 stream = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6551 stream.eof = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6552 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6553 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6554 function _ftell(stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6555 // long ftell(FILE *stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6556 // http://pubs.opengroup.org/onlinepubs/000095399/functions/ftell.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6557 stream = FS.getStream(stream);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6558 if (!stream) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6559 ___setErrNo(ERRNO_CODES.EBADF);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6560 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6561 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6562 if (FS.isChrdev(stream.node.mode)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6563 ___setErrNo(ERRNO_CODES.ESPIPE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6564 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6565 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6566 return stream.position;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6567 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6568 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6569 var _tan=Math.tan;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6570 function _sinh(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6571 var p = Math.pow(Math.E, x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6572 return (p - (1 / p)) / 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6573 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6574 function _cosh(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6575 var p = Math.pow(Math.E, x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6576 return (p + (1 / p)) / 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6577 }function _tanh(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6578 return _sinh(x) / _cosh(x);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6579 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6580 var _sqrt=Math.sqrt;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6581 var _sin=Math.sin;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6582 function _srand(seed) {}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6583 function _rand() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6584 return Math.floor(Math.random()*0x80000000);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6585 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6586 function _modf(x, intpart) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6587 HEAPF64[((intpart)>>3)]=Math.floor(x)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6588 return x - HEAPF64[((intpart)>>3)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6589 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6590 var _log=Math.log;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6591 function _log10(x) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6592 return Math.log(x) / Math.LN10;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6593 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6594 function _ldexp(x, exp_) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6595 return x * Math.pow(2, exp_);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6596 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6597 function _frexp(x, exp_addr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6598 var sig = 0, exp_ = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6599 if (x !== 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6600 var sign = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6601 if (x < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6602 x = -x;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6603 sign = -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6604 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6605 var raw_exp = Math.log(x)/Math.log(2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6606 exp_ = Math.ceil(raw_exp);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6607 if (exp_ === raw_exp) exp_ += 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6608 sig = sign*x/Math.pow(2, exp_);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6609 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6610 HEAP32[((exp_addr)>>2)]=exp_\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6611 return sig;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6612 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6613 function _fmod(x, y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6614 return x % y;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6615 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6616 var _exp=Math.exp;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6617 var _cos=Math.cos;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6618 var _ceil=Math.ceil;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6619 var _atan=Math.atan;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6620 var _atan2=Math.atan2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6621 var _asin=Math.asin;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6622 var _acos=Math.acos;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6623 var _fabs=Math.abs;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6624 function _time(ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6625 var ret = Math.floor(Date.now()/1000);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6626 if (ptr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6627 HEAP32[((ptr)>>2)]=ret\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6628 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6629 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6630 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6632 var __tzname=allocate(8, \"i32*\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6633 var __daylight=allocate(1, \"i32*\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6634 var __timezone=allocate(1, \"i32*\", ALLOC_STATIC);function _tzset() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6635 // TODO: Use (malleable) environment variables instead of system settings.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6636 if (_tzset.called) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6637 _tzset.called = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6638 HEAP32[((__timezone)>>2)]=-(new Date()).getTimezoneOffset() * 60\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6639 var winter = new Date(2000, 0, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6640 var summer = new Date(2000, 6, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6641 HEAP32[((__daylight)>>2)]=Number(winter.getTimezoneOffset() != summer.getTimezoneOffset())\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6644 var winterNamePtr = allocate(intArrayFromString(winterName), 'i8', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6645 var summerNamePtr = allocate(intArrayFromString(summerName), 'i8', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6646 HEAP32[((__tzname)>>2)]=winterNamePtr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6647 HEAP32[(((__tzname)+(4))>>2)]=summerNamePtr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6648 }function _mktime(tmPtr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6649 _tzset();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6650 var offsets = ___tm_struct_layout;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6651 var year = HEAP32[(((tmPtr)+(offsets.tm_year))>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6652 var timestamp = new Date(year >= 1900 ? year : year + 1900,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6653 HEAP32[(((tmPtr)+(offsets.tm_mon))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6654 HEAP32[(((tmPtr)+(offsets.tm_mday))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6655 HEAP32[(((tmPtr)+(offsets.tm_hour))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6656 HEAP32[(((tmPtr)+(offsets.tm_min))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6657 HEAP32[(((tmPtr)+(offsets.tm_sec))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6658 0).getTime() / 1000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6659 HEAP32[(((tmPtr)+(offsets.tm_wday))>>2)]=new Date(timestamp).getDay()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6660 var yday = Math.round((timestamp - (new Date(year, 0, 1)).getTime()) / (1000 * 60 * 60 * 24));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6661 HEAP32[(((tmPtr)+(offsets.tm_yday))>>2)]=yday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6662 return timestamp;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6663 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6664 function _setlocale(category, locale) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6665 if (!_setlocale.ret) _setlocale.ret = allocate([0], 'i8', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6666 return _setlocale.ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6667 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6668 function _rename(old_path, new_path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6669 // int rename(const char *old, const char *new);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6670 // http://pubs.opengroup.org/onlinepubs/000095399/functions/rename.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6671 old_path = Pointer_stringify(old_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6672 new_path = Pointer_stringify(new_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6673 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6674 FS.rename(old_path, new_path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6675 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6676 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6677 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6678 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6679 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6680 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6681 function _unlink(path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6682 // int unlink(const char *path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6683 // http://pubs.opengroup.org/onlinepubs/000095399/functions/unlink.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6684 path = Pointer_stringify(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6685 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6686 FS.unlink(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6687 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6688 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6689 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6690 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6691 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6692 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6693 function _rmdir(path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6694 // int rmdir(const char *path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6695 // http://pubs.opengroup.org/onlinepubs/000095399/functions/rmdir.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6696 path = Pointer_stringify(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6697 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6698 FS.rmdir(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6699 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6700 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6701 FS.handleFSError(e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6702 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6703 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6704 }function _remove(path) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6705 // int remove(const char *path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6706 // http://pubs.opengroup.org/onlinepubs/000095399/functions/remove.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6707 var ret = _unlink(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6708 if (ret == -1) ret = _rmdir(path);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6709 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6710 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6711 var _environ=allocate(1, \"i32*\", ALLOC_STATIC);var ___environ=_environ;function ___buildEnvironment(env) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6712 // WARNING: Arbitrary limit!\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6713 var MAX_ENV_VALUES = 64;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6714 var TOTAL_ENV_SIZE = 1024;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6715 // Statically allocate memory for the environment.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6716 var poolPtr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6717 var envPtr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6718 if (!___buildEnvironment.called) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6719 ___buildEnvironment.called = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6720 // Set default values. Use string keys for Closure Compiler compatibility.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6721 ENV['USER'] = 'root';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6722 ENV['PATH'] = '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6723 ENV['PWD'] = '/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6724 ENV['HOME'] = '/home/emscripten';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6725 ENV['LANG'] = 'en_US.UTF-8';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6726 ENV['_'] = './this.program';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6727 // Allocate memory.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6728 poolPtr = allocate(TOTAL_ENV_SIZE, 'i8', ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6729 envPtr = allocate(MAX_ENV_VALUES * 4,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6730 'i8*', ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6731 HEAP32[((envPtr)>>2)]=poolPtr\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6732 HEAP32[((_environ)>>2)]=envPtr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6733 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6734 envPtr = HEAP32[((_environ)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6735 poolPtr = HEAP32[((envPtr)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6736 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6737 // Collect key=value lines.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6738 var strings = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6739 var totalSize = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6740 for (var key in env) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6741 if (typeof env[key] === 'string') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6742 var line = key + '=' + env[key];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6743 strings.push(line);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6744 totalSize += line.length;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6745 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6746 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6747 if (totalSize > TOTAL_ENV_SIZE) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6748 throw new Error('Environment size exceeded TOTAL_ENV_SIZE!');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6749 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6750 // Make new.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6751 var ptrSize = 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6752 for (var i = 0; i < strings.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6753 var line = strings[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6754 for (var j = 0; j < line.length; j++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6755 HEAP8[(((poolPtr)+(j))|0)]=line.charCodeAt(j);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6756 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6757 HEAP8[(((poolPtr)+(j))|0)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6758 HEAP32[(((envPtr)+(i * ptrSize))>>2)]=poolPtr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6759 poolPtr += line.length + 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6760 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6761 HEAP32[(((envPtr)+(strings.length * ptrSize))>>2)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6762 }var ENV={};function _getenv(name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6763 // char *getenv(const char *name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6764 // http://pubs.opengroup.org/onlinepubs/009695399/functions/getenv.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6765 if (name === 0) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6766 name = Pointer_stringify(name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6767 if (!ENV.hasOwnProperty(name)) return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6768 if (_getenv.ret) _free(_getenv.ret);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6769 _getenv.ret = allocate(intArrayFromString(ENV[name]), 'i8', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6770 return _getenv.ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6771 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6772 function _system(command) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6773 // int system(const char *command);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6774 // http://pubs.opengroup.org/onlinepubs/000095399/functions/system.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6775 // Can't call external programs.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6776 ___setErrNo(ERRNO_CODES.EAGAIN);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6777 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6778 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6779 function _difftime(time1, time0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6780 return time1 - time0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6781 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6782 var ___tm_current=allocate(4*26, \"i8\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6783 var ___tm_timezone=allocate(intArrayFromString(\"GMT\"), \"i8\", ALLOC_STATIC);function _gmtime_r(time, tmPtr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6784 var date = new Date(HEAP32[((time)>>2)]*1000);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6785 var offsets = ___tm_struct_layout;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6786 HEAP32[(((tmPtr)+(offsets.tm_sec))>>2)]=date.getUTCSeconds()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6787 HEAP32[(((tmPtr)+(offsets.tm_min))>>2)]=date.getUTCMinutes()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6788 HEAP32[(((tmPtr)+(offsets.tm_hour))>>2)]=date.getUTCHours()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6789 HEAP32[(((tmPtr)+(offsets.tm_mday))>>2)]=date.getUTCDate()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6790 HEAP32[(((tmPtr)+(offsets.tm_mon))>>2)]=date.getUTCMonth()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6791 HEAP32[(((tmPtr)+(offsets.tm_year))>>2)]=date.getUTCFullYear()-1900\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6792 HEAP32[(((tmPtr)+(offsets.tm_wday))>>2)]=date.getUTCDay()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6793 HEAP32[(((tmPtr)+(offsets.tm_gmtoff))>>2)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6794 HEAP32[(((tmPtr)+(offsets.tm_isdst))>>2)]=0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6796 start.setUTCDate(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6797 start.setUTCMonth(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6798 start.setUTCHours(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6799 start.setUTCMinutes(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6800 start.setUTCSeconds(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6801 start.setUTCMilliseconds(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6802 var yday = Math.floor((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6803 HEAP32[(((tmPtr)+(offsets.tm_yday))>>2)]=yday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6804 HEAP32[(((tmPtr)+(offsets.tm_zone))>>2)]=___tm_timezone\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6805 return tmPtr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6806 }function _gmtime(time) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6807 return _gmtime_r(time, ___tm_current);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6808 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6809 function _localtime_r(time, tmPtr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6810 _tzset();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6811 var offsets = ___tm_struct_layout;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6812 var date = new Date(HEAP32[((time)>>2)]*1000);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6813 HEAP32[(((tmPtr)+(offsets.tm_sec))>>2)]=date.getSeconds()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6814 HEAP32[(((tmPtr)+(offsets.tm_min))>>2)]=date.getMinutes()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6815 HEAP32[(((tmPtr)+(offsets.tm_hour))>>2)]=date.getHours()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6816 HEAP32[(((tmPtr)+(offsets.tm_mday))>>2)]=date.getDate()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6817 HEAP32[(((tmPtr)+(offsets.tm_mon))>>2)]=date.getMonth()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6818 HEAP32[(((tmPtr)+(offsets.tm_year))>>2)]=date.getFullYear()-1900\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6819 HEAP32[(((tmPtr)+(offsets.tm_wday))>>2)]=date.getDay()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6820 var start = new Date(date.getFullYear(), 0, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6821 var yday = Math.floor((date.getTime() - start.getTime()) / (1000 * 60 * 60 * 24));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6822 HEAP32[(((tmPtr)+(offsets.tm_yday))>>2)]=yday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6823 HEAP32[(((tmPtr)+(offsets.tm_gmtoff))>>2)]=start.getTimezoneOffset() * 60\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6824 var dst = Number(start.getTimezoneOffset() != date.getTimezoneOffset());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6825 HEAP32[(((tmPtr)+(offsets.tm_isdst))>>2)]=dst\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6826 HEAP32[(((tmPtr)+(offsets.tm_zone))>>2)]=___tm_timezone\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6827 return tmPtr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6828 }function _localtime(time) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6829 return _localtime_r(time, ___tm_current);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6830 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6831 function __isLeapYear(year) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6832 return year%4 === 0 && (year%100 !== 0 || year%400 === 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6833 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6834 function __arraySum(array, index) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6835 var sum = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6836 for (var i = 0; i <= index; sum += array[i++]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6837 return sum;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6838 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6841 var newDate = new Date(date.getTime());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6842 while(days > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6843 var leap = __isLeapYear(newDate.getFullYear());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6844 var currentMonth = newDate.getMonth();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6845 var daysInCurrentMonth = (leap ? __MONTH_DAYS_LEAP : __MONTH_DAYS_REGULAR)[currentMonth];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6846 if (days > daysInCurrentMonth-newDate.getDate()) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6847 // we spill over to next month\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6848 days -= (daysInCurrentMonth-newDate.getDate()+1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6849 newDate.setDate(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6850 if (currentMonth < 11) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6851 newDate.setMonth(currentMonth+1)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6852 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6853 newDate.setMonth(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6854 newDate.setFullYear(newDate.getFullYear()+1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6855 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6856 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6857 // we stay in current month \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6858 newDate.setDate(newDate.getDate()+days);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6859 return newDate;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6860 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6861 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6862 return newDate;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6863 }function _strftime(s, maxsize, format, tm) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6865 // http://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6866 var date = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6867 tm_sec: HEAP32[(((tm)+(___tm_struct_layout.tm_sec))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6868 tm_min: HEAP32[(((tm)+(___tm_struct_layout.tm_min))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6869 tm_hour: HEAP32[(((tm)+(___tm_struct_layout.tm_hour))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6870 tm_mday: HEAP32[(((tm)+(___tm_struct_layout.tm_mday))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6871 tm_mon: HEAP32[(((tm)+(___tm_struct_layout.tm_mon))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6872 tm_year: HEAP32[(((tm)+(___tm_struct_layout.tm_year))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6873 tm_wday: HEAP32[(((tm)+(___tm_struct_layout.tm_wday))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6874 tm_yday: HEAP32[(((tm)+(___tm_struct_layout.tm_yday))>>2)],\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6875 tm_isdst: HEAP32[(((tm)+(___tm_struct_layout.tm_isdst))>>2)]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6876 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6877 var pattern = Pointer_stringify(format);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6878 // expand format\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6879 var EXPANSION_RULES_1 = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6881 '%D': '%m/%d/%y', // Equivalent to %m / %d / %y\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6882 '%F': '%Y-%m-%d', // Equivalent to %Y - %m - %d\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6883 '%h': '%b', // Equivalent to %b\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6885 '%R': '%H:%M', // Replaced by the time in 24-hour notation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6886 '%T': '%H:%M:%S', // Replaced by the time\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6887 '%x': '%m/%d/%y', // Replaced by the locale's appropriate date representation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6888 '%X': '%H:%M:%S', // Replaced by the locale's appropriate date representation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6889 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6890 for (var rule in EXPANSION_RULES_1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6891 pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_1[rule]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6892 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6893 var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6894 var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6895 var leadingSomething = function(value, digits, character) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6896 var str = typeof value === 'number' ? value.toString() : (value || '');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6897 while (str.length < digits) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6898 str = character[0]+str;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6899 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6900 return str;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6901 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6902 var leadingNulls = function(value, digits) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6903 return leadingSomething(value, digits, '0');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6904 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6905 var compareByDay = function(date1, date2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6906 var sgn = function(value) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6907 return value < 0 ? -1 : (value > 0 ? 1 : 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6908 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6909 var compare;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6910 if ((compare = sgn(date1.getFullYear()-date2.getFullYear())) === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6911 if ((compare = sgn(date1.getMonth()-date2.getMonth())) === 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6912 compare = sgn(date1.getDate()-date2.getDate());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6913 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6914 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6915 return compare;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6916 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6917 var getFirstWeekStartDate = function(janFourth) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6918 switch (janFourth.getDay()) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6919 case 0: // Sunday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6920 return new Date(janFourth.getFullYear()-1, 11, 29);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6921 case 1: // Monday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6922 return janFourth;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6923 case 2: // Tuesday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6924 return new Date(janFourth.getFullYear(), 0, 3);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6925 case 3: // Wednesday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6926 return new Date(janFourth.getFullYear(), 0, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6927 case 4: // Thursday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6928 return new Date(janFourth.getFullYear(), 0, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6929 case 5: // Friday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6930 return new Date(janFourth.getFullYear()-1, 11, 31);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6931 case 6: // Saturday\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6932 return new Date(janFourth.getFullYear()-1, 11, 30);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6933 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6934 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6935 var getWeekBasedYear = function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6936 var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6937 var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6938 var janFourthNextYear = new Date(thisDate.getFullYear()+1, 0, 4);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6939 var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6940 var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6941 if (compareByDay(firstWeekStartThisYear, thisDate) <= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6942 // this date is after the start of the first week of this year\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6943 if (compareByDay(firstWeekStartNextYear, thisDate) <= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6944 return thisDate.getFullYear()+1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6945 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6946 return thisDate.getFullYear();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6947 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6948 } else { \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6949 return thisDate.getFullYear()-1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6950 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6951 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6952 var EXPANSION_RULES_2 = {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6953 '%a': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6954 return WEEKDAYS[date.tm_wday].substring(0,3);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6955 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6956 '%A': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6957 return WEEKDAYS[date.tm_wday];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6958 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6959 '%b': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6960 return MONTHS[date.tm_mon].substring(0,3);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6961 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6962 '%B': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6963 return MONTHS[date.tm_mon];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6964 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6965 '%C': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6966 var year = date.tm_year+1900;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6967 return leadingNulls(Math.floor(year/100),2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6968 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6969 '%d': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6970 return leadingNulls(date.tm_mday, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6971 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6972 '%e': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6973 return leadingSomething(date.tm_mday, 2, ' ');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6974 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6975 '%g': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6979 // is also the first week that contains at least four days in the year. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6981 // the last week of the preceding year; thus, for Saturday 2nd January 1999, \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6982 // %G is replaced by 1998 and %V is replaced by 53. If December 29th, 30th, \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6985 return getWeekBasedYear(date).toString().substring(2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6986 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6987 '%G': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6988 return getWeekBasedYear(date);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6989 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6990 '%H': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6991 return leadingNulls(date.tm_hour, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6992 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6993 '%I': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6994 return leadingNulls(date.tm_hour < 13 ? date.tm_hour : date.tm_hour-12, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6995 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6996 '%j': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6997 // Day of the year (001-366)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6999 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7000 '%m': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7001 return leadingNulls(date.tm_mon+1, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7002 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7003 '%M': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7004 return leadingNulls(date.tm_min, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7005 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7006 '%n': function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7007 return '\\n';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7008 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7009 '%p': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7010 if (date.tm_hour > 0 && date.tm_hour < 13) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7011 return 'AM';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7012 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7013 return 'PM';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7014 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7015 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7016 '%S': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7017 return leadingNulls(date.tm_sec, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7018 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7019 '%t': function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7020 return '\\t';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7021 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7022 '%u': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7024 return day.getDay() || 7;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7025 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7026 '%U': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7027 // Replaced by the week number of the year as a decimal number [00,53]. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7028 // The first Sunday of January is the first day of week 1; \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7030 var janFirst = new Date(date.tm_year+1900, 0, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7031 var firstSunday = janFirst.getDay() === 0 ? janFirst : __addDays(janFirst, 7-janFirst.getDay());\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7032 var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7033 // is target date after the first Sunday?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7034 if (compareByDay(firstSunday, endDate) < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7035 // calculate difference in days between first Sunday and endDate\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7037 var firstSundayUntilEndJanuary = 31-firstSunday.getDate();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7038 var days = firstSundayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7039 return leadingNulls(Math.ceil(days/7), 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7040 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7041 return compareByDay(firstSunday, janFirst) === 0 ? '01': '00';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7042 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7043 '%V': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7045 // as a decimal number [01,53]. If the week containing 1 January has four \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7046 // or more days in the new year, then it is considered week 1. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7049 var janFourthThisYear = new Date(date.tm_year+1900, 0, 4);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7050 var janFourthNextYear = new Date(date.tm_year+1901, 0, 4);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7051 var firstWeekStartThisYear = getFirstWeekStartDate(janFourthThisYear);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7052 var firstWeekStartNextYear = getFirstWeekStartDate(janFourthNextYear);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7053 var endDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7054 if (compareByDay(endDate, firstWeekStartThisYear) < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7056 return '53';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7057 } \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7058 if (compareByDay(firstWeekStartNextYear, endDate) <= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7060 return '01';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7061 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7062 // given date is in between CW 01..53 of this calendar year\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7063 var daysDifference;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7064 if (firstWeekStartThisYear.getFullYear() < date.tm_year+1900) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7065 // first CW of this year starts last year\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7066 daysDifference = date.tm_yday+32-firstWeekStartThisYear.getDate()\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7067 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7068 // first CW of this year starts this year\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7069 daysDifference = date.tm_yday+1-firstWeekStartThisYear.getDate();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7070 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7071 return leadingNulls(Math.ceil(daysDifference/7), 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7072 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7073 '%w': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7075 return day.getDay();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7076 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7077 '%W': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7078 // Replaced by the week number of the year as a decimal number [00,53]. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7079 // The first Monday of January is the first day of week 1; \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7081 var janFirst = new Date(date.tm_year, 0, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7083 var endDate = new Date(date.tm_year+1900, date.tm_mon, date.tm_mday);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7084 // is target date after the first Monday?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7085 if (compareByDay(firstMonday, endDate) < 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7087 var firstMondayUntilEndJanuary = 31-firstMonday.getDate();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7088 var days = firstMondayUntilEndJanuary+februaryFirstUntilEndMonth+endDate.getDate();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7089 return leadingNulls(Math.ceil(days/7), 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7090 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7091 return compareByDay(firstMonday, janFirst) === 0 ? '01': '00';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7092 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7093 '%y': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7095 return (date.tm_year+1900).toString().substring(2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7096 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7097 '%Y': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7098 // Replaced by the year as a decimal number (for example, 1997). [ tm_year]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7099 return date.tm_year+1900;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7100 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7101 '%z': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 ),\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7103 // or by no characters if no timezone is determinable. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7104 // For example, \"-0430\" means 4 hours 30 minutes behind UTC (west of Greenwich). \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7105 // If tm_isdst is zero, the standard time offset is used. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7106 // If tm_isdst is greater than zero, the daylight savings time offset is used. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7107 // If tm_isdst is negative, no characters are returned. \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7108 // FIXME: we cannot determine time zone (or can we?)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7109 return '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7110 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7111 '%Z': function(date) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7113 // FIXME: we cannot determine time zone (or can we?)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7114 return '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7115 },\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7116 '%%': function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7117 return '%';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7118 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7119 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7120 for (var rule in EXPANSION_RULES_2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7121 if (pattern.indexOf(rule) >= 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7122 pattern = pattern.replace(new RegExp(rule, 'g'), EXPANSION_RULES_2[rule](date));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7123 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7124 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7125 var bytes = intArrayFromString(pattern, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7126 if (bytes.length > maxsize) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7127 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7128 } \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7129 writeArrayToMemory(bytes, s);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7130 return bytes.length-1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7131 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7132 function _clock() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7133 if (_clock.start === undefined) _clock.start = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7134 return Math.floor((Date.now() - _clock.start) * (1000/1000));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7135 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7136 function _toupper(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7137 if (chr >= 97 && chr <= 122) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7138 return chr - 97 + 65;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7139 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7140 return chr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7141 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7142 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7143 function _strpbrk(ptr1, ptr2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7144 var curr;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7145 var searchSet = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7146 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7147 var curr = HEAP8[((ptr2++)|0)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7148 if (!curr) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7149 searchSet[curr] = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7150 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7151 while (1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7152 curr = HEAP8[(ptr1)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7153 if (!curr) break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7154 if (curr in searchSet) return ptr1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7155 ptr1++;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7156 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7157 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7158 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7159 Module[\"_tolower\"] = _tolower;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7160 function _islower(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7161 return chr >= 97 && chr <= 122;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7162 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7163 function _ispunct(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7164 return (chr >= 33 && chr <= 47) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7165 (chr >= 58 && chr <= 64) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7166 (chr >= 91 && chr <= 96) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7167 (chr >= 123 && chr <= 126);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7168 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7169 function _isupper(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7170 return chr >= 65 && chr <= 90;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7171 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7172 function _isxdigit(chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7173 return (chr >= 48 && chr <= 57) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7174 (chr >= 97 && chr <= 102) ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7175 (chr >= 65 && chr <= 70);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7176 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7177 function _strrchr(ptr, chr) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7178 var ptr2 = ptr + _strlen(ptr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7179 do {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7180 if (HEAP8[(ptr2)] == chr) return ptr2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7181 ptr2--;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7182 } while (ptr2 >= ptr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7183 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7184 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7185 function _abort() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7186 Module['abort']();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7187 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7188 function _sbrk(bytes) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7189 // Implement a Linux-like 'memory area' for our 'process'.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7190 // Changes the size of the memory area by |bytes|; returns the\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7191 // address of the previous top ('break') of the memory area\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7192 // We control the \"dynamic\" memory - DYNAMIC_BASE to DYNAMICTOP\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7193 var self = _sbrk;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7194 if (!self.called) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7195 DYNAMICTOP = alignMemoryPage(DYNAMICTOP); // make sure we start out aligned\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7196 self.called = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7197 assert(Runtime.dynamicAlloc);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7198 self.alloc = Runtime.dynamicAlloc;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7199 Runtime.dynamicAlloc = function() { abort('cannot dynamically allocate, sbrk now has control') };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7200 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7201 var ret = DYNAMICTOP;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7202 if (bytes != 0) self.alloc(bytes);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7203 return ret; // Previous break location.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7204 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7205 function _sysconf(name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7206 // long sysconf(int name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7207 // http://pubs.opengroup.org/onlinepubs/009695399/functions/sysconf.html\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7208 switch(name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7209 case 8: return PAGE_SIZE;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7210 case 54:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7211 case 56:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7212 case 21:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7213 case 61:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7214 case 63:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7215 case 22:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7216 case 67:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7217 case 23:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7218 case 24:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7219 case 25:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7220 case 26:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7221 case 27:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7222 case 69:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7223 case 28:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7224 case 101:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7225 case 70:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7226 case 71:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7227 case 29:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7228 case 30:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7229 case 199:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7230 case 75:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7231 case 76:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7232 case 32:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7233 case 43:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7234 case 44:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7235 case 80:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7236 case 46:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7237 case 47:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7238 case 45:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7239 case 48:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7240 case 49:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7241 case 42:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7242 case 82:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7243 case 33:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7244 case 7:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7245 case 108:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7246 case 109:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7247 case 107:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7248 case 112:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7249 case 119:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7250 case 121:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7251 return 200809;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7252 case 13:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7253 case 104:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7254 case 94:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7255 case 95:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7256 case 34:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7257 case 35:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7258 case 77:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7259 case 81:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7260 case 83:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7261 case 84:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7262 case 85:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7263 case 86:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7264 case 87:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7265 case 88:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7266 case 89:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7267 case 90:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7268 case 91:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7269 case 94:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7270 case 95:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7271 case 110:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7272 case 111:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7273 case 113:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7274 case 114:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7275 case 115:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7276 case 116:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7277 case 117:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7278 case 118:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7279 case 120:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7280 case 40:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7281 case 16:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7282 case 79:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7283 case 19:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7284 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7285 case 92:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7286 case 93:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7287 case 5:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7288 case 72:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7289 case 6:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7290 case 74:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7291 case 92:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7292 case 93:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7293 case 96:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7294 case 97:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7295 case 98:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7296 case 99:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7297 case 102:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7298 case 103:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7299 case 105:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7300 return 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7301 case 38:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7302 case 66:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7303 case 50:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7304 case 51:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7305 case 4:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7306 return 1024;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7307 case 15:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7308 case 64:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7309 case 41:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7310 return 32;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7311 case 55:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7312 case 37:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7313 case 17:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7314 return 2147483647;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7315 case 18:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7316 case 1:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7317 return 47839;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7318 case 59:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7319 case 57:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7320 return 99;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7321 case 68:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7322 case 58:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7323 return 2048;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7324 case 0: return 2097152;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7325 case 3: return 65536;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7326 case 14: return 32768;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7327 case 73: return 32767;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7328 case 39: return 16384;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7329 case 60: return 1000;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7330 case 106: return 700;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7331 case 52: return 256;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7332 case 62: return 255;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7333 case 2: return 100;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7334 case 65: return 64;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7335 case 36: return 20;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7336 case 100: return 16;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7337 case 20: return 6;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7338 case 53: return 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7339 case 10: return 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7340 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7341 ___setErrNo(ERRNO_CODES.EINVAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7342 return -1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7343 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7344 var Browser={mainLoop:{scheduler:null,shouldPause:false,paused:false,queue:[],pause:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7345 Browser.mainLoop.shouldPause = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7346 },resume:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7347 if (Browser.mainLoop.paused) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7348 Browser.mainLoop.paused = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7349 Browser.mainLoop.scheduler();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7350 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7351 Browser.mainLoop.shouldPause = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7352 },updateStatus:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7353 if (Module['setStatus']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7354 var message = Module['statusMessage'] || 'Please wait...';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7355 var remaining = Browser.mainLoop.remainingBlockers;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7356 var expected = Browser.mainLoop.expectedBlockers;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7357 if (remaining) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7358 if (remaining < expected) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7359 Module['setStatus'](message + ' (' + (expected - remaining) + '/' + expected + ')');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7360 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7361 Module['setStatus'](message);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7362 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7363 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7364 Module['setStatus']('');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7365 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7366 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7367 }},isFullScreen:false,pointerLock:false,moduleContextCreatedCallbacks:[],workers:[],init:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7368 if (!Module[\"preloadPlugins\"]) Module[\"preloadPlugins\"] = []; // needs to exist even in workers\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7369 if (Browser.initted || ENVIRONMENT_IS_WORKER) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7370 Browser.initted = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7371 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7372 new Blob();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7373 Browser.hasBlobConstructor = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7374 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7375 Browser.hasBlobConstructor = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7376 console.log(\"warning: no blob constructor, cannot create blobs with mimetypes\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7377 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7379 Browser.URLObject = typeof window != \"undefined\" ? (window.URL ? window.URL : window.webkitURL) : undefined;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7380 if (!Module.noImageDecoding && typeof Browser.URLObject === 'undefined') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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.\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7382 Module.noImageDecoding = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7383 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7384 // Support for plugins that can process preloaded files. You can add more of these to\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7385 // your app by creating and appending to Module.preloadPlugins.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7386 //\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7389 // (possibly modified) data. For example, a plugin might decompress a file, or it\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7390 // might create some side data structure for use later (like an Image element, etc.).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7391 var imagePlugin = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7392 imagePlugin['canHandle'] = function(name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7393 return !Module.noImageDecoding && /\\.(jpg|jpeg|png|bmp)$/i.test(name);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7394 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7395 imagePlugin['handle'] = function(byteArray, name, onload, onerror) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7396 var b = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7397 if (Browser.hasBlobConstructor) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7398 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7399 b = new Blob([byteArray], { type: Browser.getMimetype(name) });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7400 if (b.size !== byteArray.length) { // Safari bug #118630\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7401 // Safari's Blob can only take an ArrayBuffer\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7402 b = new Blob([(new Uint8Array(byteArray)).buffer], { type: Browser.getMimetype(name) });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7403 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7404 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7405 Runtime.warnOnce('Blob constructor present but fails: ' + e + '; falling back to blob builder');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7406 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7407 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7408 if (!b) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7409 var bb = new Browser.BlobBuilder();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7411 b = bb.getBlob();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7412 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7413 var url = Browser.URLObject.createObjectURL(b);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7414 var img = new Image();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7415 img.onload = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7416 assert(img.complete, 'Image ' + name + ' could not be decoded');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7417 var canvas = document.createElement('canvas');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7418 canvas.width = img.width;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7419 canvas.height = img.height;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7420 var ctx = canvas.getContext('2d');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7421 ctx.drawImage(img, 0, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7422 Module[\"preloadedImages\"][name] = canvas;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7423 Browser.URLObject.revokeObjectURL(url);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7424 if (onload) onload(byteArray);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7425 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7426 img.onerror = function(event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7427 console.log('Image ' + url + ' could not be decoded');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7428 if (onerror) onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7429 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7430 img.src = url;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7431 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7432 Module['preloadPlugins'].push(imagePlugin);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7433 var audioPlugin = {};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7434 audioPlugin['canHandle'] = function(name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7435 return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7436 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7437 audioPlugin['handle'] = function(byteArray, name, onload, onerror) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7438 var done = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7439 function finish(audio) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7440 if (done) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7441 done = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7442 Module[\"preloadedAudios\"][name] = audio;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7443 if (onload) onload(byteArray);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7444 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7445 function fail() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7446 if (done) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7447 done = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7448 Module[\"preloadedAudios\"][name] = new Audio(); // empty shim\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7449 if (onerror) onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7450 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7451 if (Browser.hasBlobConstructor) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7452 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7453 var b = new Blob([byteArray], { type: Browser.getMimetype(name) });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7454 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7455 return fail();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7456 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7457 var url = Browser.URLObject.createObjectURL(b); // XXX we never revoke this!\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7458 var audio = new Audio();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7459 audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7460 audio.onerror = function(event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7461 if (done) return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7462 console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7463 function encode64(data) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7464 var BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7465 var PAD = '=';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7466 var ret = '';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7467 var leftchar = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7468 var leftbits = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7469 for (var i = 0; i < data.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7470 leftchar = (leftchar << 8) | data[i];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7471 leftbits += 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7472 while (leftbits >= 6) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7473 var curr = (leftchar >> (leftbits-6)) & 0x3f;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7474 leftbits -= 6;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7475 ret += BASE[curr];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7476 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7477 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7478 if (leftbits == 2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7479 ret += BASE[(leftchar&3) << 4];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7480 ret += PAD + PAD;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7481 } else if (leftbits == 4) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7482 ret += BASE[(leftchar&0xf) << 2];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7483 ret += PAD;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7484 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7485 return ret;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7486 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7487 audio.src = 'data:audio/x-' + name.substr(-3) + ';base64,' + encode64(byteArray);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7488 finish(audio); // we don't wait for confirmation this worked - but it's worth trying\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7489 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7490 audio.src = url;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7491 // workaround for chrome bug 124926 - we do not always get oncanplaythrough or onerror\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7492 Browser.safeSetTimeout(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7493 finish(audio); // try to use it even though it is not necessarily ready to play\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7494 }, 10000);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7495 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7496 return fail();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7497 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7498 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7499 Module['preloadPlugins'].push(audioPlugin);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7500 // Canvas event setup\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7501 var canvas = Module['canvas'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7502 canvas.requestPointerLock = canvas['requestPointerLock'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7503 canvas['mozRequestPointerLock'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7504 canvas['webkitRequestPointerLock'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7505 canvas.exitPointerLock = document['exitPointerLock'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7506 document['mozExitPointerLock'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7507 document['webkitExitPointerLock'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7508 function(){}; // no-op if function does not exist\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7509 canvas.exitPointerLock = canvas.exitPointerLock.bind(document);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7510 function pointerLockChange() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7511 Browser.pointerLock = document['pointerLockElement'] === canvas ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7512 document['mozPointerLockElement'] === canvas ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7513 document['webkitPointerLockElement'] === canvas;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7514 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7515 document.addEventListener('pointerlockchange', pointerLockChange, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7516 document.addEventListener('mozpointerlockchange', pointerLockChange, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7517 document.addEventListener('webkitpointerlockchange', pointerLockChange, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7518 if (Module['elementPointerLock']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7519 canvas.addEventListener(\"click\", function(ev) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7520 if (!Browser.pointerLock && canvas.requestPointerLock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7521 canvas.requestPointerLock();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7522 ev.preventDefault();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7523 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7524 }, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7525 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7526 },createContext:function (canvas, useWebGL, setInModule) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7527 var ctx;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7528 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7529 if (useWebGL) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7530 ctx = canvas.getContext('experimental-webgl', {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7531 alpha: false\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7532 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7533 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7534 ctx = canvas.getContext('2d');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7535 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7536 if (!ctx) throw ':(';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7537 } catch (e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7538 Module.print('Could not create canvas - ' + e);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7539 return null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7540 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7541 if (useWebGL) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7542 // Set the background of the WebGL canvas to black\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7543 canvas.style.backgroundColor = \"black\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7544 // Warn on context loss\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7545 canvas.addEventListener('webglcontextlost', function(event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7546 alert('WebGL context lost. You will need to reload the page.');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7547 }, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7548 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7549 if (setInModule) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7550 Module.ctx = ctx;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7551 Module.useWebGL = useWebGL;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7552 Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7553 Browser.init();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7554 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7555 return ctx;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7556 },destroyContext:function (canvas, useWebGL, setInModule) {},fullScreenHandlersInstalled:false,lockPointer:undefined,resizeCanvas:undefined,requestFullScreen:function (lockPointer, resizeCanvas) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7557 Browser.lockPointer = lockPointer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7558 Browser.resizeCanvas = resizeCanvas;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7559 if (typeof Browser.lockPointer === 'undefined') Browser.lockPointer = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7560 if (typeof Browser.resizeCanvas === 'undefined') Browser.resizeCanvas = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7561 var canvas = Module['canvas'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7562 function fullScreenChange() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7563 Browser.isFullScreen = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7564 if ((document['webkitFullScreenElement'] || document['webkitFullscreenElement'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7565 document['mozFullScreenElement'] || document['mozFullscreenElement'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7566 document['fullScreenElement'] || document['fullscreenElement']) === canvas) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7567 canvas.cancelFullScreen = document['cancelFullScreen'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7568 document['mozCancelFullScreen'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7569 document['webkitCancelFullScreen'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7570 canvas.cancelFullScreen = canvas.cancelFullScreen.bind(document);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7571 if (Browser.lockPointer) canvas.requestPointerLock();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7572 Browser.isFullScreen = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7573 if (Browser.resizeCanvas) Browser.setFullScreenCanvasSize();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7574 } else if (Browser.resizeCanvas){\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7575 Browser.setWindowedCanvasSize();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7576 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7577 if (Module['onFullScreen']) Module['onFullScreen'](Browser.isFullScreen);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7578 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7579 if (!Browser.fullScreenHandlersInstalled) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7580 Browser.fullScreenHandlersInstalled = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7581 document.addEventListener('fullscreenchange', fullScreenChange, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7582 document.addEventListener('mozfullscreenchange', fullScreenChange, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7583 document.addEventListener('webkitfullscreenchange', fullScreenChange, false);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7584 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7585 canvas.requestFullScreen = canvas['requestFullScreen'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7586 canvas['mozRequestFullScreen'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7587 (canvas['webkitRequestFullScreen'] ? function() { canvas['webkitRequestFullScreen'](Element['ALLOW_KEYBOARD_INPUT']) } : null);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7588 canvas.requestFullScreen();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7589 },requestAnimationFrame:function (func) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7590 if (!window.requestAnimationFrame) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7591 window.requestAnimationFrame = window['requestAnimationFrame'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7592 window['mozRequestAnimationFrame'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7593 window['webkitRequestAnimationFrame'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7594 window['msRequestAnimationFrame'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7595 window['oRequestAnimationFrame'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7596 window['setTimeout'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7597 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7598 window.requestAnimationFrame(func);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7599 },safeCallback:function (func) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7600 return function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7601 if (!ABORT) return func.apply(null, arguments);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7602 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7603 },safeRequestAnimationFrame:function (func) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7604 return Browser.requestAnimationFrame(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7605 if (!ABORT) func();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7606 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7607 },safeSetTimeout:function (func, timeout) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7608 return setTimeout(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7609 if (!ABORT) func();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7610 }, timeout);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7611 },safeSetInterval:function (func, timeout) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7612 return setInterval(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7613 if (!ABORT) func();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7614 }, timeout);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7615 },getMimetype:function (name) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7616 return {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7617 'jpg': 'image/jpeg',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7618 'jpeg': 'image/jpeg',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7619 'png': 'image/png',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7620 'bmp': 'image/bmp',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7621 'ogg': 'audio/ogg',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7622 'wav': 'audio/wav',\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7623 'mp3': 'audio/mpeg'\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7624 }[name.substr(name.lastIndexOf('.')+1)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7625 },getUserMedia:function (func) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7626 if(!window.getUserMedia) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7627 window.getUserMedia = navigator['getUserMedia'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7628 navigator['mozGetUserMedia'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7629 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7630 window.getUserMedia(func);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7631 },getMovementX:function (event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7632 return event['movementX'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7633 event['mozMovementX'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7634 event['webkitMovementX'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7635 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7636 },getMovementY:function (event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7637 return event['movementY'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7638 event['mozMovementY'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7639 event['webkitMovementY'] ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7640 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7642 if (Browser.pointerLock) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7643 // When the pointer is locked, calculate the coordinates\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7644 // based on the movement of the mouse.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7645 // Workaround for Firefox bug 764498\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7646 if (event.type != 'mousemove' &&\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7647 ('mozMovementX' in event)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7648 Browser.mouseMovementX = Browser.mouseMovementY = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7649 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7650 Browser.mouseMovementX = Browser.getMovementX(event);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7651 Browser.mouseMovementY = Browser.getMovementY(event);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7652 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7653 // check if SDL is available\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7654 if (typeof SDL != \"undefined\") {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7655 Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7656 Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7657 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7658 // just add the mouse delta to the current absolut mouse position\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7659 // FIXME: ideally this should be clamped against the canvas size and zero\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7660 Browser.mouseX += Browser.mouseMovementX;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7661 Browser.mouseY += Browser.mouseMovementY;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7662 } \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7663 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7664 // Otherwise, calculate the movement based on the changes\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7665 // in the coordinates.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7666 var rect = Module[\"canvas\"].getBoundingClientRect();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7667 var x, y;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7668 if (event.type == 'touchstart' ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7669 event.type == 'touchend' ||\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7670 event.type == 'touchmove') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7671 var t = event.touches.item(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7672 if (t) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7673 x = t.pageX - (window.scrollX + rect.left);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7674 y = t.pageY - (window.scrollY + rect.top);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7675 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7676 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7677 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7678 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7679 x = event.pageX - (window.scrollX + rect.left);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7680 y = event.pageY - (window.scrollY + rect.top);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7681 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7682 // the canvas might be CSS-scaled compared to its backbuffer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7683 // SDL-using content will want mouse coordinates in terms\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7684 // of backbuffer units.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7685 var cw = Module[\"canvas\"].width;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7686 var ch = Module[\"canvas\"].height;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7687 x = x * (cw / rect.width);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7688 y = y * (ch / rect.height);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7689 Browser.mouseMovementX = x - Browser.mouseX;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7690 Browser.mouseMovementY = y - Browser.mouseY;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7691 Browser.mouseX = x;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7692 Browser.mouseY = y;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7693 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7694 },xhrLoad:function (url, onload, onerror) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7695 var xhr = new XMLHttpRequest();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7696 xhr.open('GET', url, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7697 xhr.responseType = 'arraybuffer';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7698 xhr.onload = function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7699 if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7700 onload(xhr.response);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7701 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7702 onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7703 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7704 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7705 xhr.onerror = onerror;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7706 xhr.send(null);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7707 },asyncLoad:function (url, onload, onerror, noRunDep) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7708 Browser.xhrLoad(url, function(arrayBuffer) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7709 assert(arrayBuffer, 'Loading data file \"' + url + '\" failed (no arrayBuffer).');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7710 onload(new Uint8Array(arrayBuffer));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7711 if (!noRunDep) removeRunDependency('al ' + url);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7712 }, function(event) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7713 if (onerror) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7714 onerror();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7715 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7716 throw 'Loading data file \"' + url + '\" failed.';\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7717 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7718 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7719 if (!noRunDep) addRunDependency('al ' + url);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7720 },resizeListeners:[],updateResizeListeners:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7721 var canvas = Module['canvas'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7722 Browser.resizeListeners.forEach(function(listener) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7723 listener(canvas.width, canvas.height);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7724 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7725 },setCanvasSize:function (width, height, noUpdates) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7726 var canvas = Module['canvas'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7727 canvas.width = width;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7728 canvas.height = height;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7729 if (!noUpdates) Browser.updateResizeListeners();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7730 },windowedWidth:0,windowedHeight:0,setFullScreenCanvasSize:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7731 var canvas = Module['canvas'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7732 this.windowedWidth = canvas.width;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7733 this.windowedHeight = canvas.height;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7734 canvas.width = screen.width;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7735 canvas.height = screen.height;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7736 // check if SDL is available \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7737 if (typeof SDL != \"undefined\") {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7738 var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7739 flags = flags | 0x00800000; // set SDL_FULLSCREEN flag\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7740 HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7741 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7742 Browser.updateResizeListeners();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7743 },setWindowedCanvasSize:function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7744 var canvas = Module['canvas'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7745 canvas.width = this.windowedWidth;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7746 canvas.height = this.windowedHeight;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7747 // check if SDL is available \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7748 if (typeof SDL != \"undefined\") {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7749 var flags = HEAPU32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7750 flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7751 HEAP32[((SDL.screen+Runtime.QUANTUM_SIZE*0)>>2)]=flags\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7752 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7753 Browser.updateResizeListeners();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7754 }};\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7755 _fputc.ret = allocate([0], \"i8\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7757 ___errno_state = Runtime.staticAlloc(4); HEAP32[((___errno_state)>>2)]=0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7759 __ATINIT__.push({ func: function() { SOCKFS.root = FS.mount(SOCKFS, {}, null); } });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7760 _fgetc.ret = allocate([0], \"i8\", ALLOC_STATIC);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7761 ___buildEnvironment(ENV);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7762 Module[\"requestFullScreen\"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7763 Module[\"requestAnimationFrame\"] = function(func) { Browser.requestAnimationFrame(func) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7764 Module[\"setCanvasSize\"] = function(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7765 Module[\"pauseMainLoop\"] = function() { Browser.mainLoop.pause() };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7766 Module[\"resumeMainLoop\"] = function() { Browser.mainLoop.resume() };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7767 Module[\"getUserMedia\"] = function() { Browser.getUserMedia() }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7768 STACK_BASE = STACKTOP = Runtime.alignMemory(STATICTOP);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7769 staticSealed = true; // seal the static portion of memory\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7770 STACK_MAX = STACK_BASE + 5242880;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7771 DYNAMIC_BASE = DYNAMICTOP = Runtime.alignMemory(STACK_MAX);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7773 var Math_min = Math.min;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7774 function invoke_ii(index,a1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7775 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7776 return Module[\"dynCall_ii\"](index,a1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7777 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7778 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7779 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7780 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7781 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7782 function invoke_vi(index,a1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7783 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7784 Module[\"dynCall_vi\"](index,a1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7785 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7786 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7787 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7788 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7789 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7790 function invoke_vii(index,a1,a2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7791 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7792 Module[\"dynCall_vii\"](index,a1,a2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7793 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7794 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7795 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7796 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7797 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7798 function invoke_iiiii(index,a1,a2,a3,a4) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7799 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7800 return Module[\"dynCall_iiiii\"](index,a1,a2,a3,a4);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7801 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7802 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7803 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7804 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7805 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7806 function invoke_iiii(index,a1,a2,a3) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7807 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7808 return Module[\"dynCall_iiii\"](index,a1,a2,a3);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7809 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7810 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7811 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7812 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7813 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7814 function invoke_v(index) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7815 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7816 Module[\"dynCall_v\"](index);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7817 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7818 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7819 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7820 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7821 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7822 function invoke_iii(index,a1,a2) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7823 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7824 return Module[\"dynCall_iii\"](index,a1,a2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7825 } catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7826 if (typeof e !== 'number' && e !== 'longjmp') throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7827 asm[\"setThrew\"](1, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7828 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7829 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7830 function asmPrintInt(x, y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7831 Module.print('int ' + x + ',' + y);// + ' ' + new Error().stack);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7832 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7833 function asmPrintFloat(x, y) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7834 Module.print('float ' + x + ',' + y);// + ' ' + new Error().stack);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7835 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7836 // EMSCRIPTEN_START_ASM\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7838 // EMSCRIPTEN_START_FUNCS\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7841 // EMSCRIPTEN_END_FUNCS\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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}})\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7843 // EMSCRIPTEN_END_ASM\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7845 var _luaL_checkstack = Module[\"_luaL_checkstack\"] = asm[\"_luaL_checkstack\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7846 var _strlen = Module[\"_strlen\"] = asm[\"_strlen\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7847 var _strcat = Module[\"_strcat\"] = asm[\"_strcat\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7848 var _lua_pushlightuserdata = Module[\"_lua_pushlightuserdata\"] = asm[\"_lua_pushlightuserdata\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7849 var _lua_createtable = Module[\"_lua_createtable\"] = asm[\"_lua_createtable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7850 var _luaL_optinteger = Module[\"_luaL_optinteger\"] = asm[\"_luaL_optinteger\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7851 var _lua_rawset = Module[\"_lua_rawset\"] = asm[\"_lua_rawset\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7852 var _strncpy = Module[\"_strncpy\"] = asm[\"_strncpy\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7853 var _lua_setmetatable = Module[\"_lua_setmetatable\"] = asm[\"_lua_setmetatable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7854 var _lua_concat = Module[\"_lua_concat\"] = asm[\"_lua_concat\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7855 var _luaL_optlstring = Module[\"_luaL_optlstring\"] = asm[\"_luaL_optlstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7856 var _luaopen_io = Module[\"_luaopen_io\"] = asm[\"_luaopen_io\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7857 var _memcpy = Module[\"_memcpy\"] = asm[\"_memcpy\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7858 var _lua_pcall = Module[\"_lua_pcall\"] = asm[\"_lua_pcall\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7859 var _lua_pushthread = Module[\"_lua_pushthread\"] = asm[\"_lua_pushthread\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7860 var _lua_close = Module[\"_lua_close\"] = asm[\"_lua_close\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7861 var _luaopen_math = Module[\"_luaopen_math\"] = asm[\"_luaopen_math\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7862 var _lua_setupvalue = Module[\"_lua_setupvalue\"] = asm[\"_lua_setupvalue\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7863 var _lua_replace = Module[\"_lua_replace\"] = asm[\"_lua_replace\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7864 var _memcmp = Module[\"_memcmp\"] = asm[\"_memcmp\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7865 var _lua_gethookmask = Module[\"_lua_gethookmask\"] = asm[\"_lua_gethookmask\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7866 var _lua_xmove = Module[\"_lua_xmove\"] = asm[\"_lua_xmove\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7867 var _lua_load = Module[\"_lua_load\"] = asm[\"_lua_load\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7868 var _lua_touserdata = Module[\"_lua_touserdata\"] = asm[\"_lua_touserdata\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7869 var _lua_rawget = Module[\"_lua_rawget\"] = asm[\"_lua_rawget\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7870 var _free = Module[\"_free\"] = asm[\"_free\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7871 var _lua_pushcclosure = Module[\"_lua_pushcclosure\"] = asm[\"_lua_pushcclosure\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7872 var _lua_pushstring = Module[\"_lua_pushstring\"] = asm[\"_lua_pushstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7873 var _tolower = Module[\"_tolower\"] = asm[\"_tolower\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7874 var _lua_getfenv = Module[\"_lua_getfenv\"] = asm[\"_lua_getfenv\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7875 var _luaopen_string = Module[\"_luaopen_string\"] = asm[\"_luaopen_string\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7876 var _lua_isuserdata = Module[\"_lua_isuserdata\"] = asm[\"_lua_isuserdata\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7877 var _luaL_buffinit = Module[\"_luaL_buffinit\"] = asm[\"_luaL_buffinit\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7878 var _lua_resume = Module[\"_lua_resume\"] = asm[\"_lua_resume\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7879 var _lua_iscfunction = Module[\"_lua_iscfunction\"] = asm[\"_lua_iscfunction\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7880 var _lua_remove = Module[\"_lua_remove\"] = asm[\"_lua_remove\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7881 var _luaL_checkoption = Module[\"_luaL_checkoption\"] = asm[\"_luaL_checkoption\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7882 var _lua_tointeger = Module[\"_lua_tointeger\"] = asm[\"_lua_tointeger\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7883 var _lua_pushvfstring = Module[\"_lua_pushvfstring\"] = asm[\"_lua_pushvfstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7884 var _luaL_prepbuffer = Module[\"_luaL_prepbuffer\"] = asm[\"_luaL_prepbuffer\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7885 var _lua_isnumber = Module[\"_lua_isnumber\"] = asm[\"_lua_isnumber\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7886 var _luaL_checklstring = Module[\"_luaL_checklstring\"] = asm[\"_luaL_checklstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7887 var _lua_isstring = Module[\"_lua_isstring\"] = asm[\"_lua_isstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7888 var _lua_pushlstring = Module[\"_lua_pushlstring\"] = asm[\"_lua_pushlstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7889 var _lua_setfenv = Module[\"_lua_setfenv\"] = asm[\"_lua_setfenv\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7890 var _lua_lessthan = Module[\"_lua_lessthan\"] = asm[\"_lua_lessthan\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7891 var _luaopen_os = Module[\"_luaopen_os\"] = asm[\"_luaopen_os\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7892 var _lua_yield = Module[\"_lua_yield\"] = asm[\"_lua_yield\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7893 var _luaL_checkany = Module[\"_luaL_checkany\"] = asm[\"_luaL_checkany\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7894 var _luaL_addstring = Module[\"_luaL_addstring\"] = asm[\"_luaL_addstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7895 var _lua_pushfstring = Module[\"_lua_pushfstring\"] = asm[\"_lua_pushfstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7896 var _lua_insert = Module[\"_lua_insert\"] = asm[\"_lua_insert\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7897 var _lua_tolstring = Module[\"_lua_tolstring\"] = asm[\"_lua_tolstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7898 var _lua_pushnil = Module[\"_lua_pushnil\"] = asm[\"_lua_pushnil\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7899 var _luaL_register = Module[\"_luaL_register\"] = asm[\"_luaL_register\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7900 var _lua_getupvalue = Module[\"_lua_getupvalue\"] = asm[\"_lua_getupvalue\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7901 var _lua_checkstack = Module[\"_lua_checkstack\"] = asm[\"_lua_checkstack\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7902 var _luaopen_package = Module[\"_luaopen_package\"] = asm[\"_luaopen_package\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7903 var _luaL_pushresult = Module[\"_luaL_pushresult\"] = asm[\"_luaL_pushresult\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7904 var _lua_topointer = Module[\"_lua_topointer\"] = asm[\"_lua_topointer\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7905 var _lua_error = Module[\"_lua_error\"] = asm[\"_lua_error\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7906 var _lua_gettable = Module[\"_lua_gettable\"] = asm[\"_lua_gettable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7907 var _luaopen_debug = Module[\"_luaopen_debug\"] = asm[\"_luaopen_debug\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7908 var _lua_tonumber = Module[\"_lua_tonumber\"] = asm[\"_lua_tonumber\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7909 var _luaL_checkinteger = Module[\"_luaL_checkinteger\"] = asm[\"_luaL_checkinteger\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7910 var _lua_getstack = Module[\"_lua_getstack\"] = asm[\"_lua_getstack\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7911 var _lua_gettop = Module[\"_lua_gettop\"] = asm[\"_lua_gettop\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7912 var _lua_getlocal = Module[\"_lua_getlocal\"] = asm[\"_lua_getlocal\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7913 var _luaL_checktype = Module[\"_luaL_checktype\"] = asm[\"_luaL_checktype\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7914 var _lua_newuserdata = Module[\"_lua_newuserdata\"] = asm[\"_lua_newuserdata\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7915 var _lua_settable = Module[\"_lua_settable\"] = asm[\"_lua_settable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7916 var _luaL_addlstring = Module[\"_luaL_addlstring\"] = asm[\"_luaL_addlstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7917 var _luaL_loadbuffer = Module[\"_luaL_loadbuffer\"] = asm[\"_luaL_loadbuffer\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7918 var _lua_toboolean = Module[\"_lua_toboolean\"] = asm[\"_lua_toboolean\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7919 var _lua_setallocf = Module[\"_lua_setallocf\"] = asm[\"_lua_setallocf\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7920 var _memset = Module[\"_memset\"] = asm[\"_memset\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7921 var _lua_gethook = Module[\"_lua_gethook\"] = asm[\"_lua_gethook\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7922 var _lua_gethookcount = Module[\"_lua_gethookcount\"] = asm[\"_lua_gethookcount\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7923 var _luaL_openlibs = Module[\"_luaL_openlibs\"] = asm[\"_luaL_openlibs\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7924 var _lua_setlocal = Module[\"_lua_setlocal\"] = asm[\"_lua_setlocal\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7925 var _lua_tothread = Module[\"_lua_tothread\"] = asm[\"_lua_tothread\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7926 var _lua_newstate = Module[\"_lua_newstate\"] = asm[\"_lua_newstate\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7927 var _lua_pushvalue = Module[\"_lua_pushvalue\"] = asm[\"_lua_pushvalue\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7928 var _lua_tocfunction = Module[\"_lua_tocfunction\"] = asm[\"_lua_tocfunction\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7929 var _lua_newthread = Module[\"_lua_newthread\"] = asm[\"_lua_newthread\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7930 var _lua_typename = Module[\"_lua_typename\"] = asm[\"_lua_typename\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7931 var _luaL_argerror = Module[\"_luaL_argerror\"] = asm[\"_luaL_argerror\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7932 var _lua_rawgeti = Module[\"_lua_rawgeti\"] = asm[\"_lua_rawgeti\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7933 var _testSetjmp = Module[\"_testSetjmp\"] = asm[\"_testSetjmp\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7934 var _lua_sethook = Module[\"_lua_sethook\"] = asm[\"_lua_sethook\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7935 var _lua_equal = Module[\"_lua_equal\"] = asm[\"_lua_equal\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7936 var _luaL_callmeta = Module[\"_luaL_callmeta\"] = asm[\"_luaL_callmeta\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7937 var _lua_call = Module[\"_lua_call\"] = asm[\"_lua_call\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7938 var _luaL_typerror = Module[\"_luaL_typerror\"] = asm[\"_luaL_typerror\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7939 var _malloc = Module[\"_malloc\"] = asm[\"_malloc\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7940 var _lua_rawequal = Module[\"_lua_rawequal\"] = asm[\"_lua_rawequal\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7941 var _lua_type = Module[\"_lua_type\"] = asm[\"_lua_type\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7942 var _lua_getfield = Module[\"_lua_getfield\"] = asm[\"_lua_getfield\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7943 var _lua_objlen = Module[\"_lua_objlen\"] = asm[\"_lua_objlen\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7944 var _luaL_checknumber = Module[\"_luaL_checknumber\"] = asm[\"_luaL_checknumber\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7945 var _luaL_newmetatable = Module[\"_luaL_newmetatable\"] = asm[\"_luaL_newmetatable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7946 var _lua_getmetatable = Module[\"_lua_getmetatable\"] = asm[\"_lua_getmetatable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7947 var _luaL_newstate = Module[\"_luaL_newstate\"] = asm[\"_luaL_newstate\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7948 var _luaopen_base = Module[\"_luaopen_base\"] = asm[\"_luaopen_base\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7949 var _luaL_gsub = Module[\"_luaL_gsub\"] = asm[\"_luaL_gsub\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7950 var _luaL_addvalue = Module[\"_luaL_addvalue\"] = asm[\"_luaL_addvalue\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7951 var _lua_atpanic = Module[\"_lua_atpanic\"] = asm[\"_lua_atpanic\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7952 var _luaL_getmetafield = Module[\"_luaL_getmetafield\"] = asm[\"_luaL_getmetafield\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7953 var _lua_getinfo = Module[\"_lua_getinfo\"] = asm[\"_lua_getinfo\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7954 var _lua_gc = Module[\"_lua_gc\"] = asm[\"_lua_gc\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7955 var _lua_settop = Module[\"_lua_settop\"] = asm[\"_lua_settop\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7956 var _lua_pushboolean = Module[\"_lua_pushboolean\"] = asm[\"_lua_pushboolean\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7957 var _lua_setfield = Module[\"_lua_setfield\"] = asm[\"_lua_setfield\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7958 var _luaL_ref = Module[\"_luaL_ref\"] = asm[\"_luaL_ref\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7959 var _lua_next = Module[\"_lua_next\"] = asm[\"_lua_next\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7960 var _luaL_findtable = Module[\"_luaL_findtable\"] = asm[\"_luaL_findtable\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7961 var _luaL_checkudata = Module[\"_luaL_checkudata\"] = asm[\"_luaL_checkudata\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7962 var _realloc = Module[\"_realloc\"] = asm[\"_realloc\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7963 var _luaopen_table = Module[\"_luaopen_table\"] = asm[\"_luaopen_table\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7964 var _lua_setlevel = Module[\"_lua_setlevel\"] = asm[\"_lua_setlevel\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7965 var _luaL_loadfile = Module[\"_luaL_loadfile\"] = asm[\"_luaL_loadfile\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7966 var _lua_pushnumber = Module[\"_lua_pushnumber\"] = asm[\"_lua_pushnumber\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7967 var _lua_rawseti = Module[\"_lua_rawseti\"] = asm[\"_lua_rawseti\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7968 var _saveSetjmp = Module[\"_saveSetjmp\"] = asm[\"_saveSetjmp\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7969 var _luaL_optnumber = Module[\"_luaL_optnumber\"] = asm[\"_luaL_optnumber\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7970 var _lua_pushinteger = Module[\"_lua_pushinteger\"] = asm[\"_lua_pushinteger\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7971 var _lua_getallocf = Module[\"_lua_getallocf\"] = asm[\"_lua_getallocf\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7972 var _lua_dump = Module[\"_lua_dump\"] = asm[\"_lua_dump\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7973 var _lua_status = Module[\"_lua_status\"] = asm[\"_lua_status\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7974 var _luaL_where = Module[\"_luaL_where\"] = asm[\"_luaL_where\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7975 var _lua_cpcall = Module[\"_lua_cpcall\"] = asm[\"_lua_cpcall\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7976 var _luaL_error = Module[\"_luaL_error\"] = asm[\"_luaL_error\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7977 var _luaL_loadstring = Module[\"_luaL_loadstring\"] = asm[\"_luaL_loadstring\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7978 var _luaL_unref = Module[\"_luaL_unref\"] = asm[\"_luaL_unref\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7979 var runPostSets = Module[\"runPostSets\"] = asm[\"runPostSets\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7980 var dynCall_ii = Module[\"dynCall_ii\"] = asm[\"dynCall_ii\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7981 var dynCall_vi = Module[\"dynCall_vi\"] = asm[\"dynCall_vi\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7982 var dynCall_vii = Module[\"dynCall_vii\"] = asm[\"dynCall_vii\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7983 var dynCall_iiiii = Module[\"dynCall_iiiii\"] = asm[\"dynCall_iiiii\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7984 var dynCall_iiii = Module[\"dynCall_iiii\"] = asm[\"dynCall_iiii\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7985 var dynCall_v = Module[\"dynCall_v\"] = asm[\"dynCall_v\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7986 var dynCall_iii = Module[\"dynCall_iii\"] = asm[\"dynCall_iii\"];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7987 Runtime.stackAlloc = function(size) { return asm['stackAlloc'](size) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7988 Runtime.stackSave = function() { return asm['stackSave']() };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7989 Runtime.stackRestore = function(top) { asm['stackRestore'](top) };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7991 var i64Math = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7992 // === Auto-generated postamble setup entry stuff ===\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7993 function ExitStatus(status) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7994 this.name = \"ExitStatus\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7995 this.message = \"Program terminated with exit(\" + status + \")\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7996 this.status = status;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7997 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7998 ExitStatus.prototype = new Error();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7999 ExitStatus.prototype.constructor = ExitStatus;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8000 var initialStackTop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8001 var preloadStartTime = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8002 var calledMain = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8003 Module['callMain'] = Module.callMain = function callMain(args) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8004 assert(runDependencies == 0, 'cannot call main when async dependencies remain! (listen on __ATMAIN__)');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8005 assert(__ATPRERUN__.length == 0, 'cannot call main when preRun functions remain to be called');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8006 args = args || [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8007 if (ENVIRONMENT_IS_WEB && preloadStartTime !== null) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8008 Module.printErr('preload time: ' + (Date.now() - preloadStartTime) + ' ms');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8009 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8010 ensureInitRuntime();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8011 var argc = args.length+1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8012 function pad() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8013 for (var i = 0; i < 4-1; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8014 argv.push(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8015 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8016 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8017 var argv = [allocate(intArrayFromString(\"/bin/this.program\"), 'i8', ALLOC_NORMAL) ];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8018 pad();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8019 for (var i = 0; i < argc-1; i = i + 1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8020 argv.push(allocate(intArrayFromString(args[i]), 'i8', ALLOC_NORMAL));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8021 pad();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8022 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8023 argv.push(0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8024 argv = allocate(argv, 'i32', ALLOC_NORMAL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8025 initialStackTop = STACKTOP;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8026 try {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8027 var ret = Module['_main'](argc, argv, 0);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8028 // if we're not running an evented main loop, it's time to exit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8029 if (!Module['noExitRuntime']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8030 exit(ret);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8031 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8032 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8033 catch(e) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8034 if (e instanceof ExitStatus) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8035 // exit() throws this once it's done to make sure execution\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8036 // has been stopped completely\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8037 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8038 } else if (e == 'SimulateInfiniteLoop') {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8039 // running an evented main loop, don't immediately exit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8040 Module['noExitRuntime'] = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8041 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8042 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8043 throw e;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8044 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8045 } finally {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8046 calledMain = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8047 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8048 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8049 function run(args) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8050 args = args || Module['arguments'];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8051 if (preloadStartTime === null) preloadStartTime = Date.now();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8052 if (runDependencies > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8053 Module.printErr('run() called, but dependencies remain, so not running');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8054 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8055 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8056 preRun();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8057 if (runDependencies > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8058 // a preRun added a dependency, run will be called later\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8059 return;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8060 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8061 function doRun() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8062 ensureInitRuntime();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8063 preMain();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8064 calledRun = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8065 if (Module['_main'] && shouldRunNow) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8066 Module['callMain'](args);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8067 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8068 postRun();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8069 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8070 if (Module['setStatus']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8071 Module['setStatus']('Running...');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8072 setTimeout(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8073 setTimeout(function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8074 Module['setStatus']('');\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8075 }, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8076 if (!ABORT) doRun();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8077 }, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8078 } else {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8079 doRun();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8080 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8081 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8082 Module['run'] = Module.run = run;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8083 function exit(status) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8084 ABORT = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8085 EXITSTATUS = status;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8086 STACKTOP = initialStackTop;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8087 // exit the runtime\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8088 exitRuntime();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8089 // TODO We should handle this differently based on environment.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8090 // In the browser, the best we can do is throw an exception\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8091 // to halt execution, but in node we could process.exit and\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8092 // I'd imagine SM shell would have something equivalent.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8093 // This would let us set a proper exit status (which\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8094 // would be great for checking test exit statuses).\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8095 // https://github.com/kripken/emscripten/issues/1371\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8096 // throw an exception to halt the current execution\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8097 throw new ExitStatus(status);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8098 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8099 Module['exit'] = Module.exit = exit;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8100 function abort(text) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8101 if (text) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8102 Module.print(text);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8103 Module.printErr(text);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8104 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8105 ABORT = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8106 EXITSTATUS = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8107 throw 'abort() at ' + (new Error().stack);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8108 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8109 Module['abort'] = Module.abort = abort;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8110 // {{PRE_RUN_ADDITIONS}}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8111 if (Module['preInit']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8112 if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8113 while (Module['preInit'].length > 0) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8114 Module['preInit'].pop()();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8115 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8116 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8117 // shouldRunNow refers to calling main(), not run().\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8118 var shouldRunNow = true;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8119 if (Module['noInitialRun']) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8120 shouldRunNow = false;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8121 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8122 run();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8123 // {{POST_RUN_ADDITIONS}}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8124 // {{MODULE_ADDITIONS}}\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8125 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8126 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8127 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8128 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8129 var C = { };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8130 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8131 var F = Module.cwrap;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8132 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8133 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8134 // c_type.js: basic C \"types\" for Lua 5.1 C API cwraps (fragment file)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8135 // This file is a part of lua5.1.js project:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8136 // Copyright (c) LogicEditor <info@logiceditor.com>\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8137 // Copyright (c) lua5.1.js authors\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8138 // See file `COPYRIGHT` for the license\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8139 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8140 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8141 var void_t = null;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8142 var void_ptr_t = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8143 var void_ptr_t_ptr_t = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8144 var const_void_ptr_t = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8145 var int_t = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8146 var size_t_ptr_t = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8147 var size_t = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8148 var const_char_ptr_t = \"string\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8149 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8150 var NULL = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8151 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8152 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8153 // lua.h.js: Lua 5.1 C API, lua.h definitions (fragment file)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8154 // This file is a part of lua5.1.js project:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8155 // Copyright (c) LogicEditor <info@logiceditor.com>\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8156 // Copyright (c) lua5.1.js authors\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8157 // See file `COPYRIGHT` for the license\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8158 // Based on original Lua 5.1.5 header files:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8159 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8160 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8161 // Note: Keeping this file as close to Lua sources as possible.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8162 // This includes avoiding breaking lines at 80 char limit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8163 // to keep original formatting despite JS code being somewhat longer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8164 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8165 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8166 var lua_Number = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8167 var lua_Integer = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8168 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8169 C.LUA_VERSION = \"Lua 5.1\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8170 C.LUA_RELEASE = \"Lua 5.1.5\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8171 C.LUA_VERSION_NUM = 501;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8172 C.LUA_COPYRIGHT = \"Copyright (C) 1994-2012 Lua.org, PUC-Rio\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8173 C.LUA_AUTHORS = \"R. Ierusalimschy, L. H. de Figueiredo & W. Celes\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8174 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8175 /* mark for precompiled code (`<esc>Lua') */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8176 C.LUA_SIGNATURE = \"\\033Lua\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8177 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8178 /* option for multiple returns in `lua_pcall' and `lua_call' */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8179 C.LUA_MULTRET = (-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8180 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8181 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8182 ** pseudo-indices\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8183 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8184 C.LUA_REGISTRYINDEX = (-10000);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8185 C.LUA_ENVIRONINDEX = (-10001);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8186 C.LUA_GLOBALSINDEX = (-10002);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8187 C.lua_upvalueindex = function(i) { return (C.LUA_GLOBALSINDEX-(i)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8188 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8189 /* thread status; 0 is OK */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8190 C.LUA_YIELD = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8191 C.LUA_ERRRUN = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8192 C.LUA_ERRSYNTAX = 3;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8193 C.LUA_ERRMEM = 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8194 C.LUA_ERRERR = 5;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8195 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8196 var lua_State = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8197 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8198 // typedef int (*lua_CFunction) (lua_State *L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8199 var lua_CFunction = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8200 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8201 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8202 ** functions that read/write blocks when loading/dumping Lua chunks\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8203 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8204 // typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8205 var lua_Reader = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8206 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8207 // typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8208 var lua_Writer = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8209 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8210 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8211 ** prototype for memory-allocation functions\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8212 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8213 // typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8214 var lua_Alloc = \"number\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8215 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8216 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8217 ** basic types\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8218 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8219 C.LUA_TNONE = (-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8220 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8221 C.LUA_TNIL = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8222 C.LUA_TBOOLEAN = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8223 C.LUA_TLIGHTUSERDATA = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8224 C.LUA_TNUMBER = 3;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8225 C.LUA_TSTRING = 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8226 C.LUA_TTABLE = 5;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8227 C.LUA_TFUNCTION = 6;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8228 C.LUA_TUSERDATA = 7;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8229 C.LUA_TTHREAD = 8;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8230 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8231 /* minimum Lua stack available to a C function */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8232 C.LUA_MINSTACK = 20;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8233 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8234 /* type of numbers in Lua */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8235 var LUA_NUMBER = lua_Number;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8236 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8237 /* type for integer functions */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8238 var LUA_INTEGER = lua_Integer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8239 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8240 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8241 ** state manipulation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8242 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8243 C.lua_newstate = F(\"lua_newstate\", lua_State, [lua_Alloc, void_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8244 C.lua_close = F(\"lua_close\", void_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8245 C.lua_newthread = F(\"lua_newthread\", lua_State, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8246 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8247 C.lua_atpanic = F(\"lua_atpanic\", lua_CFunction, [lua_State, lua_CFunction]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8248 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8249 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8250 ** basic stack manipulation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8251 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8252 C.lua_gettop = F(\"lua_gettop\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8253 C.lua_settop = F(\"lua_settop\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8254 C.lua_pushvalue = F(\"lua_pushvalue\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8255 C.lua_remove = F(\"lua_remove\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8256 C.lua_insert = F(\"lua_insert\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8257 C.lua_replace = F(\"lua_replace\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8258 C.lua_checkstack = F(\"lua_checkstack\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8259 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8260 C.lua_xmove = F(\"lua_xmove\", void_t, [lua_State, lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8261 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8262 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8263 ** access functions (stack -> C)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8264 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8265 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8266 C.lua_isnumber = F(\"lua_isnumber\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8267 C.lua_isstring = F(\"lua_isstring\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8268 C.lua_iscfunction = F(\"lua_iscfunction\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8269 C.lua_isuserdata = F(\"lua_isuserdata\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8270 C.lua_type = F(\"lua_type\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8271 C.lua_typename = F(\"lua_typename\", const_char_ptr_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8272 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8273 C.lua_equal = F(\"lua_equal\", int_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8274 C.lua_rawequal = F(\"lua_rawequal\", int_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8275 C.lua_lessthan = F(\"lua_lessthan\", int_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8276 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8277 C.lua_tonumber = F(\"lua_tonumber\", lua_Number, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8278 C.lua_tointeger = F(\"lua_tointeger\", lua_Integer, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8279 C.lua_toboolean = F(\"lua_toboolean\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8281 C.lua_objlen = F(\"lua_objlen\", size_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8282 C.lua_tocfunction = F(\"lua_tocfunction\", lua_CFunction, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8283 C.lua_touserdata = F(\"lua_touserdata\", void_ptr_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8284 C.lua_tothread = F(\"lua_tothread\", lua_State, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8285 C.lua_topointer = F(\"lua_topointer\", const_void_ptr_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8286 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8287 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8288 ** push functions (C -> stack)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8289 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8290 C.lua_pushnil = F(\"lua_pushnil\", void_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8291 C.lua_pushnumber = F(\"lua_pushnumber\", void_t, [lua_State, lua_Number]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8292 C.lua_pushinteger = F(\"lua_pushinteger\", void_t, [lua_State, lua_Integer]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8294 C.lua_pushstring = F(\"lua_pushstring\", void_t, [lua_State, const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8295 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8296 // TODO: Support these.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8297 LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8298 va_list argp);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8299 LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8300 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8301 C.lua_pushcclosure = F(\"lua_pushcclosure\", void_t, [lua_State, lua_CFunction, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8302 C.lua_pushboolean = F(\"lua_pushboolean\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8303 C.lua_pushlightuserdata = F(\"lua_pushlightuserdata\", void_t, [lua_State, void_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8304 C.lua_pushthread = F(\"lua_pushthread\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8305 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8306 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8307 ** get functions (Lua -> stack)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8308 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8309 C.lua_gettable = F(\"lua_gettable\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8311 C.lua_rawget = F(\"lua_rawget\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8312 C.lua_rawgeti = F(\"lua_rawgeti\", void_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8313 C.lua_createtable = F(\"lua_createtable\", void_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8314 C.lua_newuserdata = F(\"lua_newuserdata\", void_ptr_t, [lua_State, size_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8315 C.lua_getmetatable = F(\"lua_getmetatable\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8316 C.lua_getfenv = F(\"lua_getfenv\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8317 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8318 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8319 ** set functions (stack -> Lua)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8320 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8321 C.lua_settable = F(\"lua_settable\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8323 C.lua_rawset = F(\"lua_rawset\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8324 C.lua_rawseti = F(\"lua_rawseti\", void_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8325 C.lua_setmetatable = F(\"lua_setmetatable\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8326 C.lua_setfenv = F(\"lua_setfenv\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8327 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8328 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8329 ** `load' and `call' functions (load and run Lua code)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8330 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8331 C.lua_call = F(\"lua_call\", void_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8333 C.lua_cpcall = F(\"lua_cpcall\", int_t, [lua_State, lua_CFunction, void_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8334 C.lua_load = F(\"lua_load\", int_t, [lua_State, lua_Reader, void_ptr_t,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8335 const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8336 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8337 C.lua_dump = F(\"lua_dump\", int_t, [lua_State, lua_Writer, void_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8338 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8339 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8340 ** coroutine functions\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8341 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8342 C.lua_yield = F(\"lua_yield\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8343 C.lua_resume = F(\"lua_resume\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8344 C.lua_status = F(\"lua_status\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8345 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8346 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8347 ** garbage-collection function and options\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8348 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8349 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8350 C.LUA_GCSTOP = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8351 C.LUA_GCRESTART = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8352 C.LUA_GCCOLLECT = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8353 C.LUA_GCCOUNT = 3;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8354 C.LUA_GCCOUNTB = 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8355 C.LUA_GCSTEP = 5;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8356 C.LUA_GCSETPAUSE = 6;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8357 C.LUA_GCSETSTEPMUL = 7;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8358 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8359 C.lua_gc = F(\"lua_gc\", int_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8360 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8361 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8362 ** miscellaneous functions\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8363 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8364 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8365 C.lua_error = F(\"lua_error\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8366 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8367 C.lua_next = F(\"lua_next\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8368 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8369 C.lua_concat = F(\"lua_concat\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8370 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8371 C.lua_getallocf = F(\"lua_getallocf\", lua_Alloc, [lua_State, void_ptr_t_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8372 C.lua_setallocf = F(\"lua_setallocf\", void_t, [lua_State, lua_Alloc, void_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8373 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8374 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8375 ** ===============================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8376 ** some useful macros\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8377 ** ===============================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8378 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8379 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8380 C.lua_pop = function(L,n) { return C.lua_settop(L, -(n)-1); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8381 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8382 C.lua_newtable = function(L) { return C.lua_createtable(L, 0, 0); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8383 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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))); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8385 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8386 C.lua_pushcfunction = function(L,f) { return C.lua_pushcclosure(L, (f), 0); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8387 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8388 C.lua_strlen = function(L,i) { return C.lua_objlen(L, (i)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8389 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8390 C.lua_isfunction = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TFUNCTION); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8391 C.lua_istable = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TTABLE); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8392 C.lua_islightuserdata = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TLIGHTUSERDATA); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8393 C.lua_isnil = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TNIL); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8394 C.lua_isboolean = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TBOOLEAN); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8395 C.lua_isthread = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TTHREAD); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8396 C.lua_isnone = function(L,n) { return (C.lua_type(L, (n)) == C.LUA_TNONE); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8397 C.lua_isnoneornil = function(L, n) { return (C.lua_type(L, (n)) <= 0); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8398 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8399 C.lua_pushliteral = C.lua_pushstring;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8400 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8401 C.lua_setglobal = function(L,s) { return C.lua_setfield(L, C.LUA_GLOBALSINDEX, (s)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8402 C.lua_getglobal = function(L,s) { return C.lua_getfield(L, C.LUA_GLOBALSINDEX, (s)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8403 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8404 C.lua_tostring = function(L,i) { return C.lua_tolstring(L, (i), NULL); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8405 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8406 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8407 ** compatibility macros and functions\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8408 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8409 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8410 C.lua_open = function() { return C.luaL_newstate(); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8411 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8412 C.lua_getregistry = function(L) { return C.lua_pushvalue(L, C.LUA_REGISTRYINDEX); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8413 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8414 C.lua_getgccount = function(L) { return C.lua_gc(L, C.LUA_GCCOUNT, 0); }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8415 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8416 var lua_Chunkreader = lua_Reader;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8417 var lua_Chunkwriter = lua_Writer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8418 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8419 /* hack */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8420 C.lua_setlevel = F(\"lua_setlevel\", void_t, [lua_State, lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8421 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8422 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8423 ** {======================================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8424 ** Debug API\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8425 ** =======================================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8426 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8427 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8428 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8429 ** Event codes\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8430 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8431 C.LUA_HOOKCALL = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8432 C.LUA_HOOKRET = 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8433 C.LUA_HOOKLINE = 2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8434 C.LUA_HOOKCOUNT = 3;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8435 C.LUA_HOOKTAILRET = 4;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8436 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8437 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8438 ** Event masks\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8439 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8440 C.LUA_MASKCALL = (1 << C.LUA_HOOKCALL);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8441 C.LUA_MASKRET = (1 << C.LUA_HOOKRET);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8442 C.LUA_MASKLINE = (1 << C.LUA_HOOKLINE);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8443 C.LUA_MASKCOUNT = (1 << C.LUA_HOOKCOUNT);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8444 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8445 // TODO: Support these. (Note LUA_IDSIZE.)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8446 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8447 typedef struct lua_Debug lua_Debug; /* activation record * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8448 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8449 /* Functions to be called by the debuger in specific events * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8450 typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8451 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8452 LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8453 LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8454 LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8455 LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8456 LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8457 LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8458 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8459 LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8460 LUA_API lua_Hook lua_gethook (lua_State *L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8461 LUA_API int lua_gethookmask (lua_State *L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8462 LUA_API int lua_gethookcount (lua_State *L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8463 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8464 struct lua_Debug {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8465 int event;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8466 const char *name; /* (n) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8467 const char *namewhat; /* (n) `global', `local', `field', `method' * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8468 const char *what; /* (S) `Lua', `C', `main', `tail' * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8469 const char *source; /* (S) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8470 int currentline; /* (l) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8471 int nups; /* (u) number of upvalues * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8472 int linedefined; /* (S) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8473 int lastlinedefined; /* (S) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8474 char short_src[LUA_IDSIZE]; /* (S) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8475 /* private part * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8476 int i_ci; /* active function * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8477 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8478 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8479 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8480 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8481 // lualib.h.js: Lua 5.1 C API, lualib.h definitions (fragment file)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8482 // This file is a part of lua5.1.js project:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8483 // Copyright (c) LogicEditor <info@logiceditor.com>\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8484 // Copyright (c) lua5.1.js authors\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8485 // See file `COPYRIGHT` for the license\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8486 // Based on original Lua 5.1.5 header files:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8487 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8488 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8489 // Note: Keeping this file as close to Lua sources as possible.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8490 // This includes avoiding breaking lines at 80 char limit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8491 // to keep original formatting despite JS code being somewhat longer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8492 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8493 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8494 /* Key to file-handle type */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8495 C.LUA_FILEHANDLE = \"FILE*\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8496 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8497 C.LUA_COLIBNAME = \"coroutine\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8498 C.luaopen_base = F(\"luaopen_base\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8499 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8500 C.LUA_TABLIBNAME = \"table\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8501 C.luaopen_table = F(\"luaopen_table\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8502 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8503 C.LUA_IOLIBNAME = \"io\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8504 C.luaopen_io = F(\"luaopen_io\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8505 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8506 C.LUA_OSLIBNAME = \"os\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8507 C.luaopen_os = F(\"luaopen_os\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8508 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8509 C.LUA_STRLIBNAME = \"string\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8510 C.luaopen_string = F(\"luaopen_string\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8511 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8512 C.LUA_MATHLIBNAME = \"math\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8513 C.luaopen_math = F(\"luaopen_math\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8514 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8515 C.LUA_DBLIBNAME = \"debug\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8516 C.luaopen_debug = F(\"luaopen_debug\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8517 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8518 C.LUA_LOADLIBNAME = \"package\";\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8519 C.luaopen_package = F(\"luaopen_package\", int_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8520 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8521 /* open all previous libraries */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8522 C.luaL_openlibs = F(\"luaL_openlibs\", void_t, [lua_State]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8523 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8524 C.lua_assert = function() { }; // Do nothing.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8525 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8526 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8527 // lauxlib.h.js: Lua 5.1 C API, lauxlib.h definitions (fragment file)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8528 // This file is a part of lua5.1.js project:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8529 // Copyright (c) LogicEditor <info@logiceditor.com>\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8530 // Copyright (c) lua5.1.js authors\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8531 // See file `COPYRIGHT` for the license\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8532 // Based on original Lua 5.1.5 header files:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8533 // Copyright (c) 1994-2012 Lua.org, PUC-Rio\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8534 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8535 // Note: Keeping this file as close to Lua sources as possible.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8536 // This includes avoiding breaking lines at 80 char limit\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8537 // to keep original formatting despite JS code being somewhat longer.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8538 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8539 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8540 C.luaL_getn = function(L,i) { return C.lua_objlen(L, i); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8541 C.luaL_setn = function(L,i,j) { }; /* no op! */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8542 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8543 // C.luaI_openlib defined below\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8544 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8545 /* extra error code for `luaL_load' */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8546 C.LUA_ERRFILE = (C.LUA_ERRERR+1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8547 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8548 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8549 // TODO: Support these.\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8550 typedef struct luaL_Reg {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8551 const char *name;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8552 lua_CFunction func;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8553 } luaL_Reg;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8554 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8555 LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8556 const luaL_Reg *l, int nup);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8557 LUALIB_API void (luaL_register) (lua_State *L, const char *libname,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8558 const luaL_Reg *l);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8559 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8560 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8565 C.luaL_checklstring = F(\"luaL_checklstring\", const_char_ptr_t, [lua_State, int_t,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8566 size_t_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8567 C.luaL_optlstring = F(\"luaL_optlstring\", const_char_ptr_t, [lua_State, int_t,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8568 const_char_ptr_t, size_t_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8569 C.luaL_checknumber = F(\"luaL_checknumber\", lua_Number, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8570 C.luaL_optnumber = F(\"luaL_optnumber\", lua_Number, [lua_State, int_t, lua_Number]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8571 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8572 C.luaL_checkinteger = F(\"luaL_checkinteger\", lua_Integer, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8573 C.luaL_optinteger = F(\"luaL_optinteger\", lua_Integer, [lua_State, int_t,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8574 lua_Integer]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8575 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8577 C.luaL_checktype = F(\"luaL_checktype\", void_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8578 C.luaL_checkany = F(\"luaL_checkany\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8579 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8580 C.luaL_newmetatable = F(\"luaL_newmetatable\", int_t, [lua_State, const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8582 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8583 C.luaL_where = F(\"luaL_where\", void_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8584 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8585 // TODO: Support these\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8586 LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8587 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8588 LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8589 const char *const lst[]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8590 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8591 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8592 C.luaL_ref = F(\"luaL_ref\", int_t, [lua_State, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8593 C.luaL_unref = F(\"luaL_unref\", void_t, [lua_State, int_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8594 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8595 C.luaL_loadfile = F(\"luaL_loadfile\", int_t, [lua_State, const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8597 const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8598 C.luaL_loadstring = F(\"luaL_loadstring\", int_t, [lua_State, const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8599 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8600 C.luaL_newstate = F(\"luaL_newstate\", lua_State, []);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8601 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8602 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8604 const_char_ptr_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8605 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8606 C.luaL_findtable = F(\"luaL_findtable\", const_char_ptr_t, [lua_State, int_t,\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8607 const_char_ptr_t, int_t]);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8608 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8609 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8610 ** ===============================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8611 ** some useful macros\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8612 ** ===============================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8613 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8614 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8615 C.luaL_argcheck = function(L, cond,numarg,extramsg) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8616 if (!cond) { C.luaL_argerror(L, (numarg), (extramsg)); } };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8617 C.luaL_checkstring = function(L,n) { return C.luaL_checklstring(L, (n), NULL); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8618 C.luaL_optstring = function(L,n,d) { return C.luaL_optlstring(L, (n), (d), NULL); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8619 C.luaL_checkint = C.luaL_checkinteger;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8620 C.luaL_optint = C.luaL_optinteger;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8621 C.luaL_checklong = C.luaL_checkinteger;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8622 C.luaL_optlong = C.luaL_optinteger;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8623 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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))); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8625 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8626 C.luaL_dofile = function(L, fn) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8627 return (C.luaL_loadfile(L, fn) || C.lua_pcall(L, 0, C.LUA_MULTRET, 0)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8628 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8629 C.luaL_dostring = function(L, s) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8630 return (C.luaL_loadstring(L, s) || C.lua_pcall(L, 0, C.LUA_MULTRET, 0)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8631 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8632 C.luaL_getmetatable = function(L,n) { return (C.lua_getfield(L, C.LUA_REGISTRYINDEX, (n))); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8633 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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))); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8635 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8636 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8637 ** {======================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8638 ** Generic Buffer manipulation\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8639 ** =======================================================\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8640 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8641 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8642 /*\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8643 // TODO: Support these\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8644 typedef struct luaL_Buffer {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8645 char *p; /* current position in buffer * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8646 int lvl; /* number of strings in the stack (level) * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8647 lua_State *L;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8648 char buffer[LUAL_BUFFERSIZE];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8649 } luaL_Buffer;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8650 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8651 #define luaL_addchar(B,c) \\\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8652 ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \\\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8653 (*(B)->p++ = (char)(c)))\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8654 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8655 /* compatibility only * /\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8656 #define luaL_putchar(B,c) luaL_addchar(B,c)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8657 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8658 #define luaL_addsize(B,n) ((B)->p += (n))\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8659 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8660 LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8661 LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8662 LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8663 LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8664 LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8665 LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8666 */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8667 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8668 /* }====================================================== */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8669 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8670 /* compatibility with ref system */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8671 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8672 /* pre-defined references */\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8673 C.LUA_NOREF = (-2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8674 C.LUA_REFNIL = (-1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8675 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8676 C.lua_ref = function(L,lock)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8677 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8678 if (lock)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8679 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8680 return C.luaL_ref(L, C.LUA_REGISTRYINDEX);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8681 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8682 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8683 C.lua_pushstring(L, \"unlocked references are obsolete\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8684 C.lua_error(L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8685 return 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8686 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8687 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8688 C.lua_unref = function(L,ref) { return C.luaL_unref(L, C.LUA_REGISTRYINDEX, (ref)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8689 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8690 C.lua_getref = function(L,ref) { return C.lua_rawgeti(L, C.LUA_REGISTRYINDEX, (ref)); };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8691 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8692 C.luaL_reg = C.luaL_Reg;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8693 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8694 ////////////////////////////////////////////////////////////////////////////////\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8695 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8696 Lua5_1.C = C;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8697 Lua5_1.Runtime = Runtime;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8698 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8699 Lua5_1.provide_file = function(parent, name, data, can_read, can_write)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8700 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8701 if (typeof(parent) === \"string\" && parent !== \"/\")\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8702 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8703 if (parent.charAt(0) !== \"/\")\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8704 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8705 throw new Error(\"can't create relative path: `\" + parent + \"'\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8706 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8707 parent = parent.substr(1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8708 parent = FS.createPath(\"/\", parent, true, true);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8709 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8710 return FS.createDataFile(parent, name, data, can_read, can_write);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8711 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8712 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8713 })(Lua5_1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8714 "e["LuaState.js"]="LuaState = (function () {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8715 var C = Lua5_1.C;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8716 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8717 function push_jsfunction(L, func, return_type, args) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8718 var arg_getters = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8719 for(var i = 0; i < args.length; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8720 arg_getters.push(\"C.luaL_check\"+args[i]+\"(L, \"+(i+1)+\")\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8721 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8722 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8723 var wrapper = eval(\"(function (func, return_type) { return (function (L) { \\\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8724 var ret = func(\"+arg_getters.join(\", \")+\"); \\\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8725 C.lua_push\"+return_type+\"(L, ret); \\\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8726 return 1; \\\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8727 }); })\")(func, return_type);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8728 C.lua_pushcfunction(L, Lua5_1.Runtime.addFunction(wrapper));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8729 return 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8730 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8731 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8732 function push_jsobject(L, obj) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8733 C.lua_newtable(L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8734 for (var key in obj) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8735 var val = obj[key];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8736 if (obj.hasOwnProperty(key)) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8737 switch(typeof val) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8738 case \"string\":\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8739 C.lua_pushstring(L, val);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8740 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8741 case \"number\":\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8742 C.lua_pushnumber(L, val);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8743 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8744 case \"object\":\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8745 push_jsobject(L, val);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8746 break;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8747 default:\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8748 C.luaL_pushfstring(L, \"Unable to convert field '%s' from type '%s'\", key, typeof val);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8749 return C.lua_error(L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8750 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8751 C.lua_setfield(L, key, -2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8752 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8753 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8754 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8755 // TODO: metatable for __index if obj.constructor !== Object?\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8756 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8757 return 1;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8758 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8759 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8760 function JSFunction(L) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8761 var funcname = C.luaL_checkstring(L, 1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8762 var ret = C.luaL_checkstring(L, 2);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8763 var n_args = C.lua_gettop(L)-2;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8764 var args = [];\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8765 for(var i = 0; i < n_args; i++) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8766 args.push(C.luaL_checkstring(L, i+3));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8767 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8768 var func = eval(funcname);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8769 if(funcname.indexOf(\".\")!=-1) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8770 func = func.bind(eval(funcname.substr(0, funcname.lastIndexOf(\".\"))));\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8771 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8772 return push_jsfunction(L, func, ret, args);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8773 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8774 var JSFunction_ptr = Lua5_1.Runtime.addFunction(JSFunction);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8775 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8776 return (function() {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8777 var L = C.lua_open();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8778 C.luaL_openlibs(L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8779 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8780 C.lua_pushcfunction(L, JSFunction_ptr);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8781 C.lua_setglobal(L, \"JSFunction\");\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8782 \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8783 return {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8784 run: function (s) {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8785 if(L == 0) throw new Error(\"Lua state is invalid\"); // FIXME\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8786 if (C.luaL_dostring(L, s) != 0)\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8787 {\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8788 var err = C.lua_tostring(L, -1);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8789 C.lua_close(L);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8790 L = 0;\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8791 throw new Error(\"Lua error: \" + err);\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8792 } \ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8793 }\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8794 };\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8795 });\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8796 })();\ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8798 pcall(require,"luarocks.require"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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"} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8800 local e={use_http=false}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8801 for t,a in ipairs(arg)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8802 if a:match("^%-")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8803 local t=a:match("^%-%-?([^%s=]+)()") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8804 t=(o[t]or t):gsub("%-+","_"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8805 if t:match("^no_")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8806 t=t:sub(4,-1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8807 e[t]=false; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8808 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8809 e[t]=a:match("=(.*)$")or true; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8810 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8811 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8812 base_path=a; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8813 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8814 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8815 if e.very_verbose then e.verbose=true;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8816 if e.very_quiet then e.quiet=true;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8817 local t=function()end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8818 local t,o,h,s=t,t,t,t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8819 if not e.very_quiet then t=print;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8820 if not e.quiet then o=print;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8821 if e.verbose or e.very_verbose then h=print;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8822 if e.very_verbose then s=print;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8823 print=h; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8824 local i,d,n={},{},{}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8825 function Module(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8826 if i[e]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8827 h("Ignoring duplicate module definition for "..e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8828 return function()end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8829 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8830 local t=#i+1; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8831 i[t]={name=e,url=___fetch_url}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8832 i[e]=i[t]; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8833 return function(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8834 i[t].path=e; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8835 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8836 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8837 function Resource(e,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8838 local t=#n+1; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8839 n[t]={name=e,path=a or e}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8840 return function(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8841 n[t].path=e; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8842 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8843 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8844 function AutoFetchURL(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8845 ___fetch_url=e; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8846 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8847 function Main(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8848 table.insert(d,e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8849 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8850 function Output(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8851 if e.output==nil then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8852 out_fn=t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8853 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8854 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8855 function Option(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8856 t=t:gsub("%-","_"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8857 if e[t]==nil then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8858 e[t]=true; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8859 return function(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8860 e[t]=a; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8861 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8862 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8863 return function()end; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8864 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8865 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8866 function GetOption(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8867 return e[t:gsub('%-','_')]; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8868 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8869 function Message(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8870 if not e.quiet then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8871 o(t); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8872 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8873 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8874 function Error(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8875 if not e.very_quiet then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8876 t(a); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8877 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8878 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8879 function Exit() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8880 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8881 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8882 base_path=(base_path or"."):gsub("/$","").."/" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8883 squishy_file=base_path.."squishy"; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8884 out_fn=e.output; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8885 local a,r=pcall(dofile,squishy_file); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8886 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8887 t("Couldn't read squishy file: "..r); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8888 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8889 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8890 if not out_fn then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8891 t("No output file specified by user or squishy file"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8892 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8893 elseif#d==0 and#i==0 and#n==0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8894 t("No files, modules or resources. Not going to generate an empty file."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8895 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8896 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8897 local r={}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8898 function r.filesystem(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8899 local e,t=io.open(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8900 if not e then return false,t;end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8901 local t=e:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8902 e:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8903 return t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8904 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8905 if e.use_http then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8906 function r.http(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8907 local t=require"socket.http"; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8908 local t,e=t.request(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8909 if e==200 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8910 return t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8911 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8912 return false,"HTTP status code: "..tostring(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8913 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8914 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8915 function r.http(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8917 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8918 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8919 h("Resolving modules..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8920 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8921 local e=package.config:sub(1,1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8922 local n=package.config:sub(5,5); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8923 local o=package.path:gsub("[^;]+",function(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8924 if not t:match("^%"..e)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8925 return base_path..t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8926 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8927 end):gsub("/%./","/"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8928 local a=package.cpath:gsub("[^;]+",function(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8929 if not t:match("^%"..e)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8930 return base_path..t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8931 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8932 end):gsub("/%./","/"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8933 function resolve_module(t,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8934 t=t:gsub("%.",e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8935 for e in a:gmatch("[^;]+")do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8936 e=e:gsub("%"..n,t); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8937 s("Looking for "..e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8938 local t=io.open(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8939 if t then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8940 s("Found!"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8941 t:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8942 return e; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8943 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8944 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8945 return nil; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8946 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8947 for a,e in ipairs(i)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8948 if not e.path then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8949 e.path=resolve_module(e.name,o); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8950 if not e.path then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8951 t("Couldn't resolve module: "..e.name); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8952 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8953 e.path=e.path:gsub("^"..base_path:gsub("%p","%%%1"),""); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8954 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8955 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8956 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8957 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8958 for a,e in ipairs(i)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8959 if not e.path then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8960 t("Exiting due to missing modules without a path"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8961 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8962 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8963 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8964 if e.list_files or e.list_missing_files then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8965 local function t(t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8966 if e.list_missing_files then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8967 local e=io.open(t); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8968 if e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8969 e:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8970 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8971 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8972 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8973 io.write(t,"\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8974 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8975 for a,e in pairs(d)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8976 t(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8977 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8978 for a,e in ipairs(i)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8979 t(e.path); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8980 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8981 for a,e in ipairs(n)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8982 t(e.path); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8983 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8984 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8985 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8986 o("Writing "..out_fn.."..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8987 local a,l=io.open(out_fn,"w+"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8988 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8989 t("Couldn't open output file: "..tostring(l)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8990 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8991 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8992 if e.executable then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8993 if e.executable==true then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8994 a:write("#!/usr/bin/env lua\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8995 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8996 a:write(e.executable,"\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8997 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8998 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8999 h("Packing modules..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9000 for o,i in ipairs(i)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9001 local h,d=i.name,i.path; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9002 if i.path:sub(1,1)~="/"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9003 d=base_path..i.path; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9004 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9005 s("Packing "..h.." ("..d..")..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9006 local o,n=r.filesystem(d); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9007 if(not o)and i.url then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9008 local e=i.url:gsub("%?",i.path); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9009 s("Fetching: "..e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9010 if e:match("^https?://")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9011 o,n=r.http(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9012 elseif e:match("^file://")or e:match("^[/%.]")then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9013 local e,t=io.open((e:gsub("^file://",""))); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9014 if e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9015 o,n=e:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9016 e:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9017 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9018 o,n=nil,t; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9019 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9020 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9021 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9022 if o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9023 o=o:gsub("^#[^\r\n]*\r?\n",""); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9024 if not e.debug then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9025 a:write("package.preload['",h,"'] = (function (...)\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9026 a:write(o); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9027 a:write(" end)\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9028 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9029 a:write("package.preload['",h,"'] = assert(loadstring(\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9030 a:write(("%q\n"):format(o)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9031 a:write(", ",("%q"):format("@"..d),"))\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9032 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9033 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9034 t("Couldn't pack module '"..h.."': "..(n or"unknown error... path to module file correct?")); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9035 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9036 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9037 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9038 if#n>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9039 h("Packing resources...") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9040 a:write("do local resources = {};\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9041 for o,e in ipairs(n)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9042 local o,e=e.name,e.path; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9043 local e,i=io.open(base_path..e,"rb"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9044 if not e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9045 t("Couldn't load resource: "..tostring(i)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9046 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9047 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9048 local t=e:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9049 local e=0; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9050 t:gsub("(=+)",function(t)e=math.max(e,#t);end); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9051 a:write(("resources[%q] = %q"):format(o,t)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9052 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9053 if e.virtual_io then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9054 local e=require_resource("vio"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9055 if not e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9056 t("Virtual IO requested but is not enabled in this build of squish"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9057 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9058 a:write(e,"\n") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9060 if not resources[fn] then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9061 return io_open(fn, mode); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9062 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9063 return vio.open(resources[fn]); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9064 end end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9065 function io.lines(fn) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9066 if not resources[fn] then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9067 return io_lines(fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9068 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9069 return vio.open(resources[fn]):lines() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9070 end end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9071 local _dofile = dofile; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9072 function dofile(fn) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9073 if not resources[fn] then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9074 return _dofile(fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9075 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9076 return assert(loadstring(resources[fn]))(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9077 end end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9078 local _loadfile = loadfile; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9079 function loadfile(fn) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9080 if not resources[fn] then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9081 return _loadfile(fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9082 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9083 return loadstring(resources[fn], "@"..fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9084 end end ]] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9085 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9086 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 ]] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9088 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9089 s("Finalising...") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9090 for e,o in pairs(d)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9091 local e,i=io.open(base_path..o); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9092 if not e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9093 t("Failed to open "..o..": "..i); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9094 os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9095 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9096 a:write((e:read("*a"):gsub("^#.-\n",""))); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9097 e:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9098 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9099 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9100 a:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9101 o("OK!"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9102 local s=require"optlex" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9103 local h=require"optparser" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9104 local a=require"llex" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9105 local r=require"lparser" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9106 local i={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9107 none={}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9108 debug={"whitespace","locals","entropy","comments","numbers"}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9109 default={"comments","whitespace","emptylines","numbers","locals"}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9110 basic={"comments","whitespace","emptylines"}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9111 full={"comments","whitespace","emptylines","eols","strings","numbers","locals","entropy"}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9112 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9113 if e.minify_level and not i[e.minify_level]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9114 t("Unknown minify level: "..e.minify_level); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9115 t("Available minify levels: none, basic, default, full, debug"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9116 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9117 for a,t in ipairs(i[e.minify_level or"default"]or{})do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9118 if e["minify_"..t]==nil then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9119 e["minify_"..t]=true; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9120 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9121 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9122 local n={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9123 ["opt-locals"]=e.minify_locals; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9124 ["opt-comments"]=e.minify_comments; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9125 ["opt-entropy"]=e.minify_entropy; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9126 ["opt-whitespace"]=e.minify_whitespace; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9127 ["opt-emptylines"]=e.minify_emptylines; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9128 ["opt-eols"]=e.minify_eols; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9129 ["opt-strings"]=e.minify_strings; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9130 ["opt-numbers"]=e.minify_numbers; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9131 } |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9132 local function i(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9133 t("minify: "..e);os.exit(1); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9134 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9135 local function l(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9136 local t=io.open(e,"rb") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9137 if not t then i("cannot open \""..e.."\" for reading")end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9138 local a=t:read("*a") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9139 if not a then i("cannot read from \""..e.."\"")end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9140 t:close() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9141 return a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9142 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9143 local function d(e,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9144 local t=io.open(e,"wb") |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9145 if not t then i("cannot open \""..e.."\" for writing")end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9146 local a=t:write(a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9147 if not a then i("cannot write to \""..e.."\"")end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9148 t:close() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9149 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9150 function minify_string(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9151 a.init(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9152 a.llex() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9153 local t,e,a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9154 =a.tok,a.seminfo,a.tokln |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9155 if n["opt-locals"]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9156 h.print=print |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9157 r.init(t,e,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9158 local o,a=r.parser() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9159 h.optimize(n,t,e,o,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9160 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9161 s.print=print |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9162 t,e,a |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9163 =s.optimize(n,t,e,a) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9164 local e=table.concat(e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9165 if string.find(e,"\r\n",1,1)or |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9166 string.find(e,"\n\r",1,1)then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9167 s.warn.mixedeol=true |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9168 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9169 return e; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9170 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9171 function minify_file(e,t) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9172 local e=l(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9173 e=minify_string(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9174 d(t,e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9175 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9176 if e.minify~=false then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9177 o("Minifying "..out_fn.."..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9178 minify_file(out_fn,out_fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9179 o("OK!"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9180 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9181 local s=require"llex" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9182 local i=128; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9183 local n={"and","break","do","else","elseif", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9184 "end","false","for","function","if", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9185 "in","local","nil","not","or","repeat", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9186 "return","then","true","until","while"} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9187 function uglify_file(l,o) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9188 local h,a=io.open(l); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9189 if not h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9190 t("Can't open input file for reading: "..tostring(a)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9191 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9192 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9193 local a,r=io.open(o..".uglified","wb+"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9194 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9195 t("Can't open output file for writing: "..tostring(r)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9196 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9197 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9198 local d=h:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9199 h:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9200 local h,t=d:match("^(#.-\n)(.+)$"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9201 local t=t or d; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9202 if h then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9203 a:write(h) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9204 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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 |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9206 i=i+1; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9207 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9208 if i+#n>255 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9209 a:write(t); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9210 a:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9211 os.rename(o..".uglified",o); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9212 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9213 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9214 local r={} |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9215 for e,t in ipairs(n)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9216 r[t]=string.char(i+e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9217 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9218 local h=0; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9219 d:gsub("(=+)",function(e)h=math.max(h,#e);end); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9220 s.init(t,"@"..l); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9221 s.llex() |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9222 local t=s.seminfo; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9223 if e.uglify_level=="full"and i+#n<255 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9224 local e={}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9225 for i,o in ipairs(s.tok)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9226 if o=="TK_NAME"or o=="TK_STRING"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9227 local a=string.format("%q,%q",o,t[i]); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9228 if not e[a]then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9229 e[a]={type=o,value=t[i],count=0}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9230 e[#e+1]=e[a]; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9231 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9232 e[a].count=e[a].count+1; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9233 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9234 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9235 for t=1,#e do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9236 local e=e[t]; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9237 e.score=(e.count)*(#e.value-1)-#string.format("%q",e.value)-1; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9238 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9239 table.sort(e,function(t,e)return t.score>e.score;end); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9240 local t=255-(i+#n); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9241 for t=t+1,#e do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9242 e[t]=nil; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9243 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9244 local t=#n; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9245 for a,e in ipairs(e)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9246 if e.score>0 then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9247 table.insert(n,e.value); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9248 r[e.value]=string.char(i+t+a); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9249 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9250 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9251 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9252 a:write("local base_char,keywords=",tostring(i),",{"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9253 for t,e in ipairs(n)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9254 a:write(string.format("%q",e),','); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9255 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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).."]", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9257 function (c) return keywords[c:byte()-base_char]; end) end ]] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9258 a:write[[return assert(loadstring(prettify]] |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9259 a:write("[",string.rep("=",h+1),"["); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9260 for o,e in ipairs(s.tok)do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9261 if e=="TK_KEYWORD"or e=="TK_NAME"or e=="TK_STRING"then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9262 local e=r[t[o]]; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9263 if e then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9264 a:write(e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9265 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9266 a:write(t[o]); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9267 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9268 else |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9269 a:write(t[o]); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9270 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9271 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9272 a:write("]",string.rep("=",h+1),"]"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9273 a:write(", '@",o,"'))()"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9274 a:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9275 os.rename(o..".uglified",o); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9276 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9277 if e.uglify then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9278 o("Uglifying "..out_fn.."..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9279 uglify_file(out_fn,out_fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9280 o("OK!"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9281 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9282 function gzip_file(a,e) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9283 local o,a=io.open(a); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9284 if not o then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9285 t("Can't open input file for reading: "..tostring(a)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9286 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9287 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9288 local a,i=io.open(e..".gzipped","wb+"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9289 if not a then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9290 t("Can't open output file for writing: "..tostring(i)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9291 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9292 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9293 local i=o:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9294 o:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9295 local n,o=i:match("^(#.-\n)(.+)$"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9296 local o=o or i; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9297 if n then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9298 a:write(n) |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9299 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9300 local i,n=io.open(e..".pregzip","wb+"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9301 if not i then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9302 t("Can't open temp file for writing: "..tostring(n)); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9303 return; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9304 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9305 i:write(o); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9306 i:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9307 local t=io.popen("gzip -c '"..e..".pregzip'"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9308 o=t:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9309 t:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9310 os.remove(e..".pregzip"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9311 local t=0; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9312 o:gsub("(=+)",function(e)t=math.max(t,#e);end); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9313 a:write("local ungz = (function ()",require_resource"gunzip.lua"," end)()\n"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
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) ]]; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9315 a:write((string.format("%q",o):gsub("\026","\\026"))); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9316 a:write(", '@",e,"'))()"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9317 a:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9318 os.rename(e..".gzipped",e); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9319 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9320 if e.gzip then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9321 o("Gzipping "..out_fn.."..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9322 gzip_file(out_fn,out_fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9323 o("OK!"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9324 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9325 if e.js then |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9326 o("Generating Javascript for "..out_fn.."..."); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9327 local e={ |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9328 ["\""]="\\\"",["\\"]="\\\\",["\b"]="\\b", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9329 ["\f"]="\\f",["\n"]="\\\n",["\r"]="\\r",["\t"]="\\t"}; |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9330 for t=0,31 do |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9331 local a=string.char(t); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9332 if not e[a]then e[a]=("\\u%.4X"):format(t);end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9333 end |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9334 local t=io.open(out_fn); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9335 local a=t:read("*a"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9336 t:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9337 local t=io.open(out_fn,"w+"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9338 t:write("(function(){\n", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9339 require_resource("lua5.1.min.js"),"\n", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9340 require_resource("LuaState.js"),"\n", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9341 "LuaState().run(\""..a:gsub(".",e).."\")\n", |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9342 "})()" |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9343 ); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9344 t:close(); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9345 o("OK!"); |
75e7917761c0
Makefile, buildscripts/squish: Add Makefile and squish to the repo
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9346 end |