diff options
| author | azidar | 2015-07-06 13:50:18 -0700 |
|---|---|---|
| committer | azidar | 2015-07-06 13:50:18 -0700 |
| commit | 896f6a9453b1093e46df4b96e2737335a71579ba (patch) | |
| tree | 125c100a1000df60b32535bc9f86fe9605cc03de /src | |
| parent | a5727e677bbf12674da94526366535a0f820590d (diff) | |
Updated todo
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/stanza/errors.stanza | 99 | ||||
| -rw-r--r-- | src/main/stanza/passes.stanza | 6 |
2 files changed, 80 insertions, 25 deletions
diff --git a/src/main/stanza/errors.stanza b/src/main/stanza/errors.stanza index 71727a14..229a1406 100644 --- a/src/main/stanza/errors.stanza +++ b/src/main/stanza/errors.stanza @@ -52,9 +52,9 @@ defn NotUnique (info:FileInfo, name:Symbol) : PassException $ string-join $ [info ": Reference " name " does not have a unique name."] -defn IsPrefix (info:FileInfo, name1:Symbol, name2:Symbol) : +defn IsPrefix (info:FileInfo, prefix:Symbol) : PassException $ string-join $ - [info ": Reference " name1 " and " name2 " share a prefix."] + [info ": Symbol " prefix " is a prefix."] defn InvalidLOC (info:FileInfo) : PassException $ string-join $ @@ -128,26 +128,75 @@ defn contains?<?T> (c:?T,cs:Streamable<?T>) -> True|False : if x == c : myret(true) false -defn is-prefix? (s:Symbol,v:HashTable<Symbol,True>,sym:Symbol) -> Symbol|False : - ;defn is-prefix? (s1:Symbol,s2:Symbol) -> True|False : - ; var is? = true - ; val s1* = to-string(s1) - ; val s2* = to-string(s2) - ; val st = to-string(sym) - ; for (x in s1*, y in s2*) do : - ; if x != y : is? = false - ; if abs(length(s1*) - length(s2*)) < length(st) : is? = false - ; else : - ; if length(s1*) > length(s2*) : - ; if substring(s1*,length(s2*),length(s2*) + length(st)) != st : is? = false - ; if length(s1*) < length(s2*) : - ; if substring(s2*,length(s1*),length(s1*) + length(st)) != st : is? = false - ; is? - ;label<Symbol|False> myret : - ; for x in v do : - ; if is-prefix?(key(x),s) : myret(key(x)) - ; false - false +;defstruct Trie : +; char : Char +; children : HashTable<Char,Trie> +; +;defn char-hash (c:Char) -> Int : symbol-hash(to-symbol(c)) +;defn new-trie (c:Char) -> Trie : Trie(c,HashTable<Char,Trie>(char-hash)) +;defn tail (s:String) -> String : substring(s,1,length(s)) +; +;defn insert-top (trie:Trie,symbol:Symbol) -> True|False : true +; insert(trie,string-join([" " symbol])) +; +;defn insert (trie:Trie,string:String) -> True|False : +; if length(string) == 0 : char(trie) +; +; val child = get?(children(trie),string[0],false) +; if length(string) == 1 : +; match(child) : +; (c:Trie) : false +; (c:False) : +; children(trie)[string[0]] = new-trie(string[0]) +; true +; else : +; match(child) : +; (c:Trie) : insert(c,tail(string)) +; (c:False) : +; val t = new-trie(string[0]) +; insert(t,tail(string)) +; children(trie)[string[0]] = t +; +;defn has? (trie:Trie, string:String) -> True|False : +; if length(string) == 0 : true +; if length(string) >= 1 : +; if key?(children(trie),string[0]) : +; has?(tail(string), children(trie)[string[0]]) +; else : false +; +;defn any-prefixes? (trie:Trie,delim:String) -> String|False : +; if has?(trie,delim) : +; val c = get-children-after(trie:Trie,delim:String) +; if length(keys(c)) > 1 : +; +; +; if length(partial-delim) == 0 : to-string(char(trie)) +; if length(partial-delim) == 1 : +; if key?(children(trie),partial-delim[0]) : any-prefixes?(...WAS HERE +; if char(trie) == partial-delim[0] : +; if length(keys(children(trie))) >= 2 : to-string(char(trie)) +; else : false +; else : +; label<String|False> myret : +; for x in children(trie) do : +; match(any-prefixes?(value(x),full-delim,full-delim)) : +; (s:False) : false +; (s:String) : myret(string-join([char(trie) s])) +; false +; else : +; label<String|False> myret : +; for x in children(trie) do : +; if char(trie) == partial-delim[0] : +; match(any-prefixes?(value(x),tail(partial-delim),full-delim)) : +; (s:False) : false +; (s:String) : myret(string-join([char(trie) s])) +; match(any-prefixes?(value(x),partial-delim,full-delim)) : +; (s:False) : false +; (s:String) : myret(string-join([char(trie) s])) +; match(any-prefixes?(value(x),full-delim,full-delim)) : +; (s:False) : false +; (s:String) : myret(string-join([char(trie) s])) +; false defn check-high-form-primop (e:DoPrim, errors:Vector<PassException>,info:FileInfo) -> False : defn correct-num (ne:Int|False,nc:Int) -> False : @@ -240,9 +289,6 @@ public defn check-high-form (c:Circuit,sym:Symbol) -> Circuit : defn check-high-form-s (s:Stmt,names:HashTable<Symbol,True>) -> Stmt : defn check-name (info:FileInfo,name:Symbol) -> False : if key?(names,name) : add(errors,NotUnique(info,name)) - val prefix = is-prefix?(name,names,sym) - if prefix typeof Symbol : add(errors,IsPrefix(info,name,prefix as Symbol)) - map(check-high-form-t{info(s),_:Type},s) map{check-high-form-s{_,names},_} $ { @@ -294,6 +340,9 @@ public defn check-high-form (c:Circuit,sym:Symbol) -> Circuit : match(m) : (m:ExModule) : false (m:InModule) : check-high-form-s(body(m),names) + ;match(any-prefixes?(names,to-string(sym),to-string(sym))) : + ;(s:False) : false + ;(s:String) : add(errors,IsPrefix(info,to-symbol(s))) false var number-top-m = 0 diff --git a/src/main/stanza/passes.stanza b/src/main/stanza/passes.stanza index 2192bd10..b2a53a70 100644 --- a/src/main/stanza/passes.stanza +++ b/src/main/stanza/passes.stanza @@ -1890,13 +1890,19 @@ defn split-exp (c:Circuit) : (s) : add(v,map(split-exp-e{_,false,info(s)},s)) false + val start-time = current-time-us() Circuit{info(c),_,main(c)} $ for m in modules(c) map : match(m) : (m:InModule) : val v = Vector<Stmt>() val sh = get-sym-hash(m) + val before = current-time-us() - start-time + println-all(["Before split: " before]) split-exp-s(body(m),v,sh) + val now = current-time-us() - start-time + println-all(["After split: " now]) + println-all(["Diff: " now - before]) InModule(info(m),name(m),ports(m),Begin(to-list(v))) (m:ExModule) : m |
