Show LINE NUMBERS in compiler errors!!
This commit is contained in:
parent
bee38a4168
commit
64281801b2
|
@ -440,7 +440,7 @@
|
||||||
(def-toolbox 0x9a04 SetTextFace (textFace) void)
|
(def-toolbox 0x9a04 SetTextFace (textFace) void)
|
||||||
(def-toolbox 0x9c04 SetTextMode (textMode) void)
|
(def-toolbox 0x9c04 SetTextMode (textMode) void)
|
||||||
(def-toolbox 0xd204 SetTextSize (textSize) void)
|
(def-toolbox 0xd204 SetTextSize (textSize) void)
|
||||||
(def-toolbox 0x4604 SetUserFIeld ((long userFieldValue)) void)
|
(def-toolbox 0x4604 SetUserField ((long userFieldValue)) void)
|
||||||
(def-toolbox 0xc804 SetVisHandle ((long rgnHandle)) void)
|
(def-toolbox 0xc804 SetVisHandle ((long rgnHandle)) void)
|
||||||
(def-toolbox 0xb404 SetVisRgn ((long rgnHandle)) void)
|
(def-toolbox 0xb404 SetVisRgn ((long rgnHandle)) void)
|
||||||
(def-toolbox 0x9104 ShowCursor () void)
|
(def-toolbox 0x9104 ShowCursor () void)
|
||||||
|
|
14
ssc/init.fnl
14
ssc/init.fnl
|
@ -441,9 +441,14 @@
|
||||||
post (icollect [_ (countiter (length args))] (self:drop))]
|
post (icollect [_ (countiter (length args))] (self:drop))]
|
||||||
(values (lume.concat [:block] pre [[:jsr f.name]] post) f.type)))
|
(values (lume.concat [:block] pre [[:jsr f.name]] post) f.type)))
|
||||||
|
|
||||||
|
(fn Ssc.enter-expr [self expr]
|
||||||
|
(let [m (getmetatable expr)]
|
||||||
|
(when (and m m.filename) (set self.expr-metadata m))))
|
||||||
|
|
||||||
(fn Ssc.expr-poly [self expr]
|
(fn Ssc.expr-poly [self expr]
|
||||||
; (pp expr)
|
(self:enter-expr expr)
|
||||||
(match expr
|
(let [(success c-expr etype)
|
||||||
|
(pcall #(match expr
|
||||||
(where lit (?. (self:opgen lit) :hi)) (let [{: lo : hi} (self:opgen lit)]
|
(where lit (?. (self:opgen lit) :hi)) (let [{: lo : hi} (self:opgen lit)]
|
||||||
(values [:block (lo :lda) [:sta self.LONG_LO] (hi :lda) [:sta self.LONG_HI]] :long))
|
(values [:block (lo :lda) [:sta self.LONG_LO] (hi :lda) [:sta self.LONG_HI]] :long))
|
||||||
(where lit (?. (self:opgen lit) :lo)) (let [{: lo} (self:opgen lit)] (values (lo :lda) :word))
|
(where lit (?. (self:opgen lit) :lo)) (let [{: lo} (self:opgen lit)] (values (lo :lda) :word))
|
||||||
|
@ -456,7 +461,10 @@
|
||||||
(cexpr etype) (f self (table.unpack args))]
|
(cexpr etype) (f self (table.unpack args))]
|
||||||
(values cexpr (or etype :word)))
|
(values cexpr (or etype :word)))
|
||||||
nil (values [:block] :void)
|
nil (values [:block] :void)
|
||||||
_ (error (.. "Unrecognized expression " (fv expr)))))
|
_ (error (.. "Unrecognized expression"))))]
|
||||||
|
(if success (values c-expr etype)
|
||||||
|
(let [{: filename : line} (or self.expr-metadata {:filename "<unknown>" :line "??"})]
|
||||||
|
(error (.. filename "@" line ": " (fv expr) "\n" c-expr))))))
|
||||||
|
|
||||||
(fn Ssc.expr-word [self expr]
|
(fn Ssc.expr-word [self expr]
|
||||||
(let [(c etype) (self:expr-poly expr)]
|
(let [(c etype) (self:expr-poly expr)]
|
||||||
|
|
|
@ -7,11 +7,18 @@
|
||||||
; (form mymacro [(fn [ssc] (ssc:compile-expr [:+ 1 2]))])
|
; (form mymacro [(fn [ssc] (ssc:compile-expr [:+ 1 2]))])
|
||||||
; => [:form :mymacro (fn [ssc] (ssc:compile-expr [:+ 1 2]))]
|
; => [:form :mymacro (fn [ssc] (ssc:compile-expr [:+ 1 2]))]
|
||||||
|
|
||||||
|
(fn attach-metadata [form result]
|
||||||
|
(if (list? form)
|
||||||
|
(let [{: filename : line : bytestart : byteend} form]
|
||||||
|
`(setmetatable ,result ,{: filename : line : bytestart : byteend}))
|
||||||
|
result))
|
||||||
|
|
||||||
(fn form-to-fnl [form]
|
(fn form-to-fnl [form]
|
||||||
|
(attach-metadata form
|
||||||
(if (sym? form) (tostring form)
|
(if (sym? form) (tostring form)
|
||||||
(sequence? form) (. form 1) ; escape
|
(sequence? form) (. form 1) ; escape
|
||||||
(list? form) (icollect [_ inner-form (ipairs form)] (form-to-fnl inner-form))
|
(list? form) (icollect [_ inner-form (ipairs form)] (form-to-fnl inner-form))
|
||||||
form))
|
form)))
|
||||||
|
|
||||||
(fn sss [...]
|
(fn sss [...]
|
||||||
(let [result `(values)]
|
(let [result `(values)]
|
||||||
|
|
Loading…
Reference in a new issue