]> Repositorios git - scryer-prolog.git/commitdiff
make double_quotes write option not dependent on double_quotes flag
authorMarkus Triska <[email protected]>
Wed, 5 Jul 2023 19:22:49 +0000 (21:22 +0200)
committerMarkus Triska <[email protected]>
Wed, 5 Jul 2023 19:37:11 +0000 (21:37 +0200)
This gives consistent results without depending on another flag.

src/heap_print.rs
src/machine/machine_state.rs
src/machine/mock_wam.rs
src/toplevel.pl

index 7cd8b7133a9924101a50da351455afeca66cdf1c..10a211a1fe177f5e8dedfdf4586fd38877a863ac 100644 (file)
@@ -487,7 +487,6 @@ pub struct HCPrinter<'a, Outputter> {
     iter: StackfulPreOrderHeapIter<'a>,
     atom_tbl: &'a mut AtomTable,
     op_dir: &'a OpDir,
-    flags: MachineFlags,
     state_stack: Vec<TokenOrRedirect>,
     toplevel_spec: Option<DirectedOp>,
     last_item_idx: usize,
@@ -555,7 +554,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
         atom_tbl: &'a mut AtomTable,
         stack: &'a mut Stack,
         op_dir: &'a OpDir,
-        flags: MachineFlags,
         output: Outputter,
         cell: HeapCellValue,
     ) -> Self {
@@ -564,7 +562,6 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
             iter: stackful_preorder_iter(heap, stack, cell),
             atom_tbl,
             op_dir,
-            flags,
             state_stack: vec![],
             toplevel_spec: None,
             last_item_idx: 0,
@@ -1187,7 +1184,7 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
 
         let at_cdr = self.outputter.ends_with("|");
 
-        if self.double_quotes && self.flags.double_quotes == DoubleQuotes::Chars {
+        if self.double_quotes {
             if !at_cdr && !self.ignore_ops && end_cell.is_string_terminator(&self.iter.heap) {
                 self.remove_list_children(focus.value() as usize);
                 return self.print_proper_string(focus.value() as usize, max_depth);
index 78b1a7f57f118597e570c18c9e22bb9de3a7e7de..5ef74003411446a8d1106413c377c922c6ce56dc 100644 (file)
@@ -786,7 +786,6 @@ impl MachineState {
                     &mut self.atom_tbl,
                     &mut self.stack,
                     op_dir,
-                    self.flags,
                     PrinterOutputter::new(),
                     term_to_be_printed,
                 );
index a4aad74c611362c440d9e45d7b0a4ed42b205ec9..70264ac9a6f62718d0b74597854b3b2a123a647e 100644 (file)
@@ -64,7 +64,6 @@ impl MockWAM {
             &mut self.machine_st.atom_tbl,
             &mut self.machine_st.stack,
             &self.op_dir,
-            self.machine_st.flags,
             PrinterOutputter::new(),
             heap_loc_as_cell!(term_write_result.heap_loc),
         );
index 2df6d3601eff84cb09bcd11d9b7fc5c246c18bcd..870b6990fa4adf84f4aee5c0b6a8bbcad73143d0 100644 (file)
@@ -221,7 +221,13 @@ arity_specifier(0, _).
 arity_specifier(1, S) :- atom_chars(S, [_,_]).
 arity_specifier(2, S) :- atom_chars(S, [_,_,_]).
 
+double_quotes_option(DQ) :-
+    (   current_prolog_flag(double_quotes, chars) -> DQ = true
+    ;   DQ = false
+    ).
+
 write_goal(G, VarList, MaxDepth) :-
+    double_quotes_option(DQ),
     (  G = (Var = Value) ->
        (  var(Value) ->
           select((Var = _), VarList, NewVarList)
@@ -231,16 +237,17 @@ write_goal(G, VarList, MaxDepth) :-
        write(' = '),
        (  needs_bracketing(Value, =) ->
           write('('),
-          write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)]),
+          write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)]),
           write(')')
-       ;  write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)])
+       ;  write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)])
        )
     ;  G == [] ->
        write('true')
-    ;  write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(true)])
+    ;  write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(DQ)])
     ).
 
 write_last_goal(G, VarList, MaxDepth) :-
+    double_quotes_option(DQ),
     (  G = (Var = Value) ->
        (  var(Value) ->
           select((Var = _), VarList, NewVarList)
@@ -250,9 +257,9 @@ write_last_goal(G, VarList, MaxDepth) :-
        write(' = '),
        (  needs_bracketing(Value, =) ->
           write('('),
-          write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)]),
+          write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)]),
           write(')')
-       ;  write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(true)]),
+       ;  write_term(Value, [quoted(true), variable_names(NewVarList), max_depth(MaxDepth), double_quotes(DQ)]),
           (  trailing_period_is_ambiguous(Value) ->
              write(' ')
           ;  true
@@ -260,7 +267,7 @@ write_last_goal(G, VarList, MaxDepth) :-
        )
     ;  G == [] ->
        write('true')
-    ;  write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(true)])
+    ;  write_term(G, [quoted(true), variable_names(VarList), max_depth(MaxDepth), double_quotes(DQ)])
     ).
 
 write_eq((G1, G2), VarList, MaxDepth) :-