Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split records of TauT and RhoT #388

Open
wants to merge 152 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
c5fd565
Split constructors of DefinitionS to individual data types
matil019 Jan 13, 2019
f577108
Add instance Alt Maybe
matil019 Oct 21, 2019
c4dfb23
[norun] Change SymbolT.SymT to an independent data type
matil019 Oct 17, 2019
73d651a
[nocompile] Change all of SymbolT constructors to independent types
matil019 Oct 17, 2019
504e178
Isolate all of SymbolT data constructors
matil019 Oct 21, 2019
e9fd748
Add instance Nice for SymT, SymL, etc.
matil019 Oct 19, 2019
1b872dc
Modify findV to return SymV, same for other Sym?s
matil019 Oct 19, 2019
7803c9e
Change the return type of patLocal, mkLocal, vSym to SymV
matil019 Oct 19, 2019
5a0459a
Remuve uses of unsafePartialView from frege.compiler.Kinds
matil019 Oct 19, 2019
f83552d
Reduce warnings on frege.tools.doc.Utilities
matil019 Oct 19, 2019
8c03d3f
Remove uses of unsafePartialView from frege.compiler.passes.Imp
matil019 Oct 19, 2019
596b2e0
Reduce uses of partial functions in frege.ide.Utilities
matil019 Oct 19, 2019
a4cb129
Remove redundant cases in frege.compiler.gen.java.Common
matil019 Oct 19, 2019
d9c176b
Change the return type of envConstructors to [SymD Global]
matil019 Oct 19, 2019
d8ce200
Remove uses of partial functions in frege.compiler.passes.Instances
matil019 Oct 19, 2019
6f2e5a4
Remove some of partial functions in frege.compiler.Classes
matil019 Oct 19, 2019
efac3c0
Remove a dead case in frege.compiler.gen.java.InstanceCode
matil019 Oct 19, 2019
727656c
Remove a dead case in frege.compiler.gen.java.DataCode
matil019 Oct 19, 2019
9caad72
Remove some partial functions and dead cases in frege.c.g.j.VarCode
matil019 Oct 19, 2019
81e2594
Remove partial functions in frege.compiler.gen.java.Match
matil019 Oct 19, 2019
56e7ac8
Change the return type of allourvars and allvars to [SymV Global]
matil019 Oct 19, 2019
fb417c4
Change fundep to take SymV
matil019 Oct 19, 2019
f0b8d1c
Change ccSym to take SymV
matil019 Oct 19, 2019
8bef123
Change the type of Global.locals to TreeMap Int (SymV Global)
matil019 Oct 19, 2019
7809062
Remove some partial functions in frege.compiler.passes.Transdef
matil019 Oct 19, 2019
daf9a49
Add instance Ord for SymT, SymL, etc.
matil019 Oct 19, 2019
a316f7a
Remove dead cases and partial functions from f.c.passes.LetUnroll
matil019 Oct 19, 2019
2c7fad5
Remove some partial functions and dead cases in frege.compiler.Typecheck
matil019 Oct 19, 2019
81a68d2
Remove partial functions in frege.compiler.GenMeta
matil019 Oct 19, 2019
d1cbfc0
Remove unused imports
matil019 Oct 19, 2019
03611c1
Assume main is SymV in frege.compiler.passes.GenCode
matil019 Oct 21, 2019
4777ba6
[prototype] Make insertSym and updateSym polymorphic
matil019 Oct 21, 2019
e0d5f1e
Add Prism
matil019 Oct 22, 2019
f95bcb3
Add prisms for SymbolT
matil019 Oct 22, 2019
cdcb6db
Introduce SymVal to constrain the return type of findVD
matil019 Oct 23, 2019
86364a5
Modify Classes.implemented to take SymVal
matil019 Oct 23, 2019
63a8efc
Remove a non-exhaustive case from passC.mkanno
matil019 Oct 23, 2019
43de55b
Remove unsafeToSymC from passC.methodcheck
matil019 Oct 23, 2019
eaaae98
Remove a redundant pattern of tcInstMethod
matil019 Oct 23, 2019
a3f51fd
Assume tcInstMethod takes either SymV or SymL
matil019 Oct 23, 2019
037f1a8
Change the type of SymI.env to SymMeth
matil019 Oct 23, 2019
58b9af7
Change the return type of classMethodOfInstMethod to SymV
matil019 Oct 24, 2019
e16d177
Modify strictReturn to return SymVal
matil019 Oct 24, 2019
cab842a
Add findMain, specialized to find the main function
matil019 Oct 24, 2019
e31e3d2
Use SymVal in substInst
matil019 Oct 24, 2019
23933ec
Use SymV in rHas
matil019 Oct 24, 2019
aaf425d
Modify passC.methodcheck to take SymMeth
matil019 Oct 24, 2019
1fdcc0c
Assume SymV in isEasy.Let
matil019 Oct 24, 2019
d698fae
Assume SymV in etaExpand.cleanVarType
matil019 Oct 24, 2019
17905bd
Change the type of Global.genEnv to [SymV Global]
matil019 Oct 24, 2019
e868594
Assume the return type of instTSym and instTauSym to be SymT
matil019 Oct 24, 2019
c973f5c
Modify methCode and related functions to take SymV
matil019 Oct 24, 2019
38021a1
Modify wrapIRMethod to take SymVal
matil019 Oct 24, 2019
379359c
Remove use of unsafePartialView in symWarning
matil019 Oct 24, 2019
1d5d778
Modify arity to take SymVal
matil019 Oct 24, 2019
f3992b8
Add a custom partial conversion SymbolT -> SymV in SymbolTable
matil019 Oct 24, 2019
599465c
Remove use of unsafePartialView in docWarningSym
matil019 Oct 24, 2019
1f5afaf
Remove uses of unsafePartialView from passes.Final
matil019 Oct 25, 2019
59847a3
Ignore missing SymbolT.env' in resolve3
matil019 Oct 25, 2019
f3f0c3a
Ignore missing SymbolT.env' in enter1ClaDcl
matil019 Oct 25, 2019
749d6cc
Remove uses of unsafePartialView in Transdef
matil019 Oct 25, 2019
1a8fade
Move a common part in SymbolTable to a new function
matil019 Oct 28, 2019
3ac3df8
Change the type of SymC.env to SymMeth
matil019 Oct 26, 2019
cdd5ba1
Replace a partial function in InstanceCode with a new error message
matil019 Oct 30, 2019
eba6356
View SymMeth as SymV in InstanceCode to reduce unsafePartialView
matil019 Oct 30, 2019
5634a4f
Treat non-SymV as non-existent in Transdef.ordInfix
matil019 Oct 30, 2019
1df0181
Remove a "may evaluate to false" warning in Classes.tcInstMethod
matil019 Oct 30, 2019
61f2681
Remove uses of unsafePartialView in Classes
matil019 Oct 30, 2019
6a60400
Remove an unused import in Final to avoid warnings
matil019 Oct 30, 2019
c4c7736
Remove uses of partial matches in VarCode
matil019 Oct 30, 2019
3b9cefb
Add a custom partial function in InstanceCode
matil019 Oct 30, 2019
da7ebcf
Add a custom partial function in Global
matil019 Oct 30, 2019
9effb28
Add an error message to the new error in SymbolTable
matil019 Oct 30, 2019
a9b0fa2
Add a copy of unsafePartialView to MethodCall
matil019 Oct 30, 2019
afca4ce
Remove uses of partial matches in doc.Utility
matil019 Oct 30, 2019
a42eca7
Remove uses of partial functions in tools.Doc
matil019 Oct 30, 2019
e7908e5
Remove uses of partial matches in ide.Utilities
matil019 Oct 30, 2019
e01d94c
Change SymbolTable.InsUpd to protected
matil019 Oct 30, 2019
4b83084
Make constructors of SymbolT, SymMeth and SymVal strict
matil019 Oct 30, 2019
e6f82dd
Clean unused imports
matil019 Oct 30, 2019
46e2e2f
Replace 'view'ing lenses with simple getters
matil019 Oct 30, 2019
750cc61
Remove Prisms and use Traversals instead
matil019 Oct 30, 2019
98d630e
Replace 'view'ing lenses with simple getters for SymMeth and SymVal
matil019 Oct 30, 2019
2709dab
Change the type of allClasses to StG [SymC Global]
matil019 Oct 30, 2019
d39551c
Remove Utilities.symVD
matil019 Oct 31, 2019
a501df7
Modify Desugar.updVis not to throw an error
matil019 Oct 31, 2019
cfa58ac
Change unAlias.aliases to return [SymA Global]
matil019 Oct 31, 2019
1ac6dad
Change isHigherKindedClass to take SymC
matil019 Oct 31, 2019
389b789
Change DataCode.subDecls to take SymT
matil019 Oct 31, 2019
49e0ca1
Add instance Ord for SymVal and SymMeth
matil019 Oct 31, 2019
8ec97a2
Change symInfo to take SymVal
matil019 Oct 31, 2019
1952d83
Remove redundant parameter from match.matchEnum
matil019 Oct 31, 2019
d39d409
Restrict parameter type of dataCode, classCode and instanceCode
matil019 Oct 31, 2019
b2fec3f
Change transDatDcl.newtCheck to take SymT
matil019 Oct 31, 2019
11bdb3f
Clean up the code
matil019 Oct 31, 2019
a6f55d1
Add type signatures, doc comments and remove unused parameters
matil019 Oct 31, 2019
2ed8324
Split TauT.TVar to its own data type
matil019 Nov 2, 2019
15be16c
Change SigmaT.bound :: [TauT s] to :: [TVar s]
matil019 Nov 3, 2019
eecca00
Rename f.c.common.Types.rnTVar to rnTau and add a new rnTVar
matil019 Nov 3, 2019
ea088f2
Change @type SigmaEnv a@ to @TreeMap String (TVar a)@
matil019 Nov 3, 2019
8edcc70
Add TVar.wildTau
matil019 Nov 3, 2019
f331d23
Change transTVar to take and return TVar
matil019 Nov 3, 2019
8ca8b22
Change f.c.passes.Imp.mvar :: Tau to :: TVar a
matil019 Nov 3, 2019
26aa9d5
Change newMeta, newFlexiTyVar and newRigidTyVar to take @TVar QName@
matil019 Nov 3, 2019
a727a3b
Change the types of syntaxes, dvars and tyvar
matil019 Nov 3, 2019
6cdc139
Change wildReturn to return [TVar QName]
matil019 Nov 3, 2019
2070613
Change SymA.vars :: [Tau] to [TVar QName]
matil019 Nov 3, 2019
138dafe
Change TypDcl.vars :: [TauS] to [TVar SName]
matil019 Nov 3, 2019
63ca6f7
Change ClaDcl.var :: TauS to TVar SName
matil019 Nov 3, 2019
30769b4
Change DatDcl.vars :: [TauS] to [TVar SName]
matil019 Nov 4, 2019
0b21074
Change JavDcl.vars :: [TauS] to [TVar SName]
matil019 Nov 4, 2019
3617d95
Change SymT.gargs :: [Tau] to [TVar QName]
matil019 Nov 4, 2019
12aeda0
Change SymC.tau :: Tau to clvar :: TVar QName
matil019 Nov 4, 2019
6fa5679
Add unsafePartialViewMsg
matil019 Nov 6, 2019
db8ef0b
Remove a use of partial function in grammar.Frege
matil019 Nov 6, 2019
3c72117
Remove unreachable case of classCode
matil019 Nov 6, 2019
732f52e
Add transTVar and redefine transBound as an alias of it
matil019 Nov 6, 2019
1787349
Change JavDcl.gargs :: Maybe [TauS] to Maybe [TVar SName]
matil019 Nov 6, 2019
f6d52e1
Add substTVar
matil019 Nov 6, 2019
7a58416
Remove uses of the partial functions (local changes only)
matil019 Nov 3, 2019
33e5a4f
Change the grammar 'gargs' to optionally take [TVar] instead of [TauS]
matil019 Nov 6, 2019
dff8f59
Change NatDcl.gargs :: Maybe [TauS] to Maybe [TVar SName]
matil019 Nov 6, 2019
50c7630
Change SymV.gargs :: [Tau] to [TVar QName]
matil019 Nov 6, 2019
dd8647c
Replace uses of unsafePartialView in Imp with a custom function nTVar
matil019 Nov 6, 2019
9a4e5fc
Remove "unsafe" functions which were meant to be used temporarily
matil019 Nov 6, 2019
89f69c8
Add TauT.traverseApp, a generalization of traversal over TauT
matil019 Nov 7, 2019
fe86bba
Add TauT.headTCon
matil019 Nov 8, 2019
8c7522a
Split TauT.TCon to its own data type
matil019 Nov 7, 2019
1589f7a
Change unused behavior of Methods.matches
matil019 Nov 8, 2019
500627e
Change Typecheck.tc to return TCon QName
matil019 Nov 8, 2019
a0f0791
Add tnameInt, tnameLong, etc. to remove uses of partial functions
matil019 Nov 8, 2019
4279cb5
Remove "unsafe" functions which were meant to be used temporarily
matil019 Nov 8, 2019
f688cda
Remove TauT.traverseApp, traverseTVar and headTCon
matil019 Nov 8, 2019
1e77d7f
Split constructors of RhoT to individual data types
matil019 Nov 10, 2019
1cc9149
Change tauRho to return RhoTau
matil019 Nov 12, 2019
57c7259
Remove Global from unifyRho's parameters
matil019 Nov 12, 2019
73e2699
Remove Global from unifySigma's parameters
matil019 Nov 12, 2019
ce72c8c
Remove Global from sigmaInst's parameters
matil019 Nov 12, 2019
2db83f7
Extract common local function as zapCtx
matil019 Nov 12, 2019
47e22b8
Remove uses of the partial functions (local changes only)
matil019 Nov 12, 2019
41364a5
Remove a use of unsafe function in match.matchNew
matil019 Nov 12, 2019
fe293ab
Remove partial functions meant for temporary use
matil019 Nov 12, 2019
7702767
Change tauRho to return @Maybe (RhoTau QName)@
matil019 Nov 12, 2019
7b31ce4
Add instance Nice (RhoTau t) and (RhoFun t)
matil019 Nov 12, 2019
cd703c5
Change instanceHead to take and return RhoTau
matil019 Nov 12, 2019
14851f2
Add symItau to remove the partial case in instFun and docSym
matil019 Nov 12, 2019
bf15e66
Remove unneeded TODO comments
matil019 Nov 12, 2019
8902a85
Remove uses of unnecessary lenses
matil019 Nov 12, 2019
094b507
Reduce another use of lenses
matil019 Nov 13, 2019
cce1b07
Rewrite substRigidRho not to use the record update syntax
matil019 Nov 13, 2019
ec9b85a
Move the implementation of instance RhoT to its constructors
matil019 Nov 13, 2019
0d51a6c
Clean up the code
matil019 Nov 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
356 changes: 165 additions & 191 deletions frege/compiler/Classes.fr

