mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 13:37:57 +03:00
Made System.exit return 'a' instead of ().
This commit is contained in:
parent
cda502b9d2
commit
36274a29d3
@ -1,5 +1,4 @@
|
||||
(defmodule System
|
||||
(register exit (Fn [Int] ()))
|
||||
(register free (Fn [t] ()))
|
||||
(register time (Fn [] Int))
|
||||
(register srand (Fn [Int] ()))
|
||||
|
@ -650,10 +650,6 @@ string Bool_format(string* str, bool b) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void System_exit(int code) {
|
||||
exit(code);
|
||||
}
|
||||
|
||||
void System_free(void *p) {
|
||||
CARP_FREE(p);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ arrayModule = Env { envBindings = bindings, envParent = Nothing, envModuleName =
|
||||
, templateSort
|
||||
]
|
||||
|
||||
-- | The pointer module contains functions for dealing with pointers.
|
||||
-- | The Pointer module contains functions for dealing with pointers.
|
||||
pointerModule :: Env
|
||||
pointerModule = Env { envBindings = bindings, envParent = Nothing, envModuleName = Just "Pointer", envUseModules = [], envMode = ExternalEnv }
|
||||
where bindings = Map.fromList [ templatePointerCopy ]
|
||||
@ -65,6 +65,22 @@ templatePointerCopy = defineTemplate
|
||||
,"}"])
|
||||
(const [])
|
||||
|
||||
-- | The System module contains functions for various OS related things like timing and process control.
|
||||
systemModule :: Env
|
||||
systemModule = Env { envBindings = bindings, envParent = Nothing, envModuleName = Just "System", envUseModules = [], envMode = ExternalEnv }
|
||||
where bindings = Map.fromList [ templateExit ]
|
||||
|
||||
-- | A template function for exiting.
|
||||
templateExit :: (String, Binder)
|
||||
templateExit = defineTemplate
|
||||
(SymPath ["System"] "exit")
|
||||
(FuncTy [IntTy] (VarTy "a"))
|
||||
(toTemplate "$a $NAME (int code)")
|
||||
(toTemplate $ unlines ["$DECL {"
|
||||
," exit(code);"
|
||||
,"}"])
|
||||
(const [])
|
||||
|
||||
-- | The dynamic module contains dynamic functions only available in the repl and during compilation.
|
||||
dynamicModule :: Env
|
||||
dynamicModule = Env { envBindings = bindings, envParent = Nothing, envModuleName = Just "Dynamic", envUseModules = [], envMode = ExternalEnv }
|
||||
@ -139,6 +155,7 @@ startingGlobalEnv noArray =
|
||||
]
|
||||
++ (if noArray then [] else [("Array", Binder (XObj (Mod arrayModule) Nothing Nothing))])
|
||||
++ [("Pointer", Binder (XObj (Mod pointerModule) Nothing Nothing))]
|
||||
++ [("System", Binder (XObj (Mod systemModule) Nothing Nothing))]
|
||||
++ [("Dynamic", Binder (XObj (Mod dynamicModule) Nothing Nothing))]
|
||||
|
||||
-- | The type environment (containing deftypes and interfaces) before any code is run.
|
||||
|
Loading…
Reference in New Issue
Block a user