text stringlengths 0 601k |
|---|
let start_playing = ref false |
let destroy ( ) = GMain . Main . quit ( ) |
let low_prio = Glib . int_of_priority ` LOW -> Glib . Timeout . id = " ml_g_timeout_add " val mutable period = 1 . 0 . / freq val mutable last_wall_clk = Unix . gettimeofday ( ) val mutable timer_id = None val mutable step_count = 0 method set_period v = period <- v method private clear_timer ( ) = match timer_id with ... |
let go freq main_step = let w = GWindow . window ~ title " : Simulator " ~ width : 250 ~ height : 70 ~ resizable : false ( ) in let outer_box = GPack . vbox ~ packing : w # add ( ) in let top_box = GPack . button_box ` HORIZONTAL ~ packing : outer_box # pack ~ child_width : 48 ~ child_height : 48 ~ layout ` : SPREAD ( ... |
type error = | Etype | Ehybrid_operator | Earray_operator | Eapplication |
let error loc kind = raise ( Error ( loc , kind ) ) |
let message loc kind = begin match kind with | Etype -> eprintf " [ @% aTranslation to L --: This type cannot be translated . . ] " @@ output_location loc | Ehybrid_operator -> eprintf " [ @% aTranslation to L --: Hybrid operators are not treated . . ] " @@ output_location loc | Earray_operator -> eprintf " [ @% aTrans... |
type return = { eqs : eq State . t ; env : tentry Env . t State . t ; assertion : exp State . t } |
let empty = { eqs = State . empty ; env = State . empty ; assertion = State . empty } |
let with_env ( { env = env0 } as return ) env = { return with env = State . cons env env0 } |
let with_eq ( { eqs = eqs } as return ) eq = { return with eqs = State . cons eq eqs } |
let par { eqs = eqs1 ; env = env1 ; assertion = as1 } { eqs = eqs2 ; env = env2 ; assertion = as2 } = { eqs = State . par eqs1 eqs2 ; env = State . par env1 env2 ; assertion = State . par as1 as2 } |
let eq_make k x e ck = { eq_kind = k ; eq_ident = x ; eq_exp = e ; eq_clock = ck } |
let on ck ln c = Ck_on ( ck , ln , c ) |
let relse res c = Res_else ( res , c ) |
let immediate = function | Eint ( i ) -> Lint ( i ) | Efloat ( f ) -> Lfloat ( f ) | Ebool ( b ) -> Lbool ( b ) | Echar ( c ) -> Lchar ( c ) | Estring ( s ) -> Lstring ( s ) | Evoid -> Lvoid |
let constr0pat { p_desc = p_desc } = match p_desc with | Econstpat ( Ebool ( b ) ) -> Lboolpat ( b ) | Econstr0pat ( c ) -> Lconstr0pat ( c ) | _ -> assert false |
let rec type_of loc { t_desc = ty } = match ty with | Deftypes . Tconstr ( q , [ ] , _ ) -> if q = Initial . int_ident then Tint else if q = Initial . int32_ident then Tint else if q = Initial . int64_ident then Tint else if q = Initial . bool_ident then Tbool else if q = Initial . zero_ident then Tbool else if q = Ini... |
let type_expression loc ty_e = let { typ_body = ty } = Interface . scheme_of_type ty_e in type_of loc ty |
let env_of_env loc env = Env . map ( fun { Deftypes . t_typ = ty } -> { t_typ = type_of loc ty } ) env |
let operator loc op e_list = match op with | Eifthenelse -> Lapp ( Lifthenelse , e_list ) | Eunarypre -> Lapp ( Lunarypre , e_list ) | Eminusgreater -> Lapp ( Lminusgreater , e_list ) | Efby -> Lapp ( Lfby , e_list ) | Eup | Einitial | Edisc | Ehorizon -> error loc Ehybrid_operator | Eaccess | Eupdate | Econcat | Eslic... |
let shared_variables { dv = dv } = dv |
let get x name_to_exp = try Env . find x name_to_exp with | Not_found -> Llast ( x ) |
let rec expression ck { e_desc = desc ; e_loc = loc } = match desc with | Elocal ( id ) -> Llocal ( id ) | Eglobal { lname = lid } -> Lglobal ( lid ) | Econst ( im ) -> Lconst ( immediate im ) | Econstr0 ( lid ) -> Lconstr0 ( lid ) | Econstr1 _ -> assert false | Elast ( x ) -> Llast ( x ) | Eapp ( _ , { e_desc = Egloba... |
let split s_set ( { eqs = eqs } as return ) = let eq_name_exp , eqs = State . partition ( fun { eq_ident = id } -> S . mem id s_set ) eqs in let name_to_exp = State . fold ( fun { eq_ident = id ; eq_exp = e } acc -> Env . add id e acc ) eq_name_exp Env . empty in name_to_exp , { return with eqs = eqs } |
let rec equation ck res { eq_desc = desc ; eq_write = defnames } = match desc with | EQeq ( { p_desc = Evarpat ( x ) } , e ) -> with_eq empty ( eq_make Def x ( expression ck e ) ck ) | EQinit ( x , e ) -> let e = expression ck e in with_eq empty ( eq_make ( Init ( res ) ) x e ck ) | EQreset ( eq_list , e ) -> let e = e... |
let local ck res { l_eq = eq_list ; l_env = l_env ; l_loc = loc } = let return = equation_list ck res eq_list in with_env return ( env_of_env loc l_env ) |
let let_expression ck res n_output ( { e_desc = desc } as e ) = match desc with | Elet ( l , e ) -> let return = local ck res l in let e = expression ck e in with_eq return ( eq_make Def n_output e ck ) | _ -> let e = expression ck e in with_eq empty ( eq_make Def n_output e ck ) |
let kind = function | S | AS | A | AD -> A | D -> D | C -> assert false |
let typedecl loc n params td = let decl { desc = desc } = match desc with | Eabstract_type -> Labstract_type | Evariant_type _ -> assert false | Erecord_type ( n_ty_list ) -> Lrecord_type | Eabbrev _ -> assert false in match params with | [ ] -> Ltypedecl ( n , decl td ) | _ -> assert false |
let implementation lmm_nodes lmm_list impl = match impl . desc with | Eopen _ -> lmm_list | Etypedecl ( n , params , td ) -> typedecl impl . loc n params td :: lmm_list | Econstdecl ( n , _ , e ) -> if Zmisc . S . mem n lmm_nodes then Lconstdecl ( n , expression Ck_base e ) :: lmm_list else lmm_list | Efundecl ( n , { ... |
let implementation_list lmm_nodes impl_list = rev ( fold_left ( implementation lmm_nodes ) [ ] impl_list ) |
let rec repeat n a = match n with | 0 -> [ ] | n -> a :: ( repeat ( n - 1 ) a ) |
let rec keep l n = match ( l , n ) with | ( _ , 0 ) -> invalid_arg " keep " | ( h :: _ , 1 ) -> h | ( _ :: t , n ) -> keep t ( n - 1 ) | _ -> invalid_arg " keep " |
let rec drop l n = match ( l , n ) with | ( _ , 0 ) -> invalid_arg " drop " | ( _ :: t , 1 ) -> t | ( h :: t , n ) -> h :: ( drop t ( n - 1 ) ) | _ -> invalid_arg " drop " |
let rec range n m = if n > m then [ ] else n :: ( range ( n + 1 ) m ) |
let separate n l = let rec f acc n l = match ( n , l ) with | ( 0 , _ ) -> ( acc , l ) | ( n , h :: t ) -> f ( h :: acc ) ( n - 1 ) t | _ -> assert false in if n > List . length l then invalid_arg " separate " else let ( p , l ) = f [ ] n l in ( List . rev p , l ) |
type ' a pattern = | Pany | Por of ' a pattern * ' a pattern | Pconstr of ' a * ' a pattern list |
module type SIG = sig type tag val compare : tag -> tag -> int val arity : tag -> int val is_complete : tag list -> bool val not_in : tag list -> tag type pattern_ast val inject : pattern_ast -> tag pattern val eject : tag pattern -> pattern_ast end |
module PATTERN_CHECKER = functor ( S : SIG ) -> struct module SSet = Set . Make ( struct type t = S . tag let compare = S . compare end ) let uniq l = SSet . elements ( List . fold_right SSet . add l SSet . empty ) let is_complete sigma = S . is_complete ( uniq sigma ) let not_in sigma = S . not_in ( uniq sigma ) let r... |
let header_in_file = let open Zconfig in " The Zelus compiler , version " ^ version ^ " " - ^ subversion ^ " \ n \ ( " ^ date ^ " ) " |
module S = Set . Make ( struct type t = string let compare = compare end ) |
module Env = Map . Make ( struct type t = string let compare = compare end ) |
let default_used_modules = ref [ name_of_stdlib_module ] |
let load_path = ref ( [ standard_lib ] ) |
let set_stdlib p = load_path := [ p ] |
let locate_stdlib ( ) = Printf . printf " % s \ n " standard_lib |
let show_version ( ) = let open Zconfig in Printf . printf " The Zelus compiler , version % s -% s ( % s ) \ n " version subversion date ; Printf . printf " Std lib : " ; locate_stdlib ( ) ; Printf . printf " \ n " ; ( ) |
let simulation_node = ref None |
let set_simulation_node ( n : string ) = simulation_node := Some ( n ) |
let outname = ref None |
let set_outname ( n : string ) = outname := Some ( n ) |
let node_outname = ref None |
let set_node_outname ( n : string ) = node_outname := Some ( n ) |
let number_of_checks = ref 0 |
let set_check ( n : int ) = number_of_checks := n |
let sampling_period = ref 0 . 0 |
let set_sampling_period p = sampling_period := p |
let inlining_level = ref 10 |
let set_inlining_level l = inlining_level := l |
let inline_all = ref false |
let dzero = ref false |
let verbose = ref false |
let vverbose = ref false |
let print_types = ref false |
let print_causality_types = ref false |
let print_initialization_types = ref false |
let typeonly = ref false |
let use_gtk = ref false |
let no_stdlib = ref false |
let no_causality = ref false |
let no_initialisation = ref false |
let no_opt = ref false |
let no_deadcode = ref false |
let no_simplify_causality_type = ref false |
let no_reduce = ref false |
let no_warning = ref false |
let zsign = ref false |
let with_copy = ref false |
let use_rif = ref false |
let build_deps = ref false |
let lmm_nodes = ref S . empty |
let set_lmm_nodes ( n : string ) = lmm_nodes := S . add n ! lmm_nodes object val mutable counter = 0 method name = counter <- counter + 1 ; counter method reset = counter <- 0 method init i = counter <- i end |
let symbol = new name_generator object val mutable counter = 0 val mutable assoc_table : ( int * string ) list = [ ] method name var = try List . assq var assoc_table with not_found -> let n = f counter in counter <- counter + 1 ; assoc_table <- ( var , n ) :: assoc_table ; n method reset = counter <- 0 ; assoc_table <... |
let int_to_letter bound i = if i < 26 then String . make 1 ( Char . chr ( i + bound ) ) else String . make 1 ( Char . chr ( ( i mod 26 ) + bound ) ) ^ string_of_int ( i / 26 ) |
let int_to_alpha i = int_to_letter 97 i |
let binding_level = ref 0 |
let top_binding_level ( ) = ! binding_level = 0 |
let push_binding_level ( ) = binding_level := ! binding_level + 1 |
let pop_binding_level ( ) = binding_level := ! binding_level - 1 ; assert ( ! binding_level > generic ) |
let reset_binding_level ( ) = binding_level := 0 |
let optional f acc = function | None -> acc | Some x -> f acc x |
let optional_unit f acc = function | None -> ( ) | Some x -> f acc x |
let optional_map f = function | None -> None | Some ( x ) -> Some ( f x ) |
let optional_with_map f acc = function | None -> None , acc | Some ( x ) -> let x , acc = f acc x in Some ( x ) , acc |
let optional_get = function | Some x -> x | None -> assert false |
let rec iter f = function | [ ] -> [ ] | x :: l -> let y = f x in y :: iter f l |
let fold f l = List . rev ( List . fold_left f [ ] l ) |
let from i = let rec fromrec acc i = match i with | 0 -> acc | _ -> fromrec ( i :: acc ) ( i - 1 ) in fromrec [ ] i |
let map_fold f acc l = let rec maprec acc = function | [ ] -> [ ] , acc | x :: l -> let y , acc = f acc x in let l , acc = maprec acc l in y :: l , acc in maprec acc l |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.