Skip to content

Commit

Permalink
changes in compiler due to issue #165
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingo60 committed Aug 19, 2015
1 parent 1f741b7 commit 5b0e6ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frege/compiler/Typecheck.fr
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ rhoLong = rhoFor "Long"
rhoDouble = rhoFor "Double"
rhoFloat = rhoFor "Float"
rhoRegex = RhoTau [] (TCon {pos=Position.null,name=TName pUtilRegex "Regex"})
rhoMatcher = RhoTau [] (TCon {pos=Position.null,name=TName pUtilRegex "Matcher"})
rhoMatcher = RhoTau [] (TCon {pos=Position.null,name=TName pUtilRegex "MatchResult"})
rhoInteger = rhoFor "Integer"
tauString = TApp (tc "StringJ") (tc "Char")
numVar = ForAll [("int", KType)]
Expand Down
16 changes: 10 additions & 6 deletions frege/compiler/gen/Match.fr
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import Compiler.enums.Literals

import Compiler.types.Strictness
import Compiler.types.JTypes
-- import Compiler.types.JNames
import Compiler.types.QNames
import Compiler.types.Types
import Compiler.types.Patterns
Expand Down Expand Up @@ -326,15 +327,18 @@ match assert (pat@PMat {pos, uid, var, value}) bind cont binds = do
lit = Lit {pos, kind = LRegex, value, typ = Just (TY.sigRegex)}

jname <- findConst lit
let xbnd = Bind{ftype = TY.sigMatcher, stype = nicer TY.sigMatcher g,
jtype = mjt,
jex = JStMem{jname, targs = []}}
let mbnd = Bind{ftype = xbnd.ftype, stype = xbnd.stype, jtype = mjt,
jex = JInvoke (JX.jexmem xbnd.jex "matcher") [sbnd.jex]}
let find = JStMem{jname = jnFind, targs = []}
-- let xbnd = Bind{ftype = TY.sigMatcher, stype = nicer TY.sigMatcher g,
-- jtype = mjt,
-- jex = JStMem{jname, targs = []}}
let mbnd = Bind{ftype = TY.sigMatcher, stype = nicer TY.sigMatcher g,
jtype = mjt,
jex = JInvoke find [sbnd.jex, JStMem jname []]}
(mbnd,code2) <- realize (U.javaName g (Local uid var)).base mbnd
body <- cont (binds.insert vsym mbnd)

let jex = JInvoke (JX.jexmem mbnd.jex "find") []
let -- jex = JInvoke (JX.jexmem mbnd.jex "find") []
jex = JBin{j1 = mbnd.jex, op = "!=", j2 = JAtom "null"}
ifc = if assert then JAssert jex : body else [JCond "if" jex body]
stio (sbnd, (comment:code) ++ code2 ++ ifc)

Expand Down
2 changes: 2 additions & 0 deletions frege/compiler/gen/Util.fr
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ jnWrapped = JName "frege.runtime" "WrappedCheckedException"
--- used to construct static member functions of @Delayed@
jnDelayed = JName "frege.runtime" "Delayed"

--- used to match @m~p@ patterns
jnFind = memberOf (JName "frege.runtime" "Regex9") "findResult"

--- Delayed<>
jtDelayed = Ref jnDelayed []
Expand Down

0 comments on commit 5b0e6ad

Please sign in to comment.