text
stringlengths
0
601k
let parse_error code err = let errors = [ ] @ Errors_internal . common in match Errors_internal . of_string err with | Some var -> if ( List . mem var errors ) && ( ( match Errors_internal . to_http_code var with | Some var -> var = code | None -> true ) ) then Some var else None | None -> None
let ( ) ||? a b = match a , b with Some x , _ | _ , Some x -> Some x | _ -> None
module TermDomain = struct include SetDomain . ToppedSet ( Basetype . Variables ) ( struct let topname = " All Variables " end ) end
let show_location_id l = string_of_int l . line ^ " _ " ^ string_of_int l . column inherit nopCilVisitor method ! vstmt s = let action s = match s . skind with | Loop ( b , loc , eloc , _ , _ ) -> let name = " term " ^ show_location_id loc in let typ = intType in let v = Goblintutil . create_var ( makeLocalVar fd name ...
let loopBreaks : ( int , location ) Hashtbl . t = Hashtbl . create 13 inherit nopCilVisitor method ! vstmt s = ( match s . skind with | Loop ( b , loc , eloc , Some continue , Some break ) -> Hashtbl . add loopBreaks break . sid loc | Loop _ -> failwith " Termination . preprocess : every loop should have a break and co...
let exits = function | { bstmts = [ { skind = Goto ( stmt , loc ) ; _ } ] ; _ } -> Hashtbl . find_option loopBreaks ! stmt . sid | _ -> None
let lvals_of_expr = let rec f a = function | Const _ | SizeOf _ | SizeOfStr _ | AlignOf _ | AddrOfLabel _ -> a | Lval l | AddrOf l | StartOf l -> l :: a | SizeOfE e | AlignOfE e | UnOp ( _ , e , _ ) | CastE ( _ , e ) | Imag e | Real e -> f a e | BinOp ( _ , e1 , e2 , _ ) -> f a e1 @ f a e2 | Question ( c , t , e , _ ) ...
let loopVars : ( location , lval ) Hashtbl . t = Hashtbl . create 13 inherit nopCilVisitor method ! vstmt s = let add_exit_cond e loc = match lvals_of_expr e with | [ lval ] when Cilfacade . typeOf e |> isArithmeticType -> Hashtbl . add loopVars loc lval | _ -> ( ) in ( match s . skind with | If ( e , tb , fb , loc , e...
let stripCastsDeep e = let v = object inherit nopCilVisitor method ! vexpr e = ChangeTo ( stripCasts e ) end in visitCilExpr v e
let cur_loop = ref None
let cur_loop ' = ref None
let makeVar fd loc name = let id = name ^ " __ " ^ show_location_id loc in try List . find ( fun v -> v . vname = id ) fd . slocals with Not_found -> let typ = intType in Goblintutil . create_var ( makeLocalVar fd id ~ init ( : SingleInit zero ) typ )
let f_commit = Lval ( var ( emptyFunction " __goblint_commit " ) . svar )
let f_check = Lval ( var ( emptyFunction " __goblint_check " ) . svar ) inherit nopCilVisitor method ! vstmt s = ( match s . skind with | Loop ( _ , loc , eloc , _ , _ ) -> cur_loop ' := ! cur_loop ; cur_loop := Some loc | _ -> ( ) ) ; let action s = ( match s . skind with | Loop ( _ , loc , eloc , _ , _ ) -> cur_loop ...
module Spec = struct include Analyses . DefaultSpec let name ( ) = " term " module D = TermDomain module C = TermDomain let assign ctx ( lval : lval ) ( rval : exp ) : D . t = ctx . local let branch ctx ( exp : exp ) ( tv : bool ) : D . t = ctx . local ) * let body ctx ( f : fundec ) : D . t = ctx . local let return ct...
let _ = Cilfacade . register_preprocess ( Spec . name ( ) ) ( new loopBreaksVisitor ) ; Cilfacade . register_preprocess ( Spec . name ( ) ) ( new loopVarsVisitor ) ; Cilfacade . register_preprocess ( Spec . name ( ) ) ( new loopInstrVisitor ) ; Cilfacade . register_preprocess ( Spec . name ( ) ) ( new recomputeVisitor ...
type term = Var of int | Term of string * term list
let rec union l1 l2 = match l1 with [ ] -> l2 | a :: r -> if List . mem a l2 then union r l2 else a :: union r l2
let rec vars = function Var n -> [ n ] | Term ( _ , l ) -> vars_of_list l [ ] -> [ ] | t :: r -> union ( vars t ) ( vars_of_list r )
let rec substitute subst = function Term ( oper , sons ) -> Term ( oper , List . map ( substitute subst ) sons ) | Var ( n ) as t -> try List . assoc n subst with Not_found -> t
let rec replace m u n = match ( u , m ) with [ ] , _ -> n | i :: u , Term ( oper , sons ) -> Term ( oper , replace_nth i sons u n ) | _ -> failwith " replace " match sons with s :: r -> if i = 1 then replace s u n :: r else s :: replace_nth ( i - 1 ) r u n | [ ] -> failwith " replace_nth "
let matching term1 term2 = let rec match_rec subst t1 t2 = match ( t1 , t2 ) with Var v , _ -> if List . mem_assoc v subst then if t2 = List . assoc v subst then subst else failwith " matching " else ( v , t2 ) :: subst | Term ( op1 , sons1 ) , Term ( op2 , sons2 ) -> if op1 = op2 then List . fold_left2 match_rec subst...
let compsubst subst1 subst2 = ( List . map ( fun ( v , t ) -> ( v , substitute subst1 t ) ) subst2 ) @ subst1
let rec occurs n = function Var m -> m = n | Term ( _ , sons ) -> List . exists ( occurs n ) sons
let rec unify term1 term2 = match ( term1 , term2 ) with Var n1 , _ -> if term1 = term2 then [ ] else if occurs n1 term2 then failwith " unify " else [ n1 , term2 ] | term1 , Var n2 -> if occurs n2 term1 then failwith " unify " else [ n2 , term1 ] | Term ( op1 , sons1 ) , Term ( op2 , sons2 ) -> if op1 = op2 then List ...
let rec pretty_term = function Var n -> print_string " v " ; print_int n | Term ( oper , sons ) -> if List . mem oper infixes then begin match sons with [ s1 ; s2 ] -> pretty_close s1 ; print_string oper ; pretty_close s2 | _ -> failwith " pretty_term : infix arity <> 2 " end else begin print_string oper ; match sons w...
let check t = let open EH1 in let open Term in let Term tr = reveal t in assert ( Term . equal t ( build tr ) ) ; let t ' = build ( map ( fun x -> x ) tr ) in assert ( Term . equal t t ' )
let check = List . iter check
let test ( ) = print_endline " Terms tests " ; let open EH1 in let open Global in init ( ) ; let open Term in let open Arith in let true_ = true0 ( ) in let false_ = false0 ( ) in let bool_t = Type . bool ( ) in let int_t = Type . int ( ) in let unint_t = Type . new_uninterpreted ( ) in assert ( not ( equal true_ false...
let test_gmp ( ) = print_endline " GMP Terms tests " ; let open EH1 in let open Global in init ( ) ; let open Term in let open Arith in let gmpz = Z . of_int 42 in let mpz1 = mpz gmpz in let gmpq = Q . of_ints 42 77 in let mpq1 = mpq gmpq in let coeff4 = [ 2 ; 3 ; 4 ; 5 ] in let coeff4_32 = List . map SInt . of_int coe...
type ' a t = E | NV of char * ' a t * ' a t * ' a t | V of char * ' a t * ' a t * ' a t * ' a
let rec length = function E -> 0 | NV ( _ , l , m , r ) | V ( _ , l , m , r , _ ) -> length l + length m + length r
let rec is_empty = function E -> true | V _ -> false | NV ( _ , l , m , r ) -> is_empty l && is_empty m && is_empty r
let find k t = let rec loop s n maxn = function E -> raise Not_found | NV ( c , l , m , r ) | V ( c , l , m , r , _ ) as node when n <= maxn -> let c ' = s . [ n ] in if c ' < c then loop s n maxn l else if c ' > c then loop s n maxn r else begin match node with NV _ -> loop s ( n + 1 ) maxn m | V ( _ , _ , _ , _ , v )...
let find_prefixes k t = let rec loop acc s n maxn = function E -> acc | NV ( c , l , m , r ) | V ( c , l , m , r , _ ) as node when n <= maxn -> let c ' = s . [ n ] in if c ' < c then loop acc s n maxn l else if c ' > c then loop acc s n maxn r else begin match node with NV _ -> loop acc s ( n + 1 ) maxn m | V ( _ , _ ...
let mem k t = try ignore ( find k t ) ; true with Not_found -> false
let add k v t = let rec add k v off maxn = function E -> if off = maxn then V ( k . [ off ] , E , E , E , v ) else if maxn = - 1 then V ( Char . chr 127 , E , E , E , v ) else NV ( k . [ off ] , E , add k v ( off + 1 ) maxn E , E ) | NV ( c , l , m , r ) -> let cmp = Char . compare k . [ off ] c in if cmp < 0 then NV (...
let prune = function NV ( _ , E , E , E ) -> E | e -> e
let remove k t = let rec del k off maxn = function E -> E | NV ( c , l , m , r ) as t -> let cmp = Char . compare k . [ off ] c in let t = if cmp < 0 then NV ( c , del k off maxn l , m , r ) else if cmp > 0 then NV ( c , l , m , del k off maxn r ) else if off = maxn then t else NV ( c , l , del k ( off + 1 ) maxn m , r...
let cons ( type a ) a ( key : string ) string ( body : a ) a ( to_yojson : a -> Yojson . Safe . t ) t = ` Assoc [ ( key , to_yojson body ) body ]
module Backend = struct module S3 = struct type t = { key : string ; encrypt : bool ; region : string ; bucket : string ; acl : string } [ @@ deriving to_yojson ] to_yojson end type t = S3 of S3 . t let to_yojson = function S3 x -> cons " s3 " x S3 . to_yojson end
module Block = struct module Terraform = struct type t = { required_version : string ; backend : Backend . t } [ @@ deriving to_yojson ] to_yojson end module Provider = struct type t = { provider : string ; region : string ; alias : string option ; project : string option ; zone : string option } [ @@ deriving to_yojso...
type t = Block . t list [ @@ deriving to_yojson ] to_yojson
let to_string = Fn . compose Yojson . Safe . pretty_to_string to_yojson
module Dim = struct let value = 4 end
module Float_array = struct include A let zeroes n = make Ctypes . float n ~ initial : 0 . let map = A . map Ctypes . float let init n f = let a = make Ctypes . float n in for i = 0 to ( n - 1 ) do A . set a i @@ f i done ; a let map2 f a b = init ( length a ) ( fun i -> f ( A . get a i ) ( A . get b i ) ) end
module Utils = struct let get , set = Ctypes . ( getf , setf ) let null = Ctypes . null let pp_opt pp ppf = function | None -> ( ) | Some x -> pp ppf x let pp_array ~ sep pp ppf a = Format . fprintf ppf " [ |% a ] " | ( Format . pp_print_list ~ pp_sep : sep pp ) @@ A . to_list a let space = Format . pp_print_cut let ( ...
module Sdl = struct open Tsdl let ( ) <?> x s = match x with | Ok x -> Format . printf " SDL : Success : % s . " @ s ; x | Error _ -> Format . eprintf " SDL : Error : % s . " @ s ; exit 1 let ( ) = Sdl . ( init Init . ( video + events ) ) <?> " Sdl init " let w = Sdl . create_window " Vulkan + SDL test " ~ w : width ~ ...
let create_buffer phy device flag mem_size = let module Memprop = Vkt . Physical_device_memory_properties in let buffer_info = Vkt . Buffer_create_info . make ~ size : mem_size ~ usage : flag ~ sharing_mode : Vkt . Sharing_mode . Exclusive ( ) in let buffer = Vkc . create_buffer device buffer_info ( ) <?> " Buffer crea...
module Instance = struct let extensions = A . of_list Ctypes . string [ " VK_KHR_surface " ; " VK_KHR_xlib_surface " ] let info = Vkt . Instance_create_info . make ~ flags : Vkt . Instance_create_flags . empty ~ enabled_extension_names : extensions ( ) ; ; debug " Info created " let x = Vkc . create_instance info ( ) <...
module Device = struct let phy_devices = let d = Vkc . enumerate_physical_devices instance <?> " physical device " in debug " Number of devices : % d \ n " ( A . length d ) ; d let property device = debug " Device properties acquisition " ; let p = Vkc . get_physical_device_properties device in debug " Device propertie...
let zero_offset = Vkt . Device_size . of_int 0
module Image = struct let surface_format = A . get Device . supported_formats 0 let allocate device image = let reqr = Vkc . get_image_memory_requirements device image in let size = reqr . # Vkt . Memory_requirements . size in debug " Depth buffer size :% d " ( Vkt . Device_size . to_int size ) ; let allocate_info = Vk...
let one_time queue command_pool f = let alloc = Vkt . Command_buffer_allocate_info . make ~ command_pool ~ level : Vkt . Command_buffer_level . Primary ~ command_buffer_count : 1 ( ) in let buffers = Vkc . allocate_command_buffers device alloc <?> " one time buffer " in let b = A . get buffers 0 in let begin_info = Vkt...
module Depth = struct let layout = Vkt . Image_layout . Depth_stencil_attachment_optimal let format = Vkt . Format . D_32_sfloat let format_properties = Vkc . get_physical_device_format_properties Device . phy format ; ; debug " Depth format % a " Vkt . Format_properties . pp format_properties let extent = let open Vkt...
module Geom = struct let geom_size = Vec . dim let texel_size = 2 let stride = geom_size + texel_size let dx = 1 . . / 4 . let flip ( x , y ) = y , x let texcoord c = ( dx . * float ( c mod 4 ) , dx . * float ( c / 4 ) ) let scale = 0 . 5 let u ( ) = Random . float 1 . let point ( u , v ) is a k = let k = stride * k in...
module Heat_equation = struct let xs = 64 and ys = 64 and nface = 6 and form_factor = 16 let xsize = 256 and ysize = 256 let texsize = xsize * ysize let model_size = xs * ys * nface let columns = xsize / xs ; ; assert ( columns = 4 ) let data = Array . init texsize ( fun _ -> Random . float 1 . ) let data ' = Array . m...
let ( ) ++ atlas ( e1 , c , e2 as l ) = atlas . ( e1 . face ) <- l :: atlas . ( e1 . face ) ; atlas . ( e2 . face ) <- ( e2 , c , e1 ) :: atlas . ( e2 . face ) ; atlas
let v k = edge X xs k , Direct , edge X 0 ( ( k + 1 ) mod 4 )
let atlas = [ v 0 ; v 1 ; v 2 ; v 3 ; edge Y ys 0 , Direct , edge Y 0 4 ; edge Y ys 4 , Reverse , edge Y ys 2 ; edge Y 0 2 , Direct , edge Y ys 5 ; edge Y 0 5 , Reverse , edge Y 0 0 ; edge Y ys 1 , Direct , edge X 0 4 ; edge X xs 4 , Reverse , edge Y ys 3 ; edge Y 0 3 , Direct , edge X 0 5 ; edge X xs 5 , Reverse , edg...
let index ( x , y , k ) = x + xs * ( k mod columns ) + xsize * ( y + ys * ( k / columns ) )
let set_edge dir edge values = let n = Array . length values in let pl = edge . len / n in for seg = 0 to n - 1 do for k = 0 to pl - 1 do let pos = reorient dir edge ( k + seg * pl ) in data . ( index ( pos ) ) <- values . ( seg ) done ; done
let set_link ( e , dir , f ) = let u ( ) = let f = 1 . . - ( Random . float 1 . ) ** 2 . in [ | f ; 1 . . - f ] | in set_edge Direct e @@ u ( ) ; set_edge dir f @@ u ( )
let paint_face k c = for x = 1 to xs - 2 do for y = 1 to ys - 2 do data . ( index ( x , y , k ) ) <- c done ; done
let border_index atlas ( _x , _y , k as pos ) = let pos = edge_transition pos atlas . ( k ) in index pos let laplacian dt data data ' ( x , y , k ) = let pos = index ( x , y , k ) in data ' . ( pos ) <- data . ( pos ) . - dt . ( * 4 . . * data . ( pos ) . - data . ( index ( x + 1 , y , k ) ) . - data . ( index ( x - 1 ...
module Texture = struct open Heat_equation let memsize = Vkt . Device_size . of_int @@ texsize * fsize let format = Vkt . Format . R_32_sfloat let src_buffer , memory = create_buffer Device . phy device Vkt . Buffer_usage_flags . transfer_src memsize let transfer_data ( ) = let mem = Vkc . map_memory ~ device ~ memory ...
module Uniform = struct let binding = Vkt . Descriptor_set_layout_binding . make ~ binding : 0 ~ descriptor_count : 1 ~ descriptor_type : Vkt . Descriptor_type . Uniform_buffer ~ stage_flags : Vkt . Shader_stage_flags . vertex ( ) let bindings = Vkt . Descriptor_set_layout_binding . array [ binding ; Texture . descript...
module Pipeline = struct let vertex_binding = Vkt . Vertex_input_binding_description . make ~ binding : 0 ~ stride ( : Geom . stride * fsize ) ~ input_rate : Vkt . Vertex_input_rate . Vertex let attributes = A . make Vkt . Vertex_input_attribute_description . ctype 2 let geom_attribute = Vkt . Vertex_input_attribute_de...
module Cmd = struct ; ; Vkc . update_descriptor_sets ~ device ~ descriptor_writes : Uniform . write_info ( ) let images = Array . init 2 ( fun i -> Vkt . Image_view . array [ A . get Image . views i ; Depth . view ] ) let framebuffer_info i = Vkt . Framebuffer_create_info . make ~ render_pass : Pipeline . simple_render...
module Render = struct let semaphore_info = Vkt . Semaphore_create_info . make ( ) let create_semaphore ( ) = Vkc . create_semaphore device semaphore_info ( ) <?> " Created semaphore " let im_semaphore = create_semaphore ( ) let render_semaphore = create_semaphore ( ) let wait_sems = Vkt . Semaphore . array [ im_semaph...
let vec : Vec . vec * Vec . vec = Vec . ( zero ` vec , zero ` vec ) ; Sdl . ( event_loop Render . draw ( let z = 0 . , 0 . in vec , ( z , z , z , z ) ) e )
let currentWinding = ref GLU_TESS_WINDING_ODD
let dli = ref 0
let makeNewLists = let tobj = gluNewTess ( ) in gluTessDefaultCallback tobj GLU_TESS_VERTEX ; gluTessDefaultCallback tobj GLU_TESS_BEGIN ; gluTessDefaultCallback tobj GLU_TESS_END ; gluTessDefaultCallback tobj GLU_TESS_ERROR ; gluTessDefaultCallback tobj GLU_TESS_COMBINE ; let rects = [ | ( 50 . 0 , 50 . 0 , 0 . 0 ) ; ...
let display ( ) = glClear [ GL_COLOR_BUFFER_BIT ] ; glColor3 1 . 0 1 . 0 1 . 0 ; glPushMatrix ( ) ; glCallList ( ! dli ) ; glTranslate 0 . 0 500 . 0 0 . 0 ; glCallList ( ! dli + 1 ) ; glTranslate ( 500 . 0 ) ( - 500 . 0 ) ( 0 . 0 ) ; glCallList ( ! dli + 2 ) ; glTranslate 0 . 0 500 . 0 0 . 0 ; glCallList ( ! dli + 3 ) ...
let init ( ) = glClearColor 0 . 0 0 . 0 0 . 0 0 . 0 ; glShadeModel GL_FLAT ; dli := glGenLists 4 ; makeNewLists ( ) ; ; ;
let reshape ~ width : w ~ height : h = glViewport 0 0 w h ; glMatrixMode GL_PROJECTION ; glLoadIdentity ( ) ; if ( w <= h ) then gluOrtho2D 0 . 0 1000 . 0 0 . 0 ( 1000 . 0 . * ( float h ) . / ( float w ) ) else gluOrtho2D 0 . 0 ( 1000 . 0 . * ( float w ) . / ( float h ) ) 0 . 0 1000 . 0 ; glMatrixMode GL_MODELVIEW ; gl...
let keyboard ~ key ~ x ~ y = match key with | ' W ' | ' w ' -> begin match ! currentWinding with | GLU_TESS_WINDING_ODD -> currentWinding := GLU_TESS_WINDING_NONZERO ; | GLU_TESS_WINDING_NONZERO -> currentWinding := GLU_TESS_WINDING_POSITIVE ; | GLU_TESS_WINDING_POSITIVE -> currentWinding := GLU_TESS_WINDING_NEGATIVE ;...
let ( ) = ignore ( glutInit Sys . argv ) ; glutInitDisplayMode [ GLUT_SINGLE ; GLUT_RGB ] ; glutInitWindowSize 500 500 ; ignore ( glutCreateWindow Sys . argv . ( 0 ) ) ; let version = gluGetString GLU_VERSION in if version < " 1 . 2 " then begin Printf . eprintf " This program demonstrates the new tesselator API in GLU...
type t = { a : string ; b : string ; c : string ; }
let t = { a = " a_pretty_long_string_to_force_separate_line " ; b = " a_pretty_long_string_to_force_separate_line " ; c = " a_pretty_long_string_to_force_separate_line " ; }
type t = | A of int | B of string | C of unit
type t = [ ` A of int | ` B of string | ` C of unit ]
let list = [ a ; b ; c ]
let list = [ a_very_long_identifier_or_expression_one ; a_very_long_identifier_or_expression_two ; a_very_long_identifier_or_expression_three ; ]
let bool = match true with | true -> false | false -> true
let ( ) = match ( ) with | ( ) -> print_endline " foo " ; print_endline " bar "
let ( ) = match true with | true -> begin match ( ) with | ( ) -> print_endline " foo " ; print_endline " bar " end | ( ) -> print_endline " foo " ; print_endline " bar "
let f = function | ( ) -> print_endline " foo " ; print_endline " bar "
let ( ) = if true then ( ) else ( )
type test_variant = [ ` Case1 | ` Case2 of int | ` Case3 of string | ` Case4 of test_variant list ]
type ( ' x , ' y ) poly = { fst : ' x list ; snd : ( ' x , ' y ) poly option }
type ' a p ' = A | Bb of ' a p ' | Ccccc of ' a
type p = [ ` A | ` B of r | ` C ]
type validate_me = string list
type val1 = { val1_x : int }
type val2 = { val2_x : val1 ; val2_y : val1 option }
type unixtime_list = float list
type date = ( int * int option * int option )
type mixed_record = { field0 : int option ; field1 : float option ; field2 : string option ; field3 : Int64 . t ; field4 : float Atdgen_runtime . Util . ocaml_array ; field5 : bool option ; field6 : string option ; field7 : test_variant ; field8 : string Atdgen_runtime . Util . ocaml_array ; field9 : ( int * int * Char...