mirror of
https://github.com/janet-lang/janet
synced 2025-02-22 19:20:01 +00:00
Fix bug in compiler
This commit is contained in:
parent
1f8b671488
commit
d6967a564d
@ -574,7 +574,7 @@ static Slot compile_assign(GstCompiler *c, FormOptions opts, GstValue left, GstV
|
|||||||
GstValue lit = gst_wrap_nil();
|
GstValue lit = gst_wrap_nil();
|
||||||
GstScope *scope = c->tail;
|
GstScope *scope = c->tail;
|
||||||
GstBuffer *buffer = c->buffer;
|
GstBuffer *buffer = c->buffer;
|
||||||
FormOptions subOpts;
|
FormOptions subOpts = form_options_default();
|
||||||
uint16_t target = 0;
|
uint16_t target = 0;
|
||||||
uint16_t level = 0;
|
uint16_t level = 0;
|
||||||
uint16_t flags = 0;
|
uint16_t flags = 0;
|
||||||
@ -1064,15 +1064,7 @@ static SpecialFormHelper get_special(const GstValue *form) {
|
|||||||
* problems. */
|
* problems. */
|
||||||
if (gst_string_length(name) == 0)
|
if (gst_string_length(name) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* One character specials. */
|
/* Specials */
|
||||||
if (gst_string_length(name) == 1) {
|
|
||||||
switch(name[0]) {
|
|
||||||
case ':': return compile_def;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Multi character specials. Mostly control flow. */
|
|
||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
case 'a':
|
case 'a':
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,19 @@
|
|||||||
(do
|
(print "Running basic tests...")
|
||||||
(: assert (fn [x e] (if x x (do (print e) (exit 1)))))
|
(def assert (fn [x e] (if x (do (write stdout ".") x) (do (print e) (exit 1)))))
|
||||||
|
|
||||||
(assert (= 10 (+ 1 2 3 4)) "addition")
|
(assert (= 10 (+ 1 2 3 4)) "addition")
|
||||||
(assert (= -8 (- 1 2 3 4)) "subtraction")
|
(assert (= -8 (- 1 2 3 4)) "subtraction")
|
||||||
(assert (= 24 (* 1 2 3 4)) "multiplication")
|
(assert (= 24 (* 1 2 3 4)) "multiplication")
|
||||||
(assert (= 0.1 (/ 1.0 10)) "division")
|
(assert (= 4 (blshift 1 2)) "left shift")
|
||||||
(exit 0)
|
(assert (= 1 (brshift 4 2)) "right shift")
|
||||||
)
|
|
||||||
|
(var accum 1)
|
||||||
|
(var count 0)
|
||||||
|
(while (< count 16)
|
||||||
|
(varset accum (blshift accum 1))
|
||||||
|
(varset count (+ 1 count)))
|
||||||
|
|
||||||
|
(assert (= accum 65536) "loop")
|
||||||
|
|
||||||
|
(print)
|
||||||
|
(exit 0)
|
Loading…
x
Reference in New Issue
Block a user