Large diffs are not rendered by default.

135 changes: 70 additions & 65 deletions frege/compiler/GenMeta.fr
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,21 @@ genmeta = do

-- let ops = [ mkOp (s,x) | (s,x) <- each g.optab, x >= LOP0 ]

let asyms = [sym | sym@SymA {pos} <- values g.thisTab, sym.vis!=Private]
let asyms = [sym | SymbolT.A sym <- values g.thisTab, sym.vis!=Private]
symas <- liftStG $ mapSt annoSymA asyms


let csyms = [sym | sym@SymC {pos} <- values g.thisTab, sym.vis!=Private]
let csyms = [sym | SymbolT.C sym <- values g.thisTab, sym.vis!=Private]
symcs <- liftStG $ mapSt annoSymC csyms

let isyms = [sym | sym@SymI {pos} <- values g.thisTab, sym.vis!=Private]
let isyms = [sym | SymbolT.I sym <- values g.thisTab, sym.vis!=Private]
symis <- liftStG $ mapSt annoSymI isyms

let tsyms = [sym | sym@SymT {pos} <- values g.thisTab, sym.vis!=Private]
let tsyms = [sym | SymbolT.T sym <- values g.thisTab, sym.vis!=Private]
symts <- liftStG $ mapSt annoSymT tsyms

