Make the locations in error messages more specific.
authorRichard W.M. Jones <rich@annexia.org>
Tue, 1 Jul 2008 11:26:12 +0000 (11:26 +0000)
committerRichard W.M. Jones <rich@annexia.org>
Tue, 1 Jul 2008 11:26:12 +0000 (11:26 +0000)
pa_bitmatch.ml

index da477e7..bae6ece 100644 (file)
@@ -166,8 +166,6 @@ let build_bitmatch_call _loc funcname length endian signed =
 
 (* Generate the code for a constructor, ie. 'BITSTRING ...'. *)
 let output_constructor _loc fields =
-  let fail = locfail _loc in
-
   let loc_fname = Loc.file_name _loc in
   let loc_line = string_of_int (Loc.start_line _loc) in
   let loc_char = string_of_int (Loc.start_off _loc - Loc.start_bol _loc) in
@@ -195,6 +193,8 @@ let output_constructor _loc fields =
       let _loc = P.get_location field in
       let offset = P.get_offset field in
 
+      let fail = locfail _loc in
+
       (* offset() not supported in constructors.  Implementation of
        * forward-only offsets is fairly straightforward: we would
        * need to just calculate the length of padding here and add
@@ -400,8 +400,6 @@ let output_constructor _loc fields =
  * the list of cases to test against.
  *)
 let output_bitmatch _loc bs cases =
-  let fail = locfail _loc in
-
   let data = gensym "data" and off = gensym "off" and len = gensym "len" in
   let result = gensym "result" in
 
@@ -426,6 +424,8 @@ let output_bitmatch _loc bs cases =
        let _loc = P.get_location field in
        let offset = P.get_offset field in
 
+       let fail = locfail _loc in
+
        (* Is flen (field len) an integer constant?  If so, what is it?
         * This will be [Some i] if it's a constant or [None] if it's
         * non-constant or we couldn't determine.