aboutsummaryrefslogtreecommitdiff
path: root/src/main/stanza/ir-utils.stanza
diff options
context:
space:
mode:
authorazidar2015-02-19 08:28:54 -0800
committerazidar2015-02-19 08:28:54 -0800
commit8c1c4225c340dc658f7d0956e8b231050c122abc (patch)
tree93c438922163579d5f00b3f3984c0506f66f59fc /src/main/stanza/ir-utils.stanza
parent50b5ce57d1b823a03725dd0aa2141f300c244bf1 (diff)
Added compiler flags to allow tests to select which passes they test.
Changed package names from chipper to firrtl
Diffstat (limited to 'src/main/stanza/ir-utils.stanza')
-rw-r--r--src/main/stanza/ir-utils.stanza26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/main/stanza/ir-utils.stanza b/src/main/stanza/ir-utils.stanza
index 9eac350c..7edbcb1c 100644
--- a/src/main/stanza/ir-utils.stanza
+++ b/src/main/stanza/ir-utils.stanza
@@ -1,7 +1,7 @@
-defpackage chipper.ir-utils :
+defpackage firrtl.ir-utils :
import core
import verse
- import chipper.ir2
+ import firrtl.ir2
;============== PRINTERS ===================================
defmethod print (o:OutputStream, d:Direction) :
@@ -227,3 +227,25 @@ defmethod children (c:Stmt) :
(c:Begin) : body(c)
(c) : List()
+;=================== STRING OPS ===============================
+public defn split (s:String,c:Char) -> List<String> :
+ val empty = ""
+ defn next-word (s:String,i:Int) -> String|False :
+ if i == length(s) : false
+ else:
+ if (s[i] == c): substring(s,0,i)
+ else: next-word(s,i + 1)
+
+ val next-str = next-word(s,0)
+ if next-str == false : list()
+ else if next-str == empty : split(substring(s,1,length(s)),c)
+ else :
+ val str = next-str as String
+ List(str,split(substring(s,length(str)+1,length(s)),c))
+
+public defn contains (l:List<Char>, c:Char) :
+ label<True|False> myret :
+ for x in l do :
+ if x == c : myret(true)
+ false
+