Skip to content
This repository
tag: v298
Fetching contributors…

Cannot retrieve contributors at this time

file 743 lines (662 sloc) 22.03 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
Opa and Qml compilers are based on this mechanism.
We use this file as a tutorial and a memo because in qml and opa, the proportion
of the asts may lead to be confusing about keeping in mind this global design.

This file is a also a tiny example of how to use the passlib pass handler and track system.

@author Mathieu Barbin
@author Quentin Bourgerie
@author Valentin Gatien-Baron
*)

(* you can search for 'open' in that file *)

module Arg = Base.Arg
module List = Base.List
module String = Base.String

module LangAst =
struct
  type expr =
    | A
    | B of expr * expr
    | K of int
    | Directive of (PassTracker.t * expr)

  type code_elt =
    | Val of string * expr
    | Package of [`declaration | `import] * string * FilePos.pos

  type code = code_elt list
end

module LangWalk =
struct
  module L = LangAst
  module Subs =
  struct
    type 'a t = LangAst.expr constraint 'a = _ * _ * _
    let foldmap tra acc t =
      match t with
      | L.A -> acc, t
      | L.B (a, b) ->
          let acc, a' = tra acc a in
          let acc, b' = tra acc b in
          acc,
          if a == a' && b == b' then t else
            L.B (a', b')
      | L.K _ -> acc, t
      | L.Directive (k, e) ->
          let acc, e' = tra acc e in
          acc,
          if e == e' then t else
            L.Directive (k, e')
    let iter x = Traverse.Unoptimized.iter foldmap x
    let map x = Traverse.Unoptimized.map foldmap x
    let fold x = Traverse.Unoptimized.fold foldmap x
  end
  module Expr = Traverse.Make2 ( Subs )
  module Elt_Subs =
  struct
    type 'a t = LangAst.expr constraint 'a = _ * _ * _
    type 'a container = LangAst.code_elt constraint 'a = _ * _ * _
    let foldmap tra acc t = match t with
    | L.Val (s, e) ->
        let acc, e' = tra acc e in
        acc,
        if e == e' then t else
          L.Val (s, e')
    | L.Package _ -> acc, t
    let iter tra = function
      | L.Val (_, e) -> tra e
      | L.Package _ -> ()
    let map x = Traverse.Unoptimized.map foldmap x
    let fold x = Traverse.Unoptimized.fold foldmap x
  end
  module Elt = Traverse.MakeLift1 (Elt_Subs) (Expr)
  module Code_Subs =
  struct
    type 'a t = LangAst.code_elt constraint 'a = _ * _ * _
    type 'a container = LangAst.code constraint 'a = _ * _ * _
    let iter = List.iter
    let map = List.map
    let fold = List.fold_left
    let foldmap = List.fold_left_map
  end
  module Code = Traverse.MakeLift2 (Code_Subs) (Elt)
  (* bring freds work there : ast projector *)
  (* usefull for meta opa (bsl ast projector) *)
  type 'proj projector =
      {
        a : 'proj ;
        b : 'proj -> 'proj -> 'proj ;
        k : int -> 'proj ;
        directive : PassTracker.t -> 'proj -> 'proj ;
      }
  let projection proj =
    let rec aux = function
      | L.A -> proj.a
      | L.B (a, b) -> proj.b (aux a) (aux b)
      | L.K i -> proj.k i
      | L.Directive (t, e) -> proj.directive t (aux e)
    in aux
  (* even more generical than the traverse *)
  (* if we define a foldmap_projection, you'll get
the walker foldmap by applying it with LangCons
as argument *)
end

module LangCons =
struct
  module L = LangAst
  let a = L.A
  let b a b = L.B (a, b)
  let k i = L.K i
end

module LangPrint =
struct
  module L = LangAst
  class print =
  object(self)
    method expr fmt = function
      | L.A -> Format.pp_print_char fmt 'A'
      | L.B (a, b) -> Format.fprintf fmt "@[<v2>B@ (%a)@ (%a)@]" self#expr a self#expr b
      | L.K i -> Format.pp_print_int fmt i
      | L.Directive (_, e) -> self#expr fmt e
    method code_elt fmt = function
      | L.Val (s, expr') -> Format.fprintf fmt "@[<2>val %s =@\n%a@]" s self#expr expr'
      | L.Package (`declaration, name, _) -> Format.fprintf fmt "package %s" name
      | L.Package (`import, name, _) -> Format.fprintf fmt "import %s" name
    method code fmt =
      List.iter (fun elt -> Format.fprintf fmt "%a@\n@\n" self#code_elt elt)
  end
  class bb_printer =
  object(self)
    inherit print as super
    method expr fmt = function
      | L.B (a, b) -> Format.fprintf fmt "@[<v2>BB@ (%a)@ (%a)@]" self#expr a self#expr b
      | e -> super#expr fmt e
  end
  let p = new print
  let expr = p#expr
  let code_elt = p#code_elt
  let code = p#code
end

module LangUtils =
struct
  module B =
  struct
    type 'a b_util = LangAst.expr -> LangAst.expr -> 'a
  end
end

module LangTrack =
struct
  module L = LangAst

  let trackers iter =
    LangWalk.Code.iter
      (function
         | L.Directive (t, e) -> iter.PassTracker.track (PassTracker.filename t) LangPrint.expr e
         | _ -> () )

  let vals iter = List.iter (
    function
      | ( L.Val (s, _) ) as v -> iter.PassTracker.track s LangPrint.code_elt v
      | _ -> ()
  )

  let code_id = PassHandler.define_printer "code"

  let printers = [
    code_id, LangPrint.code ;
  ]

  let trackers_id = PassHandler.define_tracker "trackers"
  let val_id = PassHandler.define_tracker "val"

  let trackers = [
    trackers_id, trackers ;
    val_id, vals ;
  ]
end

module LangError :
sig
  type context = (* or abstract *)
      {
        code_elt : LangAst.code_elt ;
        expr : LangAst.expr ;
      }
  val context : LangAst.code_elt -> LangAst.expr -> context
  val check_fail : PassHandler.cond_id -> context -> ('a, 'error) OManager.oformat -> 'a
  val scheck_fail : PassHandler.cond_id -> context -> ('a, unit) OManager.oformat -> 'a

  (** Overlaying PassHandler for located internal errors *)
  val cond_violation : PassHandler.cond_id -> context -> ('a, 'error) OManager.oformat -> 'a
  val scond_violation : PassHandler.cond_id -> context -> ('a, unit) OManager.oformat -> 'a
  val i_error : PassHandler.cond_id option -> context -> ('a, 'error) OManager.oformat -> 'a
  val i_serror : PassHandler.cond_id option -> context -> ('a, unit) OManager.oformat -> 'a

  (** Overlaying OManager for located errors *)
  (* val error : context -> ('a, unit, string, unit) format4 -> 'a *)
  (* val serror : context -> ('a, unit, string, unit) format4 -> 'a *)
  (* val warning : wclass:WarningClass.wclass -> context -> ('a, unit, string, unit) format4 -> 'a *)
  (* etc with the interface of OManager by partial call of the type (using internally OManager) *)
end =
struct
  type context =
      {
        code_elt : LangAst.code_elt ;
        expr : LangAst.expr ;
      }
  let context code_elt expr = { code_elt = code_elt ; expr = expr }
  let context_printer fmt context =
    Format.fprintf fmt "In the following toplevel definition :@\n%a@\nIn the following expression@\n%a\n" LangPrint.code_elt context.code_elt LangPrint.expr context.expr
  let console fmt context = Format.fprintf fmt "%a@\n" LangPrint.expr context.expr
  let check_fail c =
    PassHandler.check_fail ~full:context_printer ~console c

  let scheck_fail c =
    PassHandler.scheck_fail ~full:context_printer ~console c

  (* overlaying for passes *)
  let scond_violation c = PassHandler.scond_violation context_printer c
  let cond_violation c = PassHandler.cond_violation context_printer c
  let i_error c = PassHandler.i_error context_printer c
  let i_serror c = PassHandler.i_serror context_printer c
end

(* introduce some buggy scenario in the compiler (see documentation in arg.parse) *)
let bug_rewriting = ref false
let bug_allowed_cond_violation = ref false
let bug_cond_violation_contradiction = ref false
let bug_unbound_cond_violation = ref false
let bug_not_found = ref false

let current_filename = ref ""
let current_content = ref ""
let current_package_index = ref 1

let extrapaths = ref []

module LangCheck =
struct
  type ('env, 'a) checker = ('env -> 'a) -> 'env PassHandler.cond
  module K_values :
  sig
    val positives : ('env, LangAst.code) checker
    val positives_id : PassHandler.cond_id
  end =
  struct
    module L = LangAst

    let (!!) code_elt expr = LangError.context code_elt expr

    let positives_id = PassHandler.define_cond (* WarningClass.cond_theme_example
but there for testing : *) WarningClass.cond
    (* all K are positives *)
    let positives extract =
      PassHandler.make_condition positives_id
        (fun env -> List.iter
           (function
              | ( L.Val (_, e) ) as v ->
                  LangWalk.Expr.iter
                    (fun e -> match e with
                     | ( L.K i ) as e -> if !bug_cond_violation_contradiction then () else
                         if i < 0 then LangError.scheck_fail positives_id (!! v e) "positives check: %d < 0\n" i
                     | _ -> ()
                    ) e
              | _ -> ()
           )
           (extract env)
        )
  end

  module OtherTheme =
  struct
  end
end

module Lang =
struct
  module Ast = LangAst
  module Walk = LangWalk
  module Cons = LangCons
  (* module DeCons = LangDecons *)
  module Print = LangPrint
  (* module Parse = LangParse *)
  module Utils = LangUtils
  module Track = LangTrack
  module Error = LangError
  module Check = LangCheck
end

(* OUTSIDE OF THE KERNEL OF THE LANG *)

(* EXAMPLES OF PASSES *)

(* loading object *)
module LoadObjects =
struct
  module L = Lang.Ast
  let load code k =
    let extract_packages_decl = function
      | L.Package (kind, name, pos) -> Some (kind, name, pos)
      | _ -> None in
    let extract_more_deps _ = StringMap.empty in
    ObjectFiles.set_extrapaths ~no_stdlib:true !extrapaths;
    let l = [(!current_filename,!current_content,code)] in
    ObjectFiles.load ~no_stdlib:true extract_packages_decl extract_more_deps l
      (function
         | [(_,_,code)] -> k code
         | _ -> assert false)
end

(* alpha renaming *)
module AlphaConv =
struct
  module L = Lang.Ast
  type env = int IntMap.t * int

  (* separation *)
  module S =
  struct
    (* keep the bigger index used for renaming variables *)
    type t = int
    let pass = "AlphaConv"
    let pp = Format.pp_print_int
  end
  module R = ObjectFiles.Make(S)

  let initial () =
    let fold index t = max index t in
    let index = R.fold fold 0 in
    IntMap.empty, index

  let expr env =
    Lang.Walk.Expr.foldmap
      (fun ((env, index) as acc) -> function
         | L.K i -> if !bug_rewriting then acc, L.K (-1) else
             begin
               match IntMap.find_opt i env with
               | None ->
                   let env = IntMap.add i index env in
                   (env, succ index), L.K index
               | Some i ->
                   (env, index), L.K i
             end
         | t -> acc, t) env
  let code_elt e = Lang.Walk.Elt.foldmap_nonrec expr e
  let code e = Lang.Walk.Code.foldmap_nonrec expr e

  let pass c =
    let e = initial () in
    let (_, i), c = code e c in
    R.save i;
    c
end

(*
dummy1 :
+ K 0 => A
*)
module Dummy1 =
struct
  module L = Lang.Ast
  let (!!) v e = Lang.Error.context v e
  let expr v =
    Lang.Walk.Expr.map_up
      (function
         | (L.K _) as t when !bug_cond_violation_contradiction ->
             Lang.Error.cond_violation Lang.Check.K_values.positives_id (!! v t) "contradiction"
         | (L.K i) as t ->
             (if !bug_allowed_cond_violation && (i < 0) then
                Lang.Error.cond_violation Lang.Check.K_values.positives_id (!! v t) "%d < 0" i
             );
             if i = 0 then L.A else t
         | t -> t)
  let code_elt code_elt = Lang.Walk.Elt.map_nonrec (expr code_elt) code_elt
  let code env = List.map code_elt env
end

(*
dummy2
+ B (a, b) => B (9, b)
*)
module Dummy2 =
struct
  module L = Lang.Ast
  let (!!) v e = Lang.Error.context v e
  let expr v =
    Lang.Walk.Expr.map_up
      (function
         | (L.K i) as e ->
             (if !bug_unbound_cond_violation && (i < 0) then
                Lang.Error.scond_violation Lang.Check.K_values.positives_id (!! v e) "%d < 0" i
             );
             e
         | L.B (_, b) -> L.B (L.K (if !bug_rewriting then (-9) else 9), b)
         | t -> t)
  let code_elt code_elt = Lang.Walk.Elt.map_nonrec (expr code_elt) code_elt
  let code env = List.map code_elt env
end

module InsertTracker =
struct
  module L = Lang.Ast

  (* For the example, we add track at top level *)
  let insert = List.map
    (function
       | L.Val (id, e) ->
           let t = PassTracker.next id in
           L.Val (id, L.Directive (t, e))
       | c -> c
    )
end

(*
Simulating the linking.
In compilation mode: store the code.
In linking mode: regroup all the code.
*)
module Linking =
struct

  module S =
  struct
    type t = LangAst.code
    let pass = "Linking"
    let pp f _ = Format.pp_print_string f "<dummy>"
  end
  module R = ObjectFiles.Make(S)

  let pass code =
    match ObjectFiles.compilation_mode () with
    | `compilation ->
        OManager.unquiet "compilation of package @{<bright>%S@} ok." !current_filename;
        R.save code;
        OManager.exit 0
    | `init ->
        code
    | `linking | `prelude ->
        let fold (package_name,pos) code t =
          OManager.verbose "linking with @{<bright>%s@}:%a" package_name FilePos.pp_pos pos ;
          code @ t in
        let full_parent_code = R.fold_with_name ~packages:true ~deep:true fold [] in
        let full_code = full_parent_code @ code in
        OManager.unquiet "linking ok.";
        full_code
end

module S3Passes =
struct
  module PH = PassHandler
  module L = Lang.Ast
    (* No parser, we use this : *)
  let code () =
    match !current_package_index with
    | 1 ->
        current_filename := "package-01.opa" ;
        current_content := String.random 10 ;
        [
          L.Package (`declaration, "package-01", FilePos.nopos "position of declaration package-01") ;
          L.Val ("toto", L.B (L.A, L.K 36)) ;
          L.Val ("titi", L.B (L.K 5,
                              L.B (L.K 4,
                                   L.B (L.A,
                                        L.B (L.A,
                                             L.B (L.K 5, L.K 0)
                                            )
                                       )
                                  )
                             )
                )
        ]
    | 2 ->
        current_filename := "package-02.opa" ;
        current_content := String.random 10 ;
        [
          L.Package (`declaration, "package-02", FilePos.nopos "position of declaration package-02") ;
          L.Package (`import, "package-01", FilePos.nopos "position of import package-01") ;
          L.Val ("toto", L.B (L.A, L.K 02)) ;
        ]
    | 3 ->
        current_filename := "package-03.opa" ;
        current_content := String.random 10 ;
        [
          L.Package (`declaration, "package-03", FilePos.nopos "position of declaration package-02") ;
          L.Package (`import, "package-02", FilePos.nopos "position of import package-02") ;
          L.Val ("toto", L.B (L.A, L.K 03)) ;
        ]
    | 4 ->
        (* simulating the final linking *)
        current_filename := "linking" ;
        current_content := "nothing" ;
        []
    | _ -> assert false

  let pass_Welcome () =
    PH.make_pass
      (fun _ ->
         OManager.printf "Prototype compiler for testing new pass system@\n";
         OManager.verbose "Compilation mode is %s" (
           match ObjectFiles.compilation_mode () with
           | `linking -> "linking"
           | `init -> "init"
           | `compilation -> "compilation"
           | `prelude -> "prelude"
         );
         PassHandler.init
      )

  let pass_Parse () =
    PH.make_pass
      (fun env ->
         { PH.
           env = code ();
           options = env.PH.options;
           printers = (fun _ -> Lang.Track.printers);
           trackers = (fun _ -> Lang.Track.trackers);
         })

  let pass_LoadObjects k =
    PH.make_pass
      (fun env ->
         let env = LoadObjects.load env.PH.env (fun code -> k ( { env with PH.env = code })) in
         PH.make_env () env
      )

  let pass_InsertTracker =
    PH.make_pass
      (fun env ->
         { env with
             PH.env = InsertTracker.insert env.PH.env
         })

  let pass_AlphaConv () =
    let extract s = s in
    let postcond =
      [
        Lang.Check.K_values.positives extract
      ] in
    PH.make_pass ~postcond
      (fun env ->
         let code = env.PH.env in
         let code = AlphaConv.pass code in
         { env with
             PH.env = code
         })

  let pass_NotFound = PH.make_pass (fun _ -> raise Not_found)

  let pass_Dummy1 =
    let extract s = s in
    let precond =
      [
        Lang.Check.K_values.positives extract
      ] in
    PH.make_pass ~precond
      (fun env ->
         { env with
             PH.env = Dummy1.code env.PH.env
         })

  let pass_Dummy2 =
    let extract s = s in
    let postcond =
      [
        Lang.Check.K_values.positives extract
      ] in
    PH.make_pass ~postcond
      (fun env ->
         { env with
             PH.env = Dummy2.code env.PH.env
         })

  let pass_Linking =
    PH.make_pass
      (fun env ->
         { env with
             PH.env = Linking.pass env.PH.env
         })

  let pass_Final _ =
    PH.make_pass (
      fun _ -> {
        PH.
          env = 0 ;
          options = ();
          printers =
            (fun _ -> [
               LangTrack.code_id,
               (fun fmt i ->
                  Format.pp_print_int fmt i ;
                  Format.pp_print_char fmt '\n'
               );
             ]);
          trackers = (fun _ -> []);
      }
    )

  let pass_Exit _ =
    PH.make_pass (
      fun env ->
        OManager.printf "exit %d\n" env.PH.env ;
        { PH.
            env = () ;
            options = ();
            printers =
              (fun _ -> [
                 LangTrack.code_id,
                 (fun fmt () ->
                    Format.fprintf fmt "Compilation if over -- no more code to print\n"
                 );
               ]) ;
            trackers = (fun _ -> []) ;
        }
    )
end

module Main =
struct
  module PH = PassHandler
  module S3 = S3Passes
  let (|>) a f = f a

  let if_not_found ~options:_ _ = !bug_not_found

  (* Normal style *)
  let normal () =
    PH.init
    |> PH.handler "Welcome" (S3.pass_Welcome())
    |> PH.handler "Parse" (S3.pass_Parse())
    |> PH.handler "LoadObjects" (S3.pass_LoadObjects (fun e -> e
      |> PH.handler "InsertTracker" S3.pass_InsertTracker
      |> PH.handler "AlphaConv" (S3.pass_AlphaConv())
      |> PH.if_handler ~if_:if_not_found "NotFound" S3.pass_NotFound
      |> PH.handler "Dummy1" S3.pass_Dummy1
      |> PH.handler "Dummy2" S3.pass_Dummy2
      |> PH.handler "Linking" S3.pass_Linking
      |> PH.handler "Final" (S3.pass_Final())
      |> PH.handler "Exit" (S3.pass_Exit())
      |> PH.return ))
    |> PH.return

  (* Binary operator style *)
  let (|?>) = PassHandler.(|?>)
  let (|+>) = PassHandler.(|+>)

  let binop () =
    PH.init
    |+> ("Welcome" , S3.pass_Welcome() )
    |+> ("Parse" , S3.pass_Parse() )
    |+> ("LoadObjects" , S3.pass_LoadObjects (fun e -> e
      |+> ("InsertTracker" , S3.pass_InsertTracker )
      |+> ("AlphaConv" , S3.pass_AlphaConv() )
      |?> (if_not_found,
           "NotFound" , S3.pass_NotFound )
      |+> ("Dummy1" , S3.pass_Dummy1 )
      |+> ("Dummy2" , S3.pass_Dummy2 )
      |+> ("Linking" , S3.pass_Linking )
      |+> ("Final" , S3.pass_Final() )
      |+> ("Exit" , S3.pass_Exit() )
      |> PH.return ))
    |> PH.return
end

let _ =
  let bugs =
    [

      "--bug1",
      Arg.Set bug_rewriting,
      " Introduce some bug in a rewriting rule of the compilation. If the check is activated, this is detected as post condition failure, if not, nothing appends";


      "--bug2",
      Arg.Set bug_allowed_cond_violation,
      " Introduce a cond violation detection during the compilation. If the check is activated, the pass is not executed, if not, the check is executed afterwards. Should be combined with --bug1 or not to test";


      "--bug3",
      Arg.Set bug_cond_violation_contradiction,
      " Introduce a cond violation during the compilation, but so that for the checker point of vue the condition is not violated. If the check is activated, the pass is executed, if not the check is executed afterwards, in both case an explanation is given";


      "--bug4",
      Arg.Set bug_unbound_cond_violation,
      " Introduce a rule declaring a cond violation where the cond is not in its preconditions should be combined with --bug1";


      "--bug5",
      Arg.Set bug_not_found,
      " Introduce an uncaught exception during compilation (Not_found)";

      "--file",
      Arg.Symbol (["1"; "2"; "3"; "4"],
                  (fun s ->
                     current_package_index := int_of_string s
                  )),
      " Tell what file to compile (testing separated compilation)"
      ;

      "-I",
      Arg.String (fun s -> List.iter (fun p -> extrapaths := p :: !extrapaths) (Arg.split s)),
      " Add extra path for loading packages"
      ;

    ] in

  let _ =
    Arg.parse
      (Arg.align
         (bugs
          @ ObjectFiles.Arg.public_options
          @ ObjectFiles.Arg.private_options
          @ PassHandler.Arg.options
          @ WarningClass.Arg.options ()
          @ OManager.Arg.options
         ))
      ignore "passdesign" in
  Main.binop ()
Something went wrong with that request. Please try again.