text
stringlengths
0
601k
let a = ref 0 . 0 ; ;
let b = ref 0 . 0 ; ;
let display ( ) = a := float ! height . / float ! width ; b := float ! width . / float ! height ; glClear [ GL_COLOR_BUFFER_BIT ] ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; gluPerspective ( 20 . 0 . * sqrt ( 1 . 0 . + ! a . * ! a ) ) ( ! b ) ( 8 . 0 ) ( 12 . 0 ) ; glMatrixMode GL_MODELVIEW ; glLoadIdentity ( )...
let reshape ~ width ( : new_width ) ~ height ( : new_height ) = width := new_width ; height := new_height ; glutPostRedisplay ( ) ; ; ;
let keyboard ~ key ~ x ~ y = match key with ' q ' | ' Q ' | ' \ 027 ' -> exit 0 | _ -> ( ) ; ;
let mouse ~ button ~ state ~ x ~ y = begin match button with | GLUT_LEFT_BUTTON -> left_click := state ; | GLUT_RIGHT_BUTTON -> right_click := state ; | _ -> ( ) end ; xold := x ; yold := y ; ; ;
let motion ~ x ~ y = if ( GLUT_DOWN = ! left_click ) then begin rotate_y := ! rotate_y . + float ( y - ! yold ) . / 5 . 0 ; rotate_x := ! rotate_x . + float ( x - ! xold ) . / 5 . 0 ; if ( ! rotate_y > 90 . 0 ) then rotate_y := 90 . 0 ; if ( ! rotate_y < ( - 90 . ) ) then rotate_y := ( - 90 . 0 ) ; glutPostRedisplay ( ...
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_RGB ; GLUT_DOUBLE ] ; glutInitWindowSize 500 500 ; ignore ( glutCreateWindow " Viewport " ) ; glClearColor 0 . 0 0 . 0 0 . 0 0 . 0 ; glEnable GL_CULL_FACE ; glEnable GL_BLEND ; glutDisplayFunc ~ display ; glutReshapeFunc ~ reshape ; glutKeyboardFunc ...
let register_callers_src = { | CDR ; SOURCE ; CONS ; NIL operation ; PAIR ; } ; } |
let check_caller_src = { | CAR ; DUP ; UNIT ; VIEW " calls_count " nat ; IF_NONE { UNIT ; FAILWITH } { } ; DIP { UNIT ; VIEW " last_caller " ( option address ) ; } ; PUSH nat 0 ; /* Check if the caller address is consistent with given calls count . */ IFCMPEQ { IF_NONE { UNIT ; FAILWITH } { IF_NONE { } { UNIT ; FAILWIT...
let hooks = let rec mask_temp_dir = function | [ ] -> [ ] | " -- base - dir " :: _ :: rest -> " -- base - dir " :: " < masked " > :: rest | arg :: args -> arg :: mask_temp_dir args in { Regression . hooks with on_spawn = ( fun cmd args -> mask_temp_dir args |> Regression . hooks . on_spawn cmd ) ; }
let register ~ protocols ( ) = Protocol . register_regression_test ~ __FILE__ ~ title " : Run views " ~ tags [ " : client " ; " michelson " ] ~ output_file " : run_views " ~ protocols @@ fun protocol -> let * client = Client . init_mockup ~ protocol ( ) in let * register_callers = Client . originate_contract ~ hooks ~ ...
let domain_name = " View domain "
module Domain = struct type static_information = { global_static_information : Analyzer_headers . global_static_information ; domain_static_information : Bdu_static_views . bdu_analysis_static ; domain_static_information_pattern : Bdu_static_views . bdu_analysis_static_pattern ; domain_static_information_covering_class...
let travel_in_site_correspondence parameters error cv_id site_correspondence = let error , site_correspondence = let rec aux list = match list with | [ ] -> Exception . warn parameters error __POS__ Exit [ ] | ( h , list , _ ) :: _ when h = cv_id -> error , list | _ :: tail -> aux tail in aux site_correspondence in err...
let get_site_correspondence parameters error agent_type site_correspondence = let error , site_correspondence = match Ckappa_sig . Agent_type_quick_nearly_Inf_Int_storage_Imperatif . get parameters error agent_type site_correspondence with | error , None -> Exception . warn parameters error __POS__ Exit [ ] | error , S...
let get_list_of_sites_correspondence parameters error agent_type cv_id site_correspondence = let error , site_correspondence = get_site_correspondence parameters error agent_type site_correspondence in let error , site_correspondence = travel_in_site_correspondence parameters error cv_id site_correspondence in error , ...
let get_list_of_sites_correspondence_map parameters error agent_type cv_id site_correspondence = let error , cv_id_array_opt = Ckappa_sig . Agent_type_quick_nearly_Inf_Int_storage_Imperatif . get parameters error agent_type site_correspondence in match cv_id_array_opt with | None -> let error , map1 = Ckappa_sig . Site...
let check ( ) = has_command " vim " && List . exists Re . ( execp @@ compile @@ str " + syntax " ) ( lines_of_command " vim -- version " )
let dotvimrc = let ( / ) = Filename . concat in let vimrc = " vimrc " in let dotvimrc = " . " ^ vimrc in let dotvim = " . vim " in if not ( Sys . file_exists ( home / dotvimrc ) ) && Sys . file_exists ( home / dotvim / vimrc ) then dotvim / vimrc else dotvimrc
let base_template = [ dotvimrc , lines_of_string { vim | finish else let g : loaded_sensible = 1 endif filetype plugin indent on endif syntax enable endif nnoremap < silent > < C - L > : nohlsearch < CR >< C - L > endif set scrolloff = 1 endif set sidescrolloff = 5 endif set encoding = utf - 8 endif set listchars = tab...
let base_setup = [ dotvimrc , Text ( lines_of_string { vim |
let s : opam_share_dir = system ( " opam config var share " )
let s : opam_share_dir = substitute ( s : opam_share_dir , ' [ \ r \ n ] ' , *$ ' ' , ' ' )
let s : opam_configuration = { } execute " set rtp " ^= . s : opam_share_dir . " / ocp - indent / vim " endfunction
let s : opam_configuration [ ' ocp - indent ' ] = function ( ' OpamConfOcpIndent ' ) execute " set rtp " += . s : opam_share_dir . " / ocp - index / vim " endfunction
let s : opam_configuration [ ' ocp - index ' ] = function ( ' OpamConfOcpIndex ' ) let l : dir = s : opam_share_dir . " / merlin / vim " execute " set rtp " += . l : dir endfunction
let s : opam_packages = [ " ocp - indent " , " ocp - index " , " merlin " ]
let s : opam_available_tools = [ ] " Respect package order ( merlin should be after ocp - index ) if isdirectory ( s : opam_share_dir . " " / . tool ) call add ( s : opam_available_tools , tool ) call s : opam_configuration [ tool ] ( ) endif endfor
let comment = ( ) ^ " " \ "
let share_dir = opam_var " share "
module OcpIndent = struct let name = " ocp - indent " let chunks = let contents = Printf . sprintf { vim | source % S endif | vim } ( share_dir " / ocp - indent " " / vim " " / indent " " / ocaml . vim " ) in [ dotvimrc , Text ( lines_of_string contents ) ] let files = [ ] let post_install = [ ] let pre_remove = [ ] en...
module OcpIndex = struct let name = " ocp - index " let chunks = [ ] let files = [ ] let post_install = [ ] let pre_remove = [ ] end
module Merlin = struct let name = " ocp - index " let chunks = [ ] let files = [ ] let post_install = [ ] let pre_remove = [ ] end
let tools = [ ( module OcpIndent : ToolConfig ) ; ( module OcpIndex : ToolConfig ) ; ( module Merlin : ToolConfig ) ; ]
type t = { vlib : Lib . t ; impl : Dune_file . Library . t ; vlib_modules : Modules . t ; vlib_foreign_objects : Path . t list ; impl_cm_kind : Cm_kind . t ; vlib_obj_map : Module . t Module_name . Unique . Map . t }
let vlib_modules t = t . vlib_modules
let vlib t = t . vlib
let impl t = t . impl
let impl_cm_kind t = t . impl_cm_kind
let impl_modules t m = match t with | None -> m | Some t -> Modules . impl ~ vlib : t . vlib_modules m
let make ~ vlib ~ impl ~ vlib_modules ~ vlib_foreign_objects = let impl_cm_kind = let vlib_info = Lib . info vlib in let { Mode . Dict . byte ; native = _ } = Lib_info . modes vlib_info in Mode . cm_kind ( if byte then Byte else Native ) in let vlib_obj_map = Modules . obj_map vlib_modules ~ f ( : function | Normal m -...
let vlib_stubs_o_files = function | None -> [ ] | Some t -> t . vlib_foreign_objects
let vlib_obj_map t = t . vlib_obj_map
module type ViolationArg = sig include MyARG . S with module Edge = MyARG . InlineEdge val prev : Node . t -> ( Edge . t * Node . t ) list val violations : Node . t list end
let find_sinks ( type node ) ( module Arg : ViolationArg with type Node . t = node ) = let module NHT = BatHashtbl . Make ( Arg . Node ) in let non_sinks = NHT . create 100 in let rec iter_node node = if not ( NHT . mem non_sinks node ) then begin NHT . replace non_sinks node ( ) ; List . iter ( fun ( _ , prev_node ) -...
module type Feasibility = sig module Node : MyARG . Node type result = | Feasible | Infeasible of ( Node . t * MyARG . inline_edge * Node . t ) list | Unknown val check_path : ( Node . t * MyARG . inline_edge * Node . t ) list -> result end
module UnknownFeasibility ( Node : MyARG . Node ) : Feasibility with module Node = Node = struct module Node = Node type result = | Feasible | Infeasible of ( Node . t * MyARG . inline_edge * Node . t ) list | Unknown let check_path _ = Unknown end
module type PathArg = MyARG . S with module Edge = MyARG . InlineEdge
type ' node result = | Feasible of ( module PathArg with type Node . t = ' node ) | Infeasible of ( ' node * MyARG . inline_edge * ' node ) list | Unknown
let find_path ( type node ) ( module Arg : ViolationArg with type Node . t = node ) ( module Feasibility : Feasibility with type Node . t = node ) : node result = let module NHT = BatHashtbl . Make ( Arg . Node ) in let rec trace_path next_nodes node2 = if NHT . mem next_nodes node2 then begin let ( edge , next_node ) ...
module WP ( Node : MyARG . Node ) : Feasibility with module Node = Node = struct module Node = Node open Z3 open Cil let cfg = [ ( " model " , " true " ) ; ( " unsat_core " , " true " ) ; ] let ctx = mk_context cfg type var = varinfo module Var = CilType . Varinfo module type Env = sig type t val empty : t val get_cons...
module Configuration = struct type t = { name : string ; parameters : ( string * string ) list } let to_json { name ; parameters } : Yojson . Basic . json = ` Assoc [ " name " , ` String name ; " parameters " , ` Assoc ( List . map parameters ~ f ( : fun ( a , b ) -> a , ` String b ) ) ; ] let render { parameters ; _ }...
let run ~ run_with ~ normal ~ tumor ~ result_prefix ( ? more_edges = [ ] ) ~ configuration ( ) = let open KEDSL in let open Configuration in let name = Filename . basename result_prefix in let result_file suffix = result_prefix ^ suffix in let output_file = result_file " - somatic . vcf " in let output_prefix = " virmi...
module Pp_spec : sig type t val make : Preprocess . Without_instrumentation . t Preprocess . t Module_name . Per_item . t -> Ocaml_version . t -> t val pped_module : t -> Module . t -> Module . t type t = ( Module . t -> Module . t ) Module_name . Per_item . t let make preprocess v = Module_name . Per_item . map prepro...
let setup_copy_rules_for_impl ~ sctx ~ dir vimpl = let ctx = Super_context . context sctx in let vlib = Vimpl . vlib vimpl in let impl = Vimpl . impl vimpl in let impl_obj_dir = Dune_file . Library . obj_dir ~ dir impl in let vlib_obj_dir = Lib . obj_dir vlib in let add_rule = Super_context . add_rule sctx ~ dir in let...
let impl sctx ( ~ lib : Dune_file . Library . t ) ~ scope = let open Memo . O in match lib . implements with | None -> Memo . return None | Some ( loc , implements ) -> ( Lib . DB . find ( Scope . libs scope ) implements >>= function | None -> User_error . raise ~ loc [ Pp . textf " Cannot implement % s as that library...
type t = | Public | Private
let to_string = function | Public -> " public " | Private -> " private "
let to_dyn t = Dyn . string ( to_string t )
let encode = let open Dune_lang . Encoder in function | Public -> string " public " | Private -> string " private "
let decode = let open Dune_lang . Decoder in plain_string ( fun ~ loc -> function | " public " -> Public | " private " -> Private | _ -> User_error . raise ~ loc [ Pp . text " Not a valid visibility . Valid visibility is public or private " ] )
let is_public = function | Public -> true | Private -> false
let is_private t = not ( is_public t )
module Map = struct type ' a t = { public : ' a ; private_ : ' a } let make_both a = { public = a ; private_ = a } let find { private_ ; public } = function | Private -> private_ | Public -> public end
module Bounds = struct type t = { min_x : int ; min_y : int ; max_x : int ; max_y : int } [ @@ deriving sexp , equal ] end
let get_conservative_vis_bounds ( element : Dom_html . element Js . t ) : Bounds . t option = let client_bounds = element ## getBoundingClientRect in let client_x = client_bounds . ## left and client_y = client_bounds . ## top and client_bottom = client_bounds . ## bottom and client_right = client_bounds . ## right and...
module T = struct module Input = struct type t = Bounds . t -> unit Vdom . Effect . t [ @@ deriving sexp_of ] let combine left right bounds = Vdom . Effect . sequence_as_sibling ( left bounds ) ~ unless_stopped ( : fun ( ) -> right bounds ) ; ; end module State = struct type t = { mutable callback : Bounds . t -> unit ...
module Hook = Vdom . Attr . Hooks . Make ( T )
let on_change f = Vdom . Attr . create_hook " bounds - change " ( Hook . create f )
type node = | Expression of Expression . t | Statement of Statement . t | Argument of Identifier . t Node . t | Parameter of Parameter . t | Reference of Reference . t Node . t | Substring of Substring . t | Generator of Comprehension . Generator . t
module type NodeVisitor = sig type t val node : t -> node -> t val visit_statement_children : t -> Statement . t -> bool val visit_format_string_children : t -> Expression . t -> bool end
module MakeNodeVisitor ( Visitor : NodeVisitor ) = struct let visit_node ~ state ~ visitor node = state := visitor ! state node let visit_argument { Call . Argument . value ; _ } ~ visit_expression = visit_expression value let visit_parameter ( { Node . value = { Parameter . value ; annotation ; _ } ; _ } as parameter ...
module type Visitor = sig type t val expression : t -> Expression . t -> t val statement : t -> Statement . t -> t end
module Make ( Visitor : Visitor ) = struct let visit = let module NodeVisitor = MakeNodeVisitor ( struct type t = Visitor . t let node state = function | Expression expression -> Visitor . expression state expression | Statement statement -> Visitor . statement state statement | _ -> state let visit_statement_children ...
module type StatementVisitor = sig type t val visit_children : Statement . t -> bool val statement : Source . t -> t -> Statement . t -> t end
module MakeStatementVisitor ( Visitor : StatementVisitor ) = struct let visit state ( { Source . statements ; _ } as source ) = let state = ref state in let open Statement in let rec visit_statement { Node . location ; value } = if Visitor . visit_children { Node . location ; value } then ( match value with | Assign _ ...
module type ExpressionPredicate = sig type t val predicate : Expression . t -> t option end
module type StatementPredicate = sig type t val visit_children : Statement . t -> bool val predicate : Statement . t -> t option end
module type NodePredicate = sig type t val predicate : node -> t option end
module Collector ( ExpressionPredicate : ExpressionPredicate ) ( StatementPredicate : StatementPredicate ) ( NodePredicate : NodePredicate ) = struct type collection = { expressions : ExpressionPredicate . t list ; statements : StatementPredicate . t list ; nodes : NodePredicate . t list ; } let collect source = let mo...
module UnitPredicate = struct type t = unit let visit_children _ = true let predicate _ = None end
module ExpressionCollector ( Predicate : ExpressionPredicate ) = struct let collect source = let module Collector = Collector ( Predicate ) ( UnitPredicate ) ( UnitPredicate ) in let { Collector . expressions ; _ } = Collector . collect source in expressions end
module StatementCollector ( Predicate : StatementPredicate ) = struct module CollectingVisit = MakeStatementVisitor ( struct type t = Predicate . t list let visit_children = Predicate . visit_children let statement _ statements statement = match Predicate . predicate statement with | Some result -> result :: statements...
module NodeCollector ( Predicate : NodePredicate ) = struct let collect source = let module Collector = Collector ( UnitPredicate ) ( UnitPredicate ) ( Predicate ) in let { Collector . nodes ; _ } = Collector . collect source in nodes end
let collect_locations source = let module Collector = Collector ( UnitPredicate ) ( UnitPredicate ) ( struct type t = Location . t let predicate = function | Expression node -> Some ( Node . location node ) | Statement node -> Some ( Node . location node ) | Argument node -> Some ( Node . location node ) | Parameter no...
let collect_calls statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Call . t Node . t let predicate expression = match expression with | { Node . location ; value = Call call } -> Some { Node . location ; value = call } | _ -> None end ) in Collector . collect ( Source . cr...
let collect_names ( ? only_simple = false ) statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Name . t Node . t let predicate expression = match expression with | { Node . location ; value = Name name } -> if only_simple && not ( is_simple_name name ) then None else Some { ...
let collect_calls_and_names statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Expression . t let predicate expression = match expression with | { Node . value = Call _ ; _ } -> Some expression | { Node . value = Name _ ; _ } -> Some expression | _ -> None end ) in Collector...
let collect_base_identifiers statement = let open Expression in let module Collector = ExpressionCollector ( struct type t = Identifier . t Node . t let predicate expression = match expression with | { Node . location ; value = Name ( Name . Identifier identifier ) } -> Some { Node . location ; value = identifier } | _...
let rec collect_non_generic_type_names { Node . value ; _ } = match value with | Expression . Call { Call . arguments ; _ } -> List . concat_map ~ f ( : fun { Call . Argument . value ; _ } -> collect_non_generic_type_names value ) arguments | Tuple elements | List elements -> List . concat_map ~ f : collect_non_generic...
let collect_format_strings_with_ignores ~ ignore_line_map source = let module CollectIgnoredFormatStrings = ExpressionCollector ( struct type t = Expression . t * Ignore . t list let predicate = function | { Node . value = Expression . FormatString _ ; location } as expression -> Map . find ignore_line_map ( Location ....
let test_collect _ = let assert_collect statements expected = let collect = let module ExpressionPredicate = struct type t = Expression . t let predicate expression = Some expression end in let module StatementPredicate = struct type t = Statement . t let visit_children _ = true let predicate statement = Some statement...
let test_collect_location _ = let assert_collect_location source expected_locations = let source = parse ~ handle " : test . py " source in let actual_locations = Visit . collect_locations source in let expected_locations = let create_location ( start_line , start_column , end_line , end_column ) = { Location . start =...
let test_collect_non_generic_type_names _ = let assert_non_generic_type_names expression expected = assert_equal ~ cmp [ :% equal : string list ] ~ printer [ :% show : string list ] expected ( Visit . collect_non_generic_type_names ( parse_single_expression ~ preprocess : true expression ) ) in assert_non_generic_type_...
let test_collect_format_strings_with_ignores _ = let assert_format_strings_with_ignores source expected = let ( { Source . typecheck_flags = { ignore_lines ; _ } ; _ } as source ) = parse source in let ignore_line_map = List . map ignore_lines ~ f ( : fun ( { Ignore . ignored_line ; _ } as ignore ) -> ignored_line , ig...
let test_node_visitor _ = let module Visitor = struct type t = int String . Table . t let node state node = let increment hash_table key = match Hashtbl . find hash_table key with | None -> Hashtbl . set hash_table ~ key ~ data : 1 | Some value -> Hashtbl . set hash_table ~ key ~ data ( : value + 1 ) in match node with...
let test_statement_visitor _ = let module StatementVisitor = struct type t = int String . Table . t let visit_children _ = true let statement _ visited statement = let increment hash_table key = match Hashtbl . find hash_table key with | None -> Hashtbl . set hash_table ~ key ~ data : 1 | Some value -> Hashtbl . set ha...
let test_statement_visitor_source _ = let module StatementVisitor = struct type t = string let visit_children _ = true let statement { Source . source_path = { ModulePath . relative ; _ } ; _ } _ _ = relative end in let module Visit = Visit . MakeStatementVisitor ( StatementVisitor ) in let handle = Visit . visit " " (...
let ( ) = " visit " >::: [ " collect " >:: test_collect ; " collect_location " >:: test_collect_location ; " collect_non_generic_type_names " >:: test_collect_non_generic_type_names ; " collect_format_strings_with_ignores " >:: test_collect_format_strings_with_ignores ; " node_visitor " >:: test_node_visitor ; " statem...