symvs <- liftStG $ envValues g.thisTab
symls <- liftStG $ envLinks g.thisTab
symvs <- liftStG $ envValues $ values g.thisTab
symls <- liftStG $ envLinks $ values g.thisTab

g <- getSTT
ctime <- liftIO (System.currentTimeMillis())
Expand Down Expand Up @@ -200,23 +200,23 @@ genmeta = do


--- create annotations for all SymV in an environment
envValues :: Symtab -> StG [DOCUMENT]
envValues env = do
let vsyms = [sym | sym@SymV {pos} <- values env, sym.vis != Private]
envValues :: [Symbol] -> StG [DOCUMENT]
envValues envsyms = do
let vsyms = [sym | SymbolT.V sym <- envsyms, sym.vis != Private]
symvs <- mapSt annoSymV vsyms
stio symvs

--- create annotations for all SymL in an environment
envLinks :: Symtab -> StG [DOCUMENT]
envLinks env = do
envLinks :: [Symbol] -> StG [DOCUMENT]
envLinks envsyms = do
g <- getST
let syms = [ sym | sym@SymL {alias} <- values env, sym.vis != Private]
let syms = [ sym | SymbolT.L sym <- envsyms, sym.vis != Private]
mapM annoSymL syms

--- create annotations for all SymD in an environment
envCons :: Symtab -> StG [DOCUMENT]
envCons env = do
let syms = [sym | sym@SymD {pos} <- values env]
envCons :: [Symbol] -> StG [DOCUMENT]
envCons envsyms = do
let syms = [sym | SymbolT.D sym <- envsyms]
mapSt annoSymD syms


Expand Down Expand Up @@ -270,10 +270,10 @@ kindIndex k = do



flatTau (tv@TVar {var,kind}) = do
suba <- kindIndex (substKind empty var tv.{kind=KType} kind) -- beware of recursion
flatTau (TauT.Var (tv@TVar{var,kind})) = do
suba <- kindIndex (substKind empty var (TauT.Var tv.{kind=KType}) kind) -- beware of recursion
return (TauA {kind=3,tcon=Nothing,suba,subb=0,tvar=var})
flatTau (TCon {name}) = do
flatTau (TauT.Con TCon{name}) = do
return (TauA {kind=2,tcon=Just name,suba=0,subb=0,tvar=""})
flatTau (TApp a b) = do
suba <- tauIndex a
Expand Down Expand Up @@ -321,22 +321,24 @@ flatCtx (Ctx {pos, cname, tau}) = do
-- U.logmsg TRACE9 pos (tau.nice g)
tau <- tauIndex tau
stio (CtxA {clas=cname,tau})


flatRho (RhoFun ctx sig rho) = do
flatRho :: Rho -> StG RhoA
flatRho (RhoT.Fun (RhoFun ctx sig rho)) = do
cont <- mapSt flatCtx ctx
sigma <- sigIndex sig
rhotau <- rhoIndex rho
stio (RhoA {rhofun=true,cont,sigma,rhotau})
flatRho (RhoTau ctx tau) = do
flatRho (RhoT.Tau (RhoTau ctx tau)) = do
cont <- mapSt flatCtx ctx
rhotau <- tauIndex tau
stio (RhoA {rhofun=false,cont,sigma=0,rhotau})

rhoIndex :: Rho -> StG Int
rhoIndex rho = do
rhoa <- flatRho rho
raIndex rhoa

raIndex :: RhoA -> StG Int
raIndex ra = do
g <- getST
case g.rTree.lookup ra of
Expand Down Expand Up @@ -429,9 +431,9 @@ expIndex exp = encodeX exp >>= mbIndex
-- the list of symbols corresponding to the let bound names
syms ← mapM U.findV env
-- make (and encode) the list of sigmas
sigs ← mapM (\s -> if Symbol.anno s then sigIndex s.typ else return (-1)) syms
sigs ← mapM (\s -> if SymV.anno s then sigIndex s.typ else return (-1)) syms
-- make and encode the list of expressions
exps ← mapM (maybe (return 0) (>>=expIndex) . Symbol.expr) syms
exps ← mapM (maybe (return 0) (>>=expIndex) . _.expr) syms
exp ← expIndex ex
if exp == 0 || any (<1) exps || any (<1) qexs
then return Nothing
Expand Down Expand Up @@ -503,33 +505,35 @@ eaIndex expa = do
changeST Global.{gen <- GenSt.{xunique <- (1+)} • GenSt.{xTree <- insert expa g.xunique}}
stio g.xunique

annoSymA :: SymA Global -> StG DOCUMENT
annoSymA syma = do
g ← getST
vars <- mapSt tauIndex (Symbol.vars syma)
typ <- sigIndex (Symbol.typ syma)
vars <- mapSt (tauIndex . TauT.Var) syma.vars
typ <- sigIndex syma.typ
kind <- kindIndex syma.kind
let a = meta g "SymA" [
("offset", anno syma.pos.first.offset),
("name", annoG g (Symbol.name syma)),
("name", annoG g syma.name),
("vars", anno vars),
("typ", anno typ),
("kind", anno kind),
("publik", if syma.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc syma))
("doc", maybe PP.nil anno syma.doc)
]
stio a

