Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed annotations on assembly output for assembly-checker #1357

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Assembly/Equality.v
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ Definition Line_beq (x y : Line) : bool
:= ((x.(indent) =? y.(indent))%string
&& (x.(rawline) =? y.(rawline))%RawLine
&& (x.(pre_comment_whitespace) =? y.(pre_comment_whitespace))%string
&& option_beq String.eqb x.(comment) y.(comment))%bool.
&& option_beq String.eqb x.(comment) y.(comment))%bool
&& (x.(line_number) =? y.(line_number))%N.
Global Arguments Line_beq !_ !_ / .

Infix "=?" := Line_beq : Line_scope.
Expand Down
5 changes: 3 additions & 2 deletions src/Assembly/Equivalence.v
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ Definition AnnotatedLines := (Lines * symbolic_state)%type.

Definition show_annotated_Line : Show AnnotatedLine
:= fun '(l, d)
=> let l := show l in
(l ++ match dag.eager.description_lookup d l with
=> let l_n := show_Line_with_line_number l in
let l := show l in
(l ++ match dag.eager.description_lookup d l_n with
| [] => ""
| new_idxs
=> String.Tab ++ "; " ++ String.concat ", " (List.map (fun i => "#" ++ show i) new_idxs)
Expand Down
19 changes: 12 additions & 7 deletions src/Assembly/Parse.v
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ Definition parse_RawLine : ParserAction RawLine
parsed_prefix
end.

Definition parse_Line : ParserAction Line
Definition parse_Line (line_num : N) : ParserAction Line
:= fun s
=> let '(indentv, rest_linev) := take_while_drop_while Ascii.is_whitespace s in
let '(precommentv, commentv)
Expand All @@ -367,23 +367,24 @@ Definition parse_Line : ParserAction Line
let rawlinev := String.rev rev_rawlinev in
let trailing_whitespacev := String.rev rev_trailing_whitespacev in
List.map
(fun '(r, rem) => ({| indent := indentv ; rawline := r ; pre_comment_whitespace := trailing_whitespacev ; comment := commentv |}, rem))
(fun '(r, rem) => ({| indent := indentv ; rawline := r ; pre_comment_whitespace := trailing_whitespacev ; comment := commentv ; line_number := line_num |}, rem))
(parse_RawLine rawlinev).

(* the error is the unparsable lines *)
Fixpoint parse_Lines' (l : list string) : ErrorT (list string) Lines
Fixpoint parse_Lines' (l : list string) (line_num : N) : ErrorT (list string) Lines
:= match l with
| [] => Success []
| l :: ls
=> match finalize parse_Line l, parse_Lines' ls with
| None, Error ls => Error (l :: ls)
| None, Success _ => Error (l :: nil)
=> match finalize (parse_Line line_num) l, parse_Lines' ls (line_num + 1) with
| None, Error ls => Error (("Line " ++ show line_num ++ ": " ++ l) :: ls)
| None, Success _ => Error (("Line " ++ show line_num ++ ": " ++ l) :: nil)
| Some _, Error ls => Error ls
| Some l, Success ls => Success (l :: ls)
end
end.

Definition parse_Lines (l : list string) := parse_Lines' (String.split_newlines l).
Definition parse_Lines (l : list string) : ErrorT (list string) Lines
:= parse_Lines' (String.split_newlines l) 1.

Notation parse := parse_Lines (only parsing).

Expand Down Expand Up @@ -465,6 +466,10 @@ Global Instance show_Line : Show Line
| Some c => ";" ++ c
| None => ""
end.

Definition show_Line_with_line_number : Show Line
:= fun l => show l ++ "; (line " ++ show l.(line_number) ++ ")".

Global Instance show_lines_Lines : ShowLines Lines
:= fun ls => List.map show ls.

Expand Down
2 changes: 1 addition & 1 deletion src/Assembly/Symbolic.v
Original file line number Diff line number Diff line change
Expand Up @@ -3480,7 +3480,7 @@ Definition SymexRawLine {descr:description} (rawline : RawLine) : M unit :=
end.

Definition SymexLine line :=
let descr:description := Build_description (show line) false in
let descr:description := Build_description (Parse.show_Line_with_line_number line) false in
SymexRawLine line.(rawline).

Fixpoint SymexLines (lines : Lines) : M unit
Expand Down
2 changes: 1 addition & 1 deletion src/Assembly/Syntax.v
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Inductive RawLine :=
| INSTR (instr : NormalInstruction)
.
Coercion INSTR : NormalInstruction >-> RawLine.
Record Line := { indent : string ; rawline :> RawLine ; pre_comment_whitespace : string ; comment : option string }.
Record Line := { indent : string ; rawline :> RawLine ; pre_comment_whitespace : string ; comment : option string ; line_number : N}.
Definition Lines := list Line.

Definition reg_size (r : REG) : N :=
Expand Down