History

Merge branch 'master' of github.com:edwinb/Idris2 into fully-abstract-records

Ohad Kammar committed 6 years ago

Commit f7775312 parents 1fcac7a 884d4ad8 files · +17 −18Browse files

Unified · Split

8 files
  1. src/Compiler/CompileExpr.idr +0 −5
  2. src/Compiler/Inline.idr +1 −1
  3. src/Compiler/Scheme/Chez.idr +6 −1
  4. src/Compiler/Scheme/Common.idr +3 −3
  5. src/Compiler/Scheme/Racket.idr +6 −2
  6. src/Core/TTC.idr +0 −1
  7. src/TTImp/ProcessData.idr +0 −4
  8. src/Utils/Binary.idr +1 −1
src/Compiler/CompileExpr.idr+0−5
@@ -223,7 +223,6 @@ mutual · 222 unmodified lines
223223 pure $ natHack res
224224
225225 mutual
226− -- In the below, treat %World, and newtypes, as default cases
227226 conCases : {auto c : Ref Ctxt Defs} ->
228227 NameTags -> Name -> List (CaseAlt vars) ->
229228 Core (List (CConAlt vars))
@@ -244,8 +243,6 @@ mutual · 14 unmodified lines
244243 NameTags -> Name -> List (CaseAlt vars) ->
245244 Core (List (CConstAlt vars))
246245 constCases tags n [] = pure []
247− constCases tags n (ConstCase WorldVal sc :: ns)
248− = constCases tags n ns
249246 constCases tags n (ConstCase x sc :: ns)
250247 = pure $ MkConstAlt x !(toCExpTree tags n sc) ::
251248 !(constCases tags n ns)
@@ -258,8 +255,6 @@ mutual · 6 unmodified lines
258255 getDef fc scr tags n [] = pure Nothing
259256 getDef fc scr tags n (DefaultCase sc :: ns)
260257 = pure $ Just !(toCExpTree tags n sc)
261− getDef fc scr tags n (ConstCase WorldVal sc :: ns)
262− = pure $ Just !(toCExpTree tags n sc)
263258 getDef {vars} fc scr tags n (ConCase x tag args sc :: ns)
264259 = do defs <- get Ctxt
265260 case !(lookupDefExact x (gamma defs)) of
src/Compiler/Inline.idr+1−1
@@ -190,7 +190,7 @@ mutual · 189 unmodified lines
190190 | Nothing => pure (unload stk (CRef fc n))
191191 let arity = getArity def
192192 if (Inline `elem` flags gdef) && (not (n `elem` rec))
193− then do ap <- tryApply (n :: rec) stk env def
193+ then do ap <- tryApply (n :: rec) stk env def
194194 pure $ maybe (unloadApp arity stk (CRef fc n)) id ap
195195 else pure $ unloadApp arity stk (CRef fc n)
196196 eval {vars} {free} rec env [] (CLam fc x sc)
src/Compiler/Scheme/Chez.idr+6−1
@@ -202,11 +202,16 @@ cCall fc cfn clib args ret · 201 unmodified lines
202202 applyLams n (Nothing :: as) = applyLams ("(" ++ n ++ " #f)") as
203203 applyLams n (Just a :: as) = applyLams ("(" ++ n ++ " " ++ a ++ ")") as
204204
205+ getVal : String -> String
206+ getVal str = "(vector-ref " ++ str ++ "2)"
207+
205208 mkFun : List CFType -> CFType -> String -> String
206209 mkFun args ret n
207210 = let argns = mkNs 0 args in
208211 "(lambda (" ++ showSep " " (mapMaybe id argns) ++ ") " ++
209− (applyLams n argns ++ ")")
212+ (case ret of
213+ CFIORes _ => getVal (applyLams n argns) ++ ")"
214+ _ => applyLams n argns ++ ")")
210215
211216 notWorld : CFType -> Bool
212217 notWorld CFWorld = False
src/Compiler/Scheme/Common.idr+3−3
@@ -234,7 +234,7 @@ toPrim pn = Unknown pn · 233 unmodified lines
234234
235235 export
236236 mkWorld : String -> String
237−mkWorld res = res -- MkIORes is a newtype now! schConstructor 0 ["#f", res, "#f"] -- MkIORes
237+mkWorld res = schConstructor 0 ["#f", res, "#f"] -- MkIORes
238238
239239 schConstant : (String -> String) -> Constant -> String
240240 schConstant _ (I x) = show x
@@ -346,11 +346,11 @@ parameters (schExtPrim : Int -> ExtPrim -> List NamedCExp -> Core String, · 105 unmodified lines
346346 = pure $ mkWorld ("(apply (eval (string->symbol " ++ !(schExp i fn) ++")) "
347347 ++ !(readArgs i args) ++ ")")
348348 schExtCommon i PutStr [arg, world]
349− = pure $ "(display " ++ !(schExp i arg) ++ ") " ++ mkWorld (schConstructor 0 []) -- code for MkUnit
349+ = pure $ "(begin (display " ++ !(schExp i arg) ++ ") " ++ mkWorld (schConstructor 0 []) ++ ")" -- code for MkUnit
350350 schExtCommon i GetStr [world]
351351 = pure $ mkWorld "(blodwen-get-line (current-input-port))"
352352 schExtCommon i PutChar [arg, world]
353− = pure $ "(display " ++ !(schExp i arg) ++ ") " ++ mkWorld (schConstructor 0 []) -- code for MkUnit
353+ = pure $ "(begin (display " ++ !(schExp i arg) ++ ") " ++ mkWorld (schConstructor 0 []) ++ ")" -- code for MkUnit
354354 schExtCommon i GetChar [world]
355355 = pure $ mkWorld "(blodwen-get-char (current-input-port))"
356356 schExtCommon i FileOpen [file, mode, bin, world]
src/Compiler/Scheme/Racket.idr+6−2
@@ -180,11 +180,15 @@ cCall fc cfn libspec args ret · 179 unmodified lines
180180 applyLams n (Just (a, ty) :: as)
181181 = applyLams ("(" ++ n ++ " " ++ cToRkt ty a ++ ")") as
182182
183+ getVal : CFType -> String -> String
184+ getVal ty str = rktToC ty ("(vector-ref " ++ str ++ "2)")
185+
183186 mkFun : List CFType -> CFType -> String -> String
184187 mkFun args ret n
185188 = let argns = mkNs 0 args in
186− "(lambda (" ++ showSep " " (map fst (mapMaybe id argns)) ++ ") " ++
187− (applyLams n argns ++ ")")
189+ (case ret of
190+ CFIORes rt => getVal rt (applyLams n argns) ++ ")"
191+ _ => applyLams n argns ++ ")")
188192
189193 notWorld : CFType -> Bool
190194 notWorld CFWorld = False
src/Core/TTC.idr+0−1
@@ -973,4 +973,3 @@ Core.Context.decode gam idx update (Coded bin) · 972 unmodified lines
973973 when update $ coreLift $ writeArray arr idx (Decoded def')
974974 pure def'
975975 Core.Context.decode gam idx update (Decoded def) = pure def
976−
src/TTImp/ProcessData.idr+0−4
@@ -199,10 +199,6 @@ getRelevantArg : Defs -> Nat -> Maybe Nat -> NF [] -> Core (Maybe Nat) · 198 unmodified lines
199199 getRelevantArg defs i rel (NBind fc _ (Pi Rig0 _ _) sc)
200200 = getRelevantArg defs (1 + i) rel
201201 !(sc defs (toClosure defaultOpts [] (Erased fc False)))
202−-- %World is never inspected, so might as well be deleted from data types
203−getRelevantArg defs i rel (NBind fc _ (Pi _ _ (NPrimVal _ WorldType)) sc)
204− = getRelevantArg defs (1 + i) rel
205− !(sc defs (toClosure defaultOpts [] (Erased fc False)))
206202 getRelevantArg defs i Nothing (NBind fc _ (Pi _ _ _) sc) -- found a relevant arg
207203 = getRelevantArg defs (1 + i) (Just i)
208204 !(sc defs (toClosure defaultOpts [] (Erased fc False)))
src/Utils/Binary.idr+1−1
@@ -114,7 +114,7 @@ initBinaryS s · 113 unmodified lines
114114 extendBinary : Int -> Binary -> Core Binary
115115 extendBinary need (MkBin buf l s u)
116116 = do let newsize = s * 2
117− let s' = if newsize < need
117+ let s' = if (newsize - l) < need
118118 then newsize + need
119119 else newsize
120120 Just buf' <- coreLift $ resizeBuffer buf s'

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t