Commit f97308d7 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-06-28 18:35:47 by afrisch] Optional 'external' keyword

Original author: afrisch
Date: 2004-06-28 18:35:47+00:00
parent 242608ca
......@@ -16,19 +16,19 @@ let map_complex (f : (Float,Float)->Float)(c : { x = Float; y = Float })
let pp (x : Any) : Latin1 = string_of x
let exists = external "Sys.file_exists"
let exists = Sys.file_exists
let i = c:j
let home = external "Sys.getenv" "HOME"
let home = Sys.getenv "HOME"
let stdin : !Unix.file_descr = external "Unix.stderr"
let unix_write = external "Unix.write"
let str_len = external "String.length"
let stdin : !Unix.file_descr = Unix.stderr
let unix_write = Unix.write
let str_len = String.length
let _ = unix_write stdin home 0 (str_len home)
let [] = external "Unix.sleep" 1
let [] = Unix.sleep 1
let listmap = external { "List.map" Int Int }
......
......@@ -846,7 +846,12 @@ let rec expr env loc = function
exp loc fv (Typed.Forget (e,t))
| Var s ->
(match Ns.split_qname s with
| "", id -> let id = ident id in
| "", id ->
let s = U.get_str id in
if String.contains s '.' then
extern loc env s []
else
let id = ident id in
exp loc (Fv.singleton id) (Typed.Var id)
| cu, id ->
let cu = find_cu (U.mk cu) env in
......@@ -940,6 +945,9 @@ let rec expr env loc = function
let (fv,e) = expr env loc e and t = typ env t in
exp loc fv (Typed.Ref (e,t))
| External (s,args) ->
extern loc env s args
and extern loc env s args =
let args = List.map (typ env) args in
let (i,t) = Externals.resolve s args in
exp loc Fv.empty (Typed.External (t,i))
......
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