Skip to content

Commit

Permalink
reverting experimental code accidentally commited
Browse files Browse the repository at this point in the history
  • Loading branch information
cgrand committed Aug 20, 2024
1 parent d6c8b4a commit 8dd8e6d
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions clj/src/cljd/compiler.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@
:canon-qname pseudo.not-bool
:nullable true})

(def pseudo-not-nil '{:kind :class
:qname dc.dynamic
:lib "dart:core"
:canon-qname pseudo.not-nil
:nullable false})

(def pseudo-super '{:kind :class
:qname dc.dynamic
:lib "dart:core"
Expand Down Expand Up @@ -637,7 +631,6 @@
[tag {:keys [type-vars] :as env}]
(cond
(= 'some tag) pseudo-some
(= 'not-nil tag) pseudo-not-nil
(= 'super tag) pseudo-super
('#{void dart:core/void} tag) dc-void
:else
Expand Down Expand Up @@ -1023,9 +1016,7 @@
_ (case opt-kind
:named
(do
(when-some [extras (seq (keep (fn [[p d]] (when-not (opts p) p)) opt-params))]
(throw (Exception. (str "Unexpected optional named arguments " extras " for method " mname " for " (:element-name type) " of library " (:lib type)))))
#_(when-not (<= (count opt-params) (count opts))
(when-not (<= (count opt-params) (count opts))
(throw (Exception. (str "Too many optional named arguments (" (- (count opt-params) (count opts)) " extra(s)) for method " mname " for " (:element-name type) " of library " (:lib type)))))
(when-some [missed (seq (reduce disj opts (into #{} (map first) opt-params)))]
(throw (Exception. (str "Missing optional named arguments " missed " for method " mname " for " (:element-name type) " of library " (:lib type))))))
Expand Down Expand Up @@ -1545,13 +1536,10 @@
([dart-expr expected-type env]
(magicast dart-expr expected-type (:dart/type (infer-type dart-expr)) env))
([dart-expr expected-type actual-type env]
(when (= 'dc.Function (:canon-qname expected-type) (:canon-qname actual-type))
(prn 'RETX (is-assignable? expected-type actual-type) (:canon-qname (:return-type expected-type))
(:canon-qname (:return-type actual-type))))
(cond
(= 'dc.dynamic (:canon-qname expected-type)) dart-expr ; TODO: should be covered by is-assignable?

(is-assignable? expected-type actual-type) dart-expr ; <1>
(is-assignable? expected-type actual-type) dart-expr ; <1>

(and (nullable-type? expected-type) (nullable-type? actual-type)) ; <2>
(if-some [expected-type+ (positive-type expected-type)]
Expand Down Expand Up @@ -3375,7 +3363,6 @@
(defn emit
"Takes a clojure form and a lexical environment and returns a dartsexp."
[x env]
(when (-> x meta :line) (-> x meta prn))
(try
(let [x (macroexpand-and-inline env x) ;; meta dc-nim
dart-x
Expand All @@ -3388,9 +3375,9 @@
(emit (list 'dart:core/DateTime.parse s) env))
(instance? java.util.regex.Pattern x)
(emit (list 'new 'dart:core/RegExp
#_(list '. 'dart:core/RegExp 'escape (.pattern ^java.util.regex.Pattern x))
(.pattern ^java.util.regex.Pattern x)
#_#_#_'.& :unicode true) env)
#_(list '. 'dart:core/RegExp 'escape (.pattern ^java.util.regex.Pattern x))
(.pattern ^java.util.regex.Pattern x)
#_#_#_'.& :unicode true) env)
(keyword? x)
(emit (list 'cljd.core/Keyword. (namespace x) (name x) (cljd-hash x)) env)
(nil? x) nil
Expand Down Expand Up @@ -3451,9 +3438,9 @@
type (simple-cast type)))
(catch Exception e
(throw
(if-some [stack (::emit-stack (ex-data e))]
(ex-info (ex-message e) (assoc (ex-data e) ::emit-stack (conj stack x)) (ex-cause e))
(ex-info (str "Error while compiling " *file* " " (pr-str x)) {::emit-stack [x]} e))))))
(if-some [stack (::emit-stack (ex-data e))]
(ex-info (ex-message e) (assoc (ex-data e) ::emit-stack (conj stack x)) (ex-cause e))
(ex-info (str "Error while compiling " *file* " " (pr-str x)) {::emit-stack [x]} e))))))

(defn host-eval
[x]
Expand Down

0 comments on commit 8dd8e6d

Please sign in to comment.