##// END OF EJS Templates
Removing unnecessary returns
naryl -
r27:944c8b3e default
parent child Browse files
Show More
@@ -1,9 +1,5 b''
1
1
2 * Use Parenscript's packages
3 * Use Parenscript's minifier
4 * Remove dots
5 * MENU with async/await
2 * MENU with async/await
6 * Find a way to minify syntax (extra returns at least)
7 * Special locations
3 * Special locations
8 * Special variables
4 * Special variables
9 * CLI build for Linux
5 * CLI build for Linux
@@ -125,7 +125,7 b''
125 (defun enable-frame (key enable)
125 (defun enable-frame (key enable)
126 (let ((obj (get-frame key)))
126 (let ((obj (get-frame key)))
127 (setf (@ obj style display) (if enable "block" "none"))
127 (setf (@ obj style display) (if enable "block" "none"))
128 (values)))
128 (void)))
129
129
130 ;;; Actions
130 ;;; Actions
131
131
@@ -167,7 +167,7 b''
167 (setf (@ this indexes) (create))
167 (setf (@ this indexes) (create))
168 ;; From numbers to {num: 0, str: ""} objects
168 ;; From numbers to {num: 0, str: ""} objects
169 (setf (@ this values) (list))
169 (setf (@ this values) (list))
170 (values))
170 (void))
171
171
172 (defun new-value ()
172 (defun new-value ()
173 (create :num 0 :str ""))
173 (create :num 0 :str ""))
@@ -202,7 +202,7 b''
202 (setf (getprop (@ this values)
202 (setf (getprop (@ this values)
203 (chain this (index-num index))
203 (chain this (index-num index))
204 slot) value)
204 slot) value)
205 (values)))
205 (void)))
206
206
207 (setf (@ *var prototype kill)
207 (setf (@ *var prototype kill)
208 (lambda (index)
208 (lambda (index)
@@ -220,7 +220,7 b''
220 (defun ensure-var (name)
220 (defun ensure-var (name)
221 (let ((store (var-ref name)))
221 (let ((store (var-ref name)))
222 (unless store
222 (unless store
223 (setf store (new (-var name)))
223 (setf store (new (*var name)))
224 (setf (getprop (root vars) name) store))
224 (setf (getprop (root vars) name) store))
225 store))
225 store))
226
226
@@ -237,7 +237,7 b''
237
237
238 (defun set-var (name index slot value)
238 (defun set-var (name index slot value)
239 (chain (ensure-var name) (set index slot value))
239 (chain (ensure-var name) (set index slot value))
240 (values))
240 (void))
241
241
242 (defun get-array (name)
242 (defun get-array (name)
243 (var-ref name))
243 (var-ref name))
@@ -246,13 +246,13 b''
246 (let ((store (var-ref name)))
246 (let ((store (var-ref name)))
247 (setf (@ store values) (@ value values))
247 (setf (@ store values) (@ value values))
248 (setf (@ store indexes) (@ value indexes)))
248 (setf (@ store indexes) (@ value indexes)))
249 (values))
249 (void))
250
250
251 (defun kill-var (name &optional index)
251 (defun kill-var (name &optional index)
252 (if (and index (not (= 0 index)))
252 (if (and index (not (= 0 index)))
253 (chain (getprop (root vars) name) (kill index))
253 (chain (getprop (root vars) name) (kill index))
254 (delete (getprop (root vars) name)))
254 (delete (getprop (root vars) name)))
255 (values))
255 (void))
256
256
257 (defun array-size (name)
257 (defun array-size (name)
258 (getprop (var-ref name) 'length))
258 (getprop (var-ref name) 'length))
@@ -261,11 +261,11 b''
261
261
262 (defun push-local-frame ()
262 (defun push-local-frame ()
263 (chain (root locals) (push (create)))
263 (chain (root locals) (push (create)))
264 (values))
264 (void))
265
265
266 (defun pop-local-frame ()
266 (defun pop-local-frame ()
267 (chain (root locals) (pop))
267 (chain (root locals) (pop))
268 (values))
268 (void))
269
269
270 (defun current-local-frame ()
270 (defun current-local-frame ()
271 (elt (root locals) (1- (length (root locals)))))
271 (elt (root locals) (1- (length (root locals)))))
@@ -274,7 +274,7 b''
274 (let ((frame (current-local-frame)))
274 (let ((frame (current-local-frame)))
275 (unless (in name frame)
275 (unless (in name frame)
276 (setf (getprop frame name) (create)))
276 (setf (getprop frame name) (create)))
277 (values)))
277 (void)))
278
278
279 ;;; Objects
279 ;;; Objects
280
280
@@ -357,35 +357,37 b''
357 (call-serv-loc "ONGSAVE")
357 (call-serv-loc "ONGSAVE")
358 (setf (root state-stash)
358 (setf (root state-stash)
359 (chain *j-s-o-n (stringify
359 (chain *j-s-o-n (stringify
360 (create vars (root vars)
360 (create :vars (root vars)
361 objs (root objs)
361 :objs (root objs)
362 loc-args args
362 :loc-args args
363 msecs (- (chain *date (now)) (root started-at))
363 :msecs (- (chain *date (now)) (root started-at))
364 main-html (inner-html
364 :timer-interval (root timer-interval)
365 (by-id :qsp-main))
365 :main-html (inner-html
366 stat-html (inner-html
366 (by-id :qsp-main))
367 (by-id :qsp-stat))
367 :stat-html (inner-html
368 next-location (root current-location)))))
368 (by-id :qsp-stat))
369 (values))
369 :next-location (root current-location)))))
370 (void))
370
371
371 (defun unstash-state ()
372 (defun unstash-state ()
372 (let ((data (chain *j-s-o-n (parse (root state-stash)))))
373 (let ((data (chain *j-s-o-n (parse (root state-stash)))))
373 (clear-act)
374 (clear-act)
374 (setf (root vars) (@ data vars))
375 (setf (root vars) (@ data :vars))
375 (loop :for k :in (chain *object (keys (root vars)))
376 (loop :for k :in (chain *object (keys (root vars)))
376 :do (chain *object (set-prototype-of (getprop (root vars) k)
377 :do (chain *object (set-prototype-of (getprop (root vars) k)
377 (@ *var prototype))))
378 (@ *var prototype))))
378 (setf (root started-at) (- (chain *date (now)) (@ data msecs)))
379 (setf (root started-at) (- (chain *date (now)) (@ data :msecs)))
379 (setf (root objs) (@ data objs))
380 (setf (root objs) (@ data :objs))
380 (setf (root current-location) (@ data next-location))
381 (setf (root current-location) (@ data :next-location))
381 (setf (inner-html (by-id :qsp-main))
382 (setf (inner-html (by-id :qsp-main))
382 (@ data main-html))
383 (@ data :main-html))
383 (setf (inner-html (by-id :qsp-stat))
384 (setf (inner-html (by-id :qsp-stat))
384 (@ data stat-html))
385 (@ data :stat-html))
385 (update-objs)
386 (update-objs)
387 (set-timer (@ data :timer-interval))
386 (call-serv-loc "ONGLOAD")
388 (call-serv-loc "ONGLOAD")
387 (call-loc (root current-location) (@ data loc-args))
389 (call-loc (root current-location) (@ data :loc-args))
388 (values)))
390 (void)))
389
391
390 (defun state-to-base64 ()
392 (defun state-to-base64 ()
391 (btoa (encode-u-r-i-component (root state-stash))))
393 (btoa (encode-u-r-i-component (root state-stash))))
@@ -10,7 +10,7 b''
10 (defun goto (target args)
10 (defun goto (target args)
11 (api:clear-text :main)
11 (api:clear-text :main)
12 (funcall xgoto target (or args (list)))
12 (funcall xgoto target (or args (list)))
13 (values))
13 (void))
14
14
15 (defun xgoto (target args)
15 (defun xgoto (target args)
16 (api:clear-act)
16 (api:clear-act)
@@ -18,7 +18,7 b''
18 (api:stash-state args)
18 (api:stash-state args)
19 (funcall (getprop (root locs) (root current-location))
19 (funcall (getprop (root locs) (root current-location))
20 (or args (list)))
20 (or args (list)))
21 (values))
21 (void))
22
22
23 ;;; 2var
23 ;;; 2var
24
24
@@ -100,7 +100,7 b''
100
100
101 (defun gosub (target &rest args)
101 (defun gosub (target &rest args)
102 (funcall (getprop (root locs) target) args)
102 (funcall (getprop (root locs) target) args)
103 (values))
103 (void))
104
104
105 (defun func (target &rest args)
105 (defun func (target &rest args)
106 (funcall (getprop (root locs) target) args))
106 (funcall (getprop (root locs) target) args))
@@ -111,14 +111,14 b''
111
111
112 (defun dynamic (block &rest args)
112 (defun dynamic (block &rest args)
113 (when (stringp block)
113 (when (stringp block)
114 (api:report-error "DYNAMIC can't evaluate arbitrary strings.\nUse {braces} to create blocks for DYNAMIC."))
114 (api:report-error "DYNAMIC can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNAMIC."))
115 (api:with-call-args args
115 (api:with-call-args args
116 (funcall block args))
116 (funcall block args))
117 (values))
117 (void))
118
118
119 (defun dyneval (block &rest args)
119 (defun dyneval (block &rest args)
120 (when (stringp block)
120 (when (stringp block)
121 (api:report-error "DYNEVAL can't evaluate arbitrary strings.\nUse {braces} to create blocks for DYNEVAL."))
121 (api:report-error "DYNEVAL can't evaluate arbitrary strings.\\nUse {braces} to create blocks for DYNEVAL."))
122 (api:with-call-args args
122 (api:with-call-args args
123 (funcall block args)))
123 (funcall block args)))
124
124
@@ -126,21 +126,21 b''
126
126
127 (defun main-p (s)
127 (defun main-p (s)
128 (api:add-text :main s)
128 (api:add-text :main s)
129 (values))
129 (void))
130
130
131 (defun main-pl (s)
131 (defun main-pl (s)
132 (api:add-text :main s)
132 (api:add-text :main s)
133 (api:newline :main)
133 (api:newline :main)
134 (values))
134 (void))
135
135
136 (defun main-nl (s)
136 (defun main-nl (s)
137 (api:newline :main)
137 (api:newline :main)
138 (api:add-text :main s)
138 (api:add-text :main s)
139 (values))
139 (void))
140
140
141 (defun maintxt (s)
141 (defun maintxt (s)
142 (api:get-text :main)
142 (api:get-text :main)
143 (values))
143 (void))
144
144
145 ;; For clarity (it leaves a lib.desc() call in JS)
145 ;; For clarity (it leaves a lib.desc() call in JS)
146 (defun desc (s)
146 (defun desc (s)
@@ -148,38 +148,38 b''
148
148
149 (defun main-clear ()
149 (defun main-clear ()
150 (api:clear-text :main)
150 (api:clear-text :main)
151 (values))
151 (void))
152
152
153 ;;; 12stat
153 ;;; 12stat
154
154
155 (defun stat-p (s)
155 (defun stat-p (s)
156 (api:add-text :stat s)
156 (api:add-text :stat s)
157 (values))
157 (void))
158
158
159 (defun stat-pl (s)
159 (defun stat-pl (s)
160 (api:add-text :stat s)
160 (api:add-text :stat s)
161 (api:newline :stat)
161 (api:newline :stat)
162 (values))
162 (void))
163
163
164 (defun stat-nl (s)
164 (defun stat-nl (s)
165 (api:newline :stat)
165 (api:newline :stat)
166 (api:add-text :stat s)
166 (api:add-text :stat s)
167 (values))
167 (void))
168
168
169 (defun stattxt (s)
169 (defun stattxt (s)
170 (api:get-text :stat)
170 (api:get-text :stat)
171 (values))
171 (void))
172
172
173 (defun stat-clear ()
173 (defun stat-clear ()
174 (api:clear-text :stat)
174 (api:clear-text :stat)
175 (values))
175 (void))
176
176
177 (defun cls ()
177 (defun cls ()
178 (stat-clear)
178 (stat-clear)
179 (main-clear)
179 (main-clear)
180 (cla)
180 (cla)
181 (cmdclear)
181 (cmdclear)
182 (values))
182 (void))
183
183
184 ;;; 13diag
184 ;;; 13diag
185
185
@@ -189,27 +189,27 b''
189 (let ((acts (root acts)))
189 (let ((acts (root acts)))
190 (lambda ()
190 (lambda ()
191 (setf (root acts) acts)
191 (setf (root acts) acts)
192 (values))))
192 (void))))
193
193
194 ;;; 15objs
194 ;;; 15objs
195
195
196 (defun addobj (name)
196 (defun addobj (name)
197 (chain (root objs) (push name))
197 (chain (root objs) (push name))
198 (api:update-objs)
198 (api:update-objs)
199 (values))
199 (void))
200
200
201 (defun delobj (name)
201 (defun delobj (name)
202 (let ((index (chain (root objs) (index-of name))))
202 (let ((index (chain (root objs) (index-of name))))
203 (when (> index -1)
203 (when (> index -1)
204 (killobj (1+ index))))
204 (killobj (1+ index))))
205 (values))
205 (void))
206
206
207 (defun killobj (&optional (num nil))
207 (defun killobj (&optional (num nil))
208 (if (eq nil num)
208 (if (eq nil num)
209 (setf (root objs) (list))
209 (setf (root objs) (list))
210 (chain (root objs) (splice (1- num) 1)))
210 (chain (root objs) (splice (1- num) 1)))
211 (api:update-objs)
211 (api:update-objs)
212 (values))
212 (void))
213
213
214 ;;; 16menu
214 ;;; 16menu
215
215
@@ -232,7 +232,7 b''
232 loc loc
232 loc loc
233 icon icon))))))))
233 icon icon))))))))
234 (api:menu menu-data)
234 (api:menu menu-data)
235 (values)))
235 (void)))
236
236
237 ;;; 17sound
237 ;;; 17sound
238
238
@@ -244,7 +244,8 b''
244
244
245 (defun close (filename)
245 (defun close (filename)
246 (funcall (root playing filename) stop)
246 (funcall (root playing filename) stop)
247 (delete (root playing filename)))
247 (delete (root playing filename))
248 (void))
248
249
249 (defun closeall ()
250 (defun closeall ()
250 (loop :for k :in (chain *object (keys (root playing)))
251 (loop :for k :in (chain *object (keys (root playing)))
@@ -58,3 +58,12 b''
58 (ps-print body))
58 (ps-print body))
59
59
60 (cl:export '=>)
60 (cl:export '=>)
61
62 ;;; Actually return nothing (with no empty return)
63 (defvar *old-return-result-of* (function return-result-of))
64
65 (defun return-result-of (tag form)
66 (if (equal form '(void))
67 nil
68 (funcall *old-return-result-of* tag form)))
69 (export 'void)
@@ -9,16 +9,14 b''
9
9
10 ;;; Common
10 ;;; Common
11
11
12 (defpsmacro label-block ((&key (locals t)) &body body)
12 (defpsmacro label-block (() &body body)
13 (let ((has-labels (some #'keywordp body)))
13 (let ((has-labels (some #'keywordp body)))
14 `(block nil
14 `(block nil
15 ,@(when has-labels
15 ,@(when has-labels
16 '((defvar __labels)))
16 '((defvar __labels)))
17 ,@(if locals
17 (tagbody
18 `((tagbody
18 ,@body
19 ,@body))
19 (void)))))
20 `((tagbody
21 ,@body))))))
22
20
23 (defpsmacro str (&rest forms)
21 (defpsmacro str (&rest forms)
24 (cond ((zerop (length forms))
22 (cond ((zerop (length forms))
@@ -130,7 +128,7 b''
130 `(api-call add-act ,name ,img
128 `(api-call add-act ,name ,img
131 (async-lambda ()
129 (async-lambda ()
132 (label-block ()
130 (label-block ()
133 ,@body))))
131 ,@body))))
134
132
135 ;;; 12aux
133 ;;; 12aux
136
134
General Comments 0
You need to be logged in to leave comments. Login now