Commit 6f795a69 authored by Michael Hanus 's avatar Michael Hanus

External interfaces redefined w.r.t. new pakcs version

parent aa2a9946
<?xml version="1.0" standalone="no"?>
<!DOCTYPE primitives SYSTEM "http://www.informatik.uni-kiel.de/~pakcs/primitives.dtd">
<primitives>
<primitive name="getCPUTime" arity="0">
<library>prim_system</library>
<entry>prim_getCPUTime</entry>
</primitive>
<primitive name="getElapsedTime" arity="0">
<library>prim_system</library>
<entry>prim_getElapsedTime</entry>
</primitive>
</primitives>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Definitions of builtins of module System.CPUTime
%
:- (current_module(prologbasics) -> true ; use_module('../prologbasics')).
'System.CPUTime.getCPUTime'(MS) :- getRunTime(MS).
'System.CPUTime.getElapsedTime'(MS) :- getElapsedTime(MS).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<?xml version="1.0" standalone="no"?>
<!DOCTYPE primitives SYSTEM "http://www.informatik.uni-kiel.de/~pakcs/primitives.dtd">
<primitives>
<primitive name="getArgs" arity="0">
<library>prim_system</library>
<entry>prim_getArgs</entry>
</primitive>
<primitive name="prim_getEnviron" arity="1">
<library>prim_system</library>
<entry>prim_getEnviron</entry>
</primitive>
<primitive name="prim_setEnviron" arity="2">
<library>prim_system</library>
<entry>prim_setEnviron</entry>
</primitive>
<primitive name="prim_unsetEnviron" arity="1">
<library>prim_system</library>
<entry>prim_unsetEnviron</entry>
</primitive>
<primitive name="getHostname" arity="0">
<library>prim_system</library>
<entry>prim_getHostname</entry>
</primitive>
<primitive name="getProgName" arity="0">
<library>prim_system</library>
<entry>prim_getProgName</entry>
</primitive>
<primitive name="isWindows" arity="0">
<library>prim_system</library>
<entry>isWindows</entry>
</primitive>
</primitives>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Definitions of builtins of module System.Environment
%
:- (current_module(prologbasics) -> true ; use_module('../prologbasics')).
:- (current_module(basics) -> true ; use_module('../basics')).
'System.Environment.getArgs'(StringArgs) :-
(rtArgs(Args) -> true ; getProgramArgs(Args)),
map2M(basics:atom2String,Args,StringArgs).
'System.Environment.prim_getEnviron'(Var,Value) :-
string2Atom(Var,AtomVar),
(getEnv(AtomVar,AtomValue) -> atom2String(AtomValue,Value)
; Value = []). % empty string if undefined
'System.Environment.prim_setEnviron'(Var,Value,'Prelude.()') :-
string2Atom(Var,AtomVar),
string2Atom(Value,AtomValue),
catch(setEnv(AtomVar,AtomValue), _,
prolog:set_system_property(AtomVar,AtomValue)).
'System.Environment.prim_unsetEnviron'(Var,'Prelude.()') :-
string2Atom(Var,AtomVar),
catch(unsetEnv(AtomVar), _,
'System.Environment.prim_setEnviron'(Var,[],'Prelude.()')).
'System.Environment.getHostname'(String) :-
getHostname(Name),
atom2String(Name,String).
'System.Environment.getProgName'(String) :-
user:currentModuleFile(Name,_),
atom2String(Name,String).
'System.Environment.isWindows'(Flag) :-
getEnv('COMSPEC', _) ->
% Windows systems define this environment variable...
Flag = 'Prelude.True'
; Flag = 'Prelude.False'.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
<?xml version="1.0" standalone="no"?>
<!DOCTYPE primitives SYSTEM "http://www.informatik.uni-kiel.de/~pakcs/primitives.dtd">
<primitives>
<primitive name="handle_eq" arity="2">
<library>prim_io</library>
<entry>handle_eq</entry>
</primitive>
<primitive name="stdin" arity="0">
<library>prim_io</library>
<entry>prim_stdin</entry>
</primitive>
<primitive name="stdout" arity="0">
<library>prim_io</library>
<entry>prim_stdout</entry>
</primitive>
<primitive name="stderr" arity="0">
<library>prim_io</library>
<entry>prim_stderr</entry>
</primitive>
<primitive name="prim_openFile" arity="2">
<library>prim_io</library>
<entry>prim_openFile</entry>
</primitive>
<primitive name="prim_hClose" arity="1">
<library>prim_io</library>
<entry>prim_hClose</entry>
</primitive>
<primitive name="prim_hFlush" arity="1">
<library>prim_io</library>
<entry>prim_hFlush</entry>
</primitive>
<primitive name="prim_hIsEOF" arity="1">
<library>prim_io</library>
<entry>prim_hIsEOF</entry>
</primitive>
<primitive name="prim_hSeek" arity="3">
<library>prim_io</library>
<entry>prim_hSeek</entry>
</primitive>
<primitive name="prim_hWaitForInput" arity="2">
<library>prim_io</library>
<entry>prim_hWaitForInput[raw]</entry>
......@@ -49,24 +13,4 @@
<library>prim_io</library>
<entry>prim_hWaitForInputsOrMsg[raw]</entry>
</primitive>
<primitive name="prim_hGetChar" arity="1">
<library>prim_io</library>
<entry>prim_hGetChar</entry>
</primitive>
<primitive name="prim_hPutChar" arity="2">
<library>prim_io</library>
<entry>prim_hPutChar</entry>
</primitive>
<primitive name="prim_hIsReadable" arity="1">
<library>prim_io</library>
<entry>prim_hIsReadable</entry>
</primitive>
<primitive name="prim_hIsWritable" arity="1">
<library>prim_io</library>
<entry>prim_hIsWritable</entry>
</primitive>
<primitive name="prim_hIsTerminalDevice" arity="1">
<library>prim_io</library>
<entry>prim_hIsTerminalDevice</entry>
</primitive>
</primitives>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Definitions of builtins of module System.IO
%
:- (current_module(prologbasics) -> true ; use_module('../prologbasics')).
:- (current_module(basics) -> true ; use_module('../basics')).
% to implement IO.prim_hWaitForInputsOrMsg:
:- (current_module(prim_ports) -> true ; ensure_loaded(prim_ports)).
% equality of two handles:
'System.IO.handle_eq'(H1,H2,B) :-
(H1=H2 -> B='Prelude.True' ; B='Prelude.False').
'System.IO.stdin'(Stream) :- stdInputStream(Stream).
'System.IO.stdout'(Stream) :- stdOutputStream(Stream).
'System.IO.stderr'(Stream) :- stdErrorStream(Stream).
'System.IO.prim_openFile'(A,Mode,Stream) :-
string2Atom(A,FName),
curryFileMode2plmode(Mode,PMode),
fileOpenOptions(Options),
open(FName,PMode,Stream,Options).
curryFileMode2plmode('System.IO.ReadMode',read).
curryFileMode2plmode('System.IO.WriteMode',write).
curryFileMode2plmode('System.IO.AppendMode',append).
'System.IO.prim_hClose'('$stream'('$inoutstream'(In,Out)),'Prelude.()') :- !,
flush_output(Out),
close(Out),
(In==Out -> true ; close(In)).
'System.IO.prim_hClose'(Stream,'Prelude.()') :-
(isOutputStream(Stream) -> flush_output(Stream) ; true),
close(Stream).
'System.IO.prim_hFlush'('$stream'('$inoutstream'(_,Out)),'Prelude.()') :- !,
flush_output(Out).
'System.IO.prim_hFlush'(Stream,'Prelude.()') :-
(isOutputStream(Stream) -> flush_output(Stream) ; true).
'System.IO.prim_hIsEOF'('$stream'('$inoutstream'(In,_)),B) :- !,
(atEndOfStream(In) -> B='Prelude.True' ; B='Prelude.False').
'System.IO.prim_hIsEOF'(Stream,B) :-
(atEndOfStream(Stream) -> B='Prelude.True' ; B='Prelude.False').
'System.IO.prim_hSeek'(Handle,SeekMode,Pos,'Prelude.()') :-
currySeekMode2plmode(SeekMode,PlSM),
seek(Handle,Pos,PlSM,_).
currySeekMode2plmode('System.IO.AbsoluteSeek',bof).
currySeekMode2plmode('System.IO.RelativeSeek',current).
currySeekMode2plmode('System.IO.SeekFromEnd',eof).
'System.IO.prim_hGetChar'('$stream'('$inoutstream'(In,_)),C) :- !,
get_code(In,N), char_int(C,N).
'System.IO.prim_hGetChar'(Stream,C) :-
get_code(Stream,N), char_int(C,N).
'System.IO.prim_hPutChar'('$stream'('$inoutstream'(_,Out)),C,'Prelude.()') :- !,
char_int(C,N), put_code(Out,N).
'System.IO.prim_hPutChar'(Stream,C,'Prelude.()') :-
char_int(C,N), put_code(Stream,N).
'System.IO.prim_hIsReadable'('$stream'('$inoutstream'(_,_)),'Prelude.True') :-
!.
'System.IO.prim_hIsReadable'(Stream,B) :-
(isInputStream(Stream) -> B='Prelude.True' ; B='Prelude.False').
'System.IO.prim_hIsWritable'('$stream'('$inoutstream'(_,_)),'Prelude.True') :-
!.
'System.IO.prim_hIsWritable'(Stream,B) :-
(isOutputStream(Stream) -> B='Prelude.True' ; B='Prelude.False').
'System.IO.prim_hIsTerminalDevice'('$stream'('$inoutstream'(_,S)),R) :- !,
prim_hIsTerminalDevice(S,R).
'System.IO.prim_hIsTerminalDevice'(Stream,B) :-
(isTerminalDeviceStream(Stream) -> B='Prelude.True'
; B='Prelude.False').
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment