text
stringlengths
0
601k
type eventInfo = { mutable ev_Above : int ; mutable ev_ButtonNumber : int ; mutable ev_Count : int ; mutable ev_Detail : string ; mutable ev_Focus : bool ; mutable ev_Height : int ; mutable ev_KeyCode : int ; mutable ev_Mode : string ; mutable ev_OverrideRedirect : bool ; mutable ev_Place : string ; mutable ev_State : ...
type eventField = [ | ` Above | ` ButtonNumber | ` Count | ` Detail | ` Focus | ` Height | ` KeyCode | ` Mode | ` OverrideRedirect | ` Place | ` State | ` Time | ` Width | ` MouseX | ` MouseY | ` Char | ` BorderWidth | ` SendEvent | ` KeySymString | ` KeySymInt | ` RootWindow | ` SubWindow | ` Type | ` Widget | ` RootX...
let filleventInfo ev v : eventField -> unit = function | ` Above -> ev . ev_Above <- int_of_string v | ` ButtonNumber -> ev . ev_ButtonNumber <- int_of_string v | ` Count -> ev . ev_Count <- int_of_string v | ` Detail -> ev . ev_Detail <- v | ` Focus -> ev . ev_Focus <- v = " 1 " | ` Height -> ev . ev_Height <- int_of_...
let wrapeventInfo f ( what : eventField list ) = let ev = { ev_Above = 0 ; ev_ButtonNumber = 0 ; ev_Count = 0 ; ev_Detail = " " ; ev_Focus = false ; ev_Height = 0 ; ev_KeyCode = 0 ; ev_Mode = " " ; ev_OverrideRedirect = false ; ev_Place = " " ; ev_State = " " ; ev_Time = 0 ; ev_Width = 0 ; ev_MouseX = 0 ; ev_MouseY = 0...
let rec writeeventField : eventField list -> string = function | [ ] -> " " | field :: rest -> begin match field with | ` Above -> " % a " | ` ButtonNumber " -> % b " | ` Count -> " % c " | ` Detail -> " % d " | ` Focus -> " % f " | ` Height -> " % h " | ` KeyCode -> " % k " | ` Mode -> " % m " | ` OverrideRedirect -> ...
type color = | NamedColor of string | Black | White | Red | Green | Blue | Yellow ; ; ## else
type color = [ | ` Color of string | ` Black | ` White | ` Red | ` Green | ` Blue | ` Yellow ] ; ; ## endif
type cursor = | XCursor of string | XCursorFg of string * color | XCursortFgBg of string * color * color | CursorFileFg of string * color | CursorMaskFile of string * string * color * color ; ; ## else
type cursor = [ | ` Xcursor of string | ` Xcursorfg of string * color | ` Xcursorfgbg of string * color * color | ` Cursorfilefg of string * color | ` Cursormaskfile of string * string * color * color ] ; ; ## endif
type index = | Number of int | ActiveElement | End | Last | NoIndex | Insert | SelFirst | SelLast | At of int | AtXY of int * int | AnchorPoint | Pattern of string | LineChar of int * int | Mark of string | TagFirst of string | TagLast of string | Embedded of widget ; ; ## else
type canvas_index = [ | ` Num of int | ` End | ` Insert | ` Selfirst | ` Sellast | ` Atxy of int * int ] ; ;
type entry_index = [ | ` Num of int | ` End | ` Insert | ` Selfirst | ` Sellast | ` At of int | ` Anchor ] ; ;
type listbox_index = [ | ` Num of int | ` Active | ` Anchor | ` End | ` Atxy of int * int ] ; ;
type menu_index = [ | ` Num of int | ` Active | ` End | ` Last | ` None | ` At of int | ` Pattern of string ] ; ;
type text_index = [ | ` Linechar of int * int | ` Atxy of int * int | ` End | ` Mark of string | ` Tagfirst of string | ` Taglast of string | ` Window of any widget | ` Image of string ] ; ;
type linechar_index = int * int ; ;
type num_index = int ; ; ## endif
type textModifier = | CharOffset of int | LineOffset of int | LineStart | LineEnd | WordStart | WordEnd ; ;
type textIndex = | TextIndex of index * textModifier list | TextIndexNone ; ; ## else
type textModifier = [ | ` Char of int | ` Line of int | ` Linestart | ` Lineend | ` Wordstart | ` Wordend ] ; ;
type textIndex = text_index * textModifier list ; ; ## endif
let arguments = Variables . make ( " arguments " , " Arguments passed to executed programs and scripts " )
let cwd = Variables . make ( " cwd " , " Used to change current working directory , but not updated " )
let commandline = Variables . make ( " commandline " , " Specify the commandline of a tool " )
let exit_status = Variables . make ( " exit_status " , " Expected program exit status " )
let files = Variables . make ( " files " , " Files used by the tests " )
let make = Variables . make ( " MAKE " , " Command used to invoke make " )
let ocamltest_response = Variables . make ( " ocamltest_response " , " File used by hooks to send back information . " )
let ocamltest_log = Variables . make ( " ocamltest_log " , " Path to log file for the current test " )
let output = Variables . make ( " output " , " Where the output of executing the program is saved " )
let program = Variables . make ( " program " , " Name of program produced by ocamlc . byte and ocamlopt . byte " )
let program2 = Variables . make ( " program2 " , " Name of program produced by ocamlc . opt and ocamlopt . opt " )
let promote = Variables . make ( " promote " , " Set to " \ true " \ to overwrite reference files with the test output " )
let reason = Variables . make ( " reason " , " Let a test report why it passed / skipped / failed . " )
let reference = Variables . make ( " reference " , " Path of file to which program output should be compared " )
let skip_header_lines = Variables . make ( " skip_header_lines " , " The number of lines to skip when comparing program output \ with the reference file " )
let skip_header_bytes = Variables . make ( " skip_header_bytes " , " The number of bytes to skip when comparing program output \ with the reference file " )
let script = Variables . make ( " script " , " External script to run " )
let stdin = Variables . make ( " stdin " , " Default standard input " )
let stdout = Variables . make ( " stdout " , " Default standard output " )
let stderr = Variables . make ( " stderr " , " Default standard error " )
let test_build_directory = Variables . make ( " test_build_directory " , " Directory for files produced during a test " )
let test_build_directory_prefix = Variables . make ( " test_build_directory_prefix " , " Directory under which all test directories should be created " )
let test_file = Variables . make ( " test_file " , " Name of file containing the specification of which tests to run " )
let test_source_directory = Variables . make ( " test_source_directory " , " Directory containing the test source files " )
let test_pass = Variables . make ( " TEST_PASS " , " Exit code to let a script report success " )
let test_skip = Variables . make ( " TEST_SKIP " , " Exit code to let a script report skipping " )
let test_fail = Variables . make ( " TEST_FAIL " , " Exit code to let a script report failure " )
let _ = List . iter Variables . register_variable [ arguments ; cwd ; commandline ; exit_status ; files ; make ; ocamltest_response ; ocamltest_log ; output ; program ; program2 ; reason ; reference ; skip_header_lines ; skip_header_bytes ; script ; stdin ; stdout ; stderr ; test_build_directory ; test_file ; test_sour...
let label_counter = ref 0
let new_label ( ) = incr label_counter ; ! label_counter
let empty_env = { ce_stack = Ident . empty ; ce_heap = Ident . empty ; ce_rec = Ident . empty }
let add_var id pos env = { ce_stack = Ident . add id pos env . ce_stack ; ce_heap = env . ce_heap ; ce_rec = env . ce_rec }
let rec add_vars idlist pos env = match idlist with [ ] -> env | id :: rem -> add_vars rem ( pos + 1 ) ( add_var id pos env )
let label_code = function Kbranch lbl :: _ as cont -> ( lbl , cont ) | Klabel lbl :: _ as cont -> ( lbl , cont ) | cont -> let lbl = new_label ( ) in ( lbl , Klabel lbl :: cont )
let rec make_branch_2 lbl n cont = function Kreturn m :: _ -> ( Kreturn ( n + m ) , cont ) | Klabel _ :: c -> make_branch_2 lbl n cont c | Kpop m :: c -> make_branch_2 lbl ( n + m ) cont c | _ -> match lbl with Some lbl -> ( Kbranch lbl , cont ) | None -> let lbl = new_label ( ) in ( Kbranch lbl , Klabel lbl :: cont )
let make_branch cont = match cont with ( Kbranch _ as branch ) :: _ -> ( branch , cont ) | ( Kreturn _ as return ) :: _ -> ( return , cont ) | Kraise k :: _ -> ( Kraise k , cont ) | Klabel lbl :: _ -> make_branch_2 ( Some lbl ) 0 cont cont | _ -> make_branch_2 ( None ) 0 cont cont
let branch_to label cont = match cont with
let rec discard_dead_code = function [ ] -> [ ] | ( Klabel _ | Krestart | Ksetglobal _ ) :: _ as cont -> cont | _ :: cont -> discard_dead_code cont
let rec is_tailcall = function Kreturn _ :: _ -> true | Klabel _ :: c -> is_tailcall c | Kpop _ :: c -> is_tailcall c | _ -> false
let preserve_tailcall_for_prim = function Pidentity | Popaque | Pdirapply _ | Prevapply _ | Psequor | Psequand -> true | Pbytes_to_string | Pbytes_of_string | Pignore | Pgetglobal _ | Psetglobal _ | Pmakeblock _ | Pmakefloatblock _ | Pfield _ | Pfield_computed _ | Psetfield _ | Psetfield_computed _ | Pfloatfield _ | Ps...
let rec add_pop n cont = if n = 0 then cont else match cont with Kpop m :: cont -> add_pop ( n + m ) cont | Kreturn m :: cont -> Kreturn ( n + m ) :: cont | Kraise _ :: _ -> cont | _ -> Kpop n :: cont
let add_const_unit = function ( Kacc _ | Kconst _ | Kgetglobal _ | Kpush_retaddr _ ) :: _ as cont -> cont | cont -> Kconst const_unit :: cont
let rec push_dummies n k = match n with
type rhs_kind = | RHS_block of int | RHS_infix of { blocksize : int ; offset : int } | RHS_floatblock of int | RHS_nonrec | RHS_function of int * int ; ;
let rec check_recordwith_updates id e = match e with | Lsequence ( Lprim ( ( Psetfield _ | Psetfloatfield _ ) , [ Lvar id2 ; _ ] , _ ) , cont ) -> id2 = id && check_recordwith_updates id cont | Lvar id2 -> id2 = id | _ -> false ; ;
let rec size_of_lambda env = function | Lvar id -> begin try Ident . find_same id env with Not_found -> RHS_nonrec end | Lfunction { params } as funct -> RHS_function ( 2 + Ident . Set . cardinal ( free_variables funct ) , List . length params ) | Llet ( Strict , _k , id , Lprim ( Pduprecord ( kind , size ) , _ , _ ) ,...
let copy_event ev kind info repr = { ev with ev_pos = 0 ; ev_kind = kind ; ev_info = info ; ev_repr = repr }
let merge_infos ev ev ' = match ev . ev_info , ev ' . ev_info with Event_other , info -> info | info , Event_other -> info | _ -> fatal_error " Bytegen . merge_infos "
let merge_repr ev ev ' = match ev . ev_repr , ev ' . ev_repr with Event_none , x -> x | x , Event_none -> x | Event_parent r , Event_child r ' when r == r ' && ! r = 1 -> Event_none | Event_child r , Event_parent r ' when r == r ' -> Event_parent r | _ , _ -> fatal_error " Bytegen . merge_repr "
let merge_events ev ev ' = let ( maj , min ) = match ev . ev_kind , ev ' . ev_kind with Event_pseudo , _ -> ev ' , ev | _ , Event_pseudo -> ev , ev ' | Event_before , ( Event_after _ | Event_before ) -> ev ' , ev | Event_after _ , ( Event_after _ | Event_before ) -> ev , ev ' in copy_event maj maj . ev_kind ( merge_inf...
let weaken_event ev cont = match ev . ev_kind with Event_after _ -> begin match cont with Kpush :: Kevent ( { ev_repr = Event_none } as ev ' ) :: c -> begin match ev . ev_info with Event_return _ -> let repr = ref 1 in let ev = copy_event ev Event_pseudo ev . ev_info ( Event_parent repr ) and ev ' = copy_event ev ' ev ...
let add_event ev = function Kevent ev ' :: cont -> weaken_event ( merge_events ev ev ' ) cont | cont -> weaken_event ev cont
let add_pseudo_event loc modname c = if ! Clflags . debug then let ev_defname = string_of_scoped_location loc in let ev = { ev_pos = 0 ; ev_module = modname ; ev_loc = to_location loc ; ev_defname ; ev_kind = Event_pseudo ; ev_info = Event_other ; ev_typenv = Env . Env_empty ; ev_typsubst = Subst . identity ; ev_compen...
let try_blocks = ref [ ]
let sz_static_raises = ref [ ]
let push_static_raise i lbl_handler sz = sz_static_raises := ( i , ( lbl_handler , sz , ! try_blocks ) ) :: ! sz_static_raises
let find_raise_label i = try List . assoc i ! sz_static_raises with | Not_found -> Misc . fatal_error ( " exit ( " ^ Int . to_string i " ) ^ outside appropriated catch " )
let code_as_jump l sz = match l with let label , size , tb = find_raise_label i in if sz = size && tb == ! try_blocks then Some label else None
type function_to_compile = { params : Ident . t list ; body : lambda ; label : label ; free_vars : Ident . t list ; num_defs : int ; rec_vars : Ident . t list ; rec_pos : int }
let functions_to_compile = ( Stack . create ( ) : function_to_compile Stack . t )
let compunit_name = ref " "
let max_stack_used = ref 0
let comp_bint_primitive bi suff args = let pref = match bi with Pnativeint -> " caml_nativeint_ " | Pint32 -> " caml_int32_ " | Pint64 -> " caml_int64_ " in Kccall ( pref ^ suff , List . length args )
let comp_primitive p args = match p with Pgetglobal id -> Kgetglobal id | Psetglobal id -> Ksetglobal id | Pintcomp cmp -> Kintcomp cmp | Pcompare_ints -> Kccall ( " caml_int_compare " , 2 ) | Pcompare_floats -> Kccall ( " caml_float_compare " , 2 ) | Pcompare_bints bi -> comp_bint_primitive bi " compare " args | Pfiel...
let is_immed n = immed_min <= n && n <= immed_max
module Storer = Switch . Store ( struct type t = lambda type key = lambda let compare_key = Stdlib . compare let make_key = Lambda . make_key end )
let rec comp_expr env exp sz cont = if sz > ! max_stack_used then max_stack_used := sz ; match exp with Lvar id -> begin try let pos = Ident . find_same id env . ce_stack in Kacc ( sz - pos ) :: cont with Not_found -> try let pos = Ident . find_same id env . ce_heap in Kenvacc ( pos ) :: cont with Not_found -> try let ...
let comp_block env exp sz cont = max_stack_used := 0 ; let code = comp_expr env exp sz cont in let used_safe = ! max_stack_used + Config . stack_safety_margin in if used_safe > Config . stack_threshold then Kconst ( Const_base ( Const_int used_safe ) ) :: Kccall ( " caml_ensure_stack_capacity " , 1 ) :: code else code
let comp_function tc cont = let arity = List . length tc . params in let rec positions pos delta = function [ ] -> Ident . empty | id :: rem -> Ident . add id pos ( positions ( pos + delta ) delta rem ) in let env = { ce_stack = positions arity ( - 1 ) tc . params ; ce_heap = positions ( 3 * ( tc . num_defs - tc . rec_...
let comp_remainder cont = let c = ref cont in begin try while true do c := comp_function ( Stack . pop functions_to_compile ) ! c done with Stack . Empty -> ( ) end ; ! c
let compile_implementation modulename expr = Stack . clear functions_to_compile ; label_counter := 0 ; sz_static_raises := [ ] ; compunit_name := modulename ; let init_code = comp_block empty_env expr 0 [ ] in if Stack . length functions_to_compile > 0 then begin let lbl_init = new_label ( ) in Kbranch lbl_init :: comp...
let compile_phrase expr = Stack . clear functions_to_compile ; label_counter := 0 ; sz_static_raises := [ ] ; let init_code = comp_block empty_env expr 1 [ Kreturn 1 ] in let fun_code = comp_remainder [ ] in ( init_code , fun_code )
let reset ( ) = label_counter := 0 ; sz_static_raises := [ ] ; compunit_name := " " ; Stack . clear functions_to_compile ; max_stack_used := 0
type error = File_not_found of string | Not_an_object_file of string
let copy_compunit ic oc compunit = seek_in ic compunit . cu_pos ; compunit . cu_pos <- pos_out oc ; compunit . cu_force_link <- compunit . cu_force_link || ! Clflags . link_everything ; copy_file_chunk ic oc compunit . cu_codesize ; if compunit . cu_debug > 0 then begin seek_in ic compunit . cu_debug ; compunit . cu_de...
let lib_ccobjs = ref [ ]
let lib_ccopts = ref [ ]
let lib_dllibs = ref [ ]
let add_ccobjs l = if not ! Clflags . no_auto_link then begin if l . lib_custom then Clflags . custom_runtime := true ; lib_ccobjs := ! lib_ccobjs @ l . lib_ccobjs ; lib_ccopts := ! lib_ccopts @ l . lib_ccopts ; lib_dllibs := ! lib_dllibs @ l . lib_dllibs end