annoSymV :: SymV Global -> StG DOCUMENT
annoSymV symv = do
g <- getST
gargs mapM tauIndex symv.gargs
case isPSigma (Symbol.typ symv) of
gargs <- mapM (tauIndex . TauT.Var) symv.gargs
case isPSigma symv.typ of
true -> E.fatal symv.pos (text (symv.nice g ++ " has no type."))
false -> do
sig <- sigIndex (Symbol.typ symv)
sig <- sigIndex symv.typ
-- inline candidates must be safe tail calls and no loops
let !classop
| MName tname _ <- symv.name,
Just SymC{} <- g.find tname = isJust symv.expr -- this is a class member
Just (SymbolT.C _) <- g.find tname = isJust symv.expr -- this is a class member
| otherwise = false
!candidate = classop || symv.exported
-- U.logmsg TRACE9 symv.pos (text ((nicer symv g)
Expand Down Expand Up @@ -580,32 +584,30 @@ annoSymV symv = do
changeST Global.{gen <- _.{expSym <- insert symv.name exp}}
stio a

annoSymL :: SymL Global -> StG DOCUMENT
annoSymL sym = do
g ← getST
pure $ meta g "SymL" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("alias", annoG g (Symbol.alias sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("alias", annoG g sym.alias),
("publik", if sym.vis == Public then PP.nil else anno false),
-- ("doc", maybe PP.nil anno (Symbol.doc sym))
]

annoSymD :: SymD Global -> StG DOCUMENT
annoSymD sym = do
g <- getST
typ <- sigIndex (Symbol.typ sym)
typ <- sigIndex sym.typ
fields <- mapSt conFieldA sym.flds
let a = meta g "SymD" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
-- ("stri", lit sym.strsig.show),
("cid", anno (Symbol.cid sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("cid", anno sym.cid),
("typ", anno typ),
("fields", annoListG g fields),
-- ("fnms", if null fnms || all null fnms then PP.nil else anno fnms),
-- ("ftys", if null ftys then PP.nil else anno ftys),
("priv", if sym.vis == Private then anno true else PP.nil),
("publik", if sym.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc sym)),
("doc", maybe PP.nil anno sym.doc),
("op", if sym.op == defaultInfix then PP.nil else anno (ord sym.op))]
stio a

Expand All @@ -626,50 +628,53 @@ instance AnnoG ConFieldA where
]


annoSymC :: SymC Global -> StG DOCUMENT
annoSymC sym = do
g ← getST
tau <- tauIndex (Symbol.tau sym)
meml <- envLinks (Symbol.env sym)
memv <- envValues (Symbol.env sym)
tau <- tauIndex $ TauT.Var sym.clvar
meml <- envLinks $ map _.toSymbol $ values sym.meth
memv <- envValues $ map _.toSymbol $ values sym.meth
let a = meta g "SymC" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("tau", anno tau),
("sups", if null sym.supers then PP.nil else annoListG g sym.supers),
("ins1", if null sym.insts then PP.nil else annoListG g (map fst sym.insts)),
("ins2", if null sym.insts then PP.nil else annoListG g (map snd sym.insts)),
("lnks", some meml),
("funs", some memv),
("publik", if sym.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc sym))]
("doc", maybe PP.nil anno sym.doc)]
stio a

annoSymI :: SymI Global -> StG DOCUMENT
annoSymI sym = do
g ← getST
typ <- sigIndex (Symbol.typ sym)
meml <- envLinks (Symbol.env sym)
memv <- envValues (Symbol.env sym)
typ <- sigIndex sym.typ
meml <- envLinks $ map _.toSymbol $ values sym.meth
memv <- envValues $ map _.toSymbol $ values sym.meth
let a = meta g "SymI" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("clas", annoG g (Symbol.clas sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("clas", annoG g sym.clas),
("typ", anno typ),
("lnks", some meml),
("funs", some memv),
("doc", maybe PP.nil anno (Symbol.doc sym))]
("doc", maybe PP.nil anno sym.doc)]
stio a

annoSymT :: SymT Global -> StG DOCUMENT
annoSymT sym = do
g ← getST
typ <- sigIndex (Symbol.typ sym)
memc <- envCons (Symbol.env sym)
meml <- envLinks (Symbol.env sym)
memv <- envValues (Symbol.env sym)
typ <- sigIndex sym.typ
memc <- envCons $ values sym.env
meml <- envLinks $ values sym.env
memv <- envValues $ values sym.env
kind <- kindIndex sym.kind
gargs mapM tauIndex sym.gargs
gargs <- mapM (tauIndex . TauT.Var) sym.gargs
let a = meta g "SymT" [
("offset", anno (Symbol.pos sym).first.offset),
("name", annoG g (Symbol.name sym)),
("offset", anno sym.pos.first.offset),
("name", annoG g sym.name),
("typ", anno typ),
("kind", anno kind),
("cons", some memc),
Expand All @@ -679,8 +684,8 @@ annoSymT sym = do
("isEnum", if sym.enum then anno true else PP.nil),
("pur", if sym.pur then anno true else PP.nil),
("newt", if sym.newt then anno true else PP.nil),
("nativ", maybe PP.nil anno (Symbol.nativ sym)),
("nativ", maybe PP.nil anno sym.nativ),
("gargs", if null gargs then PP.nil else anno gargs),
("publik", if sym.vis == Public then PP.nil else anno false),
("doc", maybe PP.nil anno (Symbol.doc sym))]
("doc", maybe PP.nil anno sym.doc)]
pure a
5 changes: 3 additions & 2 deletions frege/compiler/Javatypes.fr
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ package frege.compiler.Javatypes where
import frege.compiler.Utilities as U()
import frege.lib.PP (text)

import Compiler.types.Symbols(SymbolT)
import Compiler.types.Positions(Position)
import Compiler.types.Global as G

Expand Down Expand Up @@ -106,8 +107,8 @@ findAllSupers name
Left l -> liftStG do
g <- getST
syms <- mapM U.findT (U.typesOfNativ name g)
let oss = filter (g.ourSym) syms
pos = if null oss then Position.null else (head oss).pos
let oss = filter (g.ourSym . SymbolT.T) syms
pos = if null oss then Position.null else (head oss).pos
E.error pos (text ("`" ++ name ++ "` is not a known java class"))
changeST Global.{javaEnv <- _.delete name}
Right c -> do
Expand Down
Loading