[m-rev.] diff: delete further old C interface stuff

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Jun 16 17:53:46 AEST 2011


Branches: main

Delete more old C interface stuff.

compiler/add_pragma.m:
 	Delete code that was previously required for handling pragma
 	import declarations.

compiler/mercury_compile.m:
compiler/ml_elim_nested.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/var_locn.m:
 	Update references to the old C interface.

Julien.

Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.119
diff -u -r1.119 add_pragma.m
--- compiler/add_pragma.m	16 Jun 2011 06:42:13 -0000	1.119
+++ compiler/add_pragma.m	16 Jun 2011 07:45:50 -0000
@@ -2213,11 +2213,10 @@
                  pred_info_get_arg_types(!.PredInfo, ArgTypes),
                  pred_info_get_purity(!.PredInfo, Purity),
                  pred_info_get_markers(!.PredInfo, Markers),
-                clauses_info_add_pragma_foreign_proc(standard_foreign_proc,
-                    Purity, Attributes, PredId, ProcId, ProgVarSet, PVars,
-                    ArgTypes, PragmaImpl, Context, PredOrFunc,
-                    PredName, Arity, Markers, ClausesInfo1, ClausesInfo,
-                    !ModuleInfo, !Specs),
+                clauses_info_add_pragma_foreign_proc(Purity, Attributes,
+                    PredId, ProcId, ProgVarSet, PVars, ArgTypes, PragmaImpl,
+                    Context, PredOrFunc, PredName, Arity, Markers,
+                    ClausesInfo1, ClausesInfo, !ModuleInfo, !Specs),
                  pred_info_set_clauses_info(ClausesInfo, !PredInfo),
                  pred_info_update_goal_type(goal_type_foreign, !PredInfo),
                  map.det_update(PredId, !.PredInfo, Preds0, Preds),
@@ -3092,28 +3091,20 @@
          PragmaVars0 = []
      ).

-    % This type is used to distinguish between those foreign_procs that
-    % were created by the transformation for `:- pragma import' and those
-    % that were not.
-    %
-:- type foreign_proc_origin
-    --->    standard_foreign_proc
-    ;       pragma_import_foreign_proc.
-
      % Add the pragma_foreign_proc goal to the clauses_info for this procedure.
      % To do so, we must also insert unifications between the variables in the
      % pragma foreign_proc declaration and the head vars of the pred. Also
      % return the hlds_goal.
      %
-:- pred clauses_info_add_pragma_foreign_proc(foreign_proc_origin::in,
-    purity::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in,
+:- pred clauses_info_add_pragma_foreign_proc(purity::in,
+    pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in,
      prog_varset::in, list(pragma_var)::in, list(mer_type)::in,
      pragma_foreign_code_impl::in, prog_context::in,
      pred_or_func::in, sym_name::in, arity::in, pred_markers::in,
      clauses_info::in, clauses_info::out, module_info::in, module_info::out,
      list(error_spec)::in, list(error_spec)::out) is det.

-clauses_info_add_pragma_foreign_proc(Origin, Purity, Attributes0,
+clauses_info_add_pragma_foreign_proc(Purity, Attributes0,
          PredId, ProcId, PVarSet, PVars, OrigArgTypes, PragmaImpl0,
          Context, PredOrFunc, PredName, Arity, Markers,
          !ClausesInfo, !ModuleInfo, !Specs) :-
@@ -3136,21 +3127,21 @@
          )
      ;
          AllProcIds = pred_info_all_procids(PredInfo),
-        clauses_info_do_add_pragma_foreign_proc(Origin, Purity, Attributes0,
+        clauses_info_do_add_pragma_foreign_proc(Purity, Attributes0,
              PredId, ProcId, AllProcIds, PVarSet, PVars, OrigArgTypes,
              PragmaImpl0, Context, PredOrFunc, PredName, Arity,
              Markers, !ClausesInfo, !ModuleInfo, !Specs)
      ).

-:- pred clauses_info_do_add_pragma_foreign_proc(foreign_proc_origin::in,
-    purity::in, pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in,
+:- pred clauses_info_do_add_pragma_foreign_proc(purity::in,
+    pragma_foreign_proc_attributes::in, pred_id::in, proc_id::in,
      list(proc_id)::in, prog_varset::in, list(pragma_var)::in,
      list(mer_type)::in, pragma_foreign_code_impl::in, prog_context::in,
      pred_or_func::in, sym_name::in, arity::in, pred_markers::in,
      clauses_info::in, clauses_info::out, module_info::in, module_info::out,
      list(error_spec)::in, list(error_spec)::out) is det.

-clauses_info_do_add_pragma_foreign_proc(Origin, Purity, Attributes0,
+clauses_info_do_add_pragma_foreign_proc(Purity, Attributes0,
          PredId, ProcId, AllProcIds, PVarSet, PVars, OrigArgTypes, PragmaImpl0,
          Context, PredOrFunc, PredName, Arity, Markers,
          !ClausesInfo, !ModuleInfo, !Specs) :-
@@ -3225,15 +3216,9 @@
          % Check that the purity of a predicate/function declaration agrees with
          % the (promised) purity of the foreign proc.  We do not perform this
          % check there is a promise_{pure,semipure} pragma for the
-        % predicate/function since in that case they will differ anyway.  We
-        % also do not perform this check if the foreign_proc was introduced as
-        % a result of a `:- pragma import' declaration since doing so results
-        % in spurious error messages about non-existent foreign_procs.  For
-        % that case we assume that the code that constructs the foreign_procs
-        % from the import pragmas sets the purity attributes correctly.
+        % predicate/function since in that case they will differ anyway.
          (
-            ( Origin = pragma_import_foreign_proc
-            ; check_marker(Markers, marker_promised_pure)
+            ( check_marker(Markers, marker_promised_pure)
              ; check_marker(Markers, marker_promised_semipure)
              )
          ->
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.514
diff -u -r1.514 mercury_compile.m
--- compiler/mercury_compile.m	23 May 2011 05:08:05 -0000	1.514
+++ compiler/mercury_compile.m	16 Jun 2011 06:49:25 -0000
@@ -1780,7 +1780,7 @@
                  % We don't invoke the assembler to produce an object file yet
                  % -- that is done at the top level.
                  %
-                % But if the module contained `pragma c_code', then we will
+                % But if the module contained C foreign code then we will
                  % have compiled that to a separate C file. We need to invoke
                  % the C compiler on that.
                  (
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.117
diff -u -r1.117 ml_elim_nested.m
--- compiler/ml_elim_nested.m	23 May 2011 05:08:06 -0000	1.117
+++ compiler/ml_elim_nested.m	16 Jun 2011 06:36:45 -0000
@@ -216,8 +216,8 @@
  %   But if Mercury code calls C code which calls back to Mercury code, and
  %   the C code uses pointers to the Mercury heap, then there could be
  %   serious problems (i.e. dangling pointers). Even if you just use `pragma
-%   foreign_export' to export a procedure and `pragma import' to import it
-%   back again, there may be trouble. The code generated for the exported
+%   foreign_export' to export a procedure and `pragma foreign_proc' to import
+%   it back again, there may be trouble. The code generated for the exported
  %   functions can include calls to MR_MAYBE_BOX_FOREIGN_TYPE, which may
  %   allocate heap; we ought to register the frame and call MR_GC_check()
  %   before each call to MR_MAYBE_BOX_FOREIGN_TYPE, but currently we don't.
Index: compiler/prog_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_data.m,v
retrieving revision 1.229
diff -u -r1.229 prog_data.m
--- compiler/prog_data.m	16 Jun 2011 06:42:15 -0000	1.229
+++ compiler/prog_data.m	16 Jun 2011 07:45:50 -0000
@@ -1144,7 +1144,7 @@
      ;       proc_may_not_duplicate.

      % This type specifies the termination property of a procedure
-    % defined using pragma c_code or pragma foreign_proc.
+    % defined using pragma foreign_proc.
      %
  :- type proc_terminates
      --->    proc_terminates
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.149
diff -u -r1.149 prog_io_pragma.m
--- compiler/prog_io_pragma.m	16 Jun 2011 06:42:15 -0000	1.149
+++ compiler/prog_io_pragma.m	16 Jun 2011 07:45:50 -0000
@@ -2225,7 +2225,7 @@
  parse_ordinary_despite_detism(
          term.functor(term.atom("ordinary_despite_detism"), [], _)).

-    % Parse a pragma foreign_code declaration.
+    % Parse a pragma foreign_proc declaration.
      %
  :- pred parse_pragma_foreign_code(module_name::in,
      pragma_foreign_proc_attributes::in, term::in, pragma_foreign_code_impl::in,
@@ -2233,7 +2233,7 @@

  parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm0,
          PragmaImpl, VarSet, Context, SeqNum, MaybeItem) :-
-    ContextPieces = [words("In"), quote(":- pragma c_code"),
+    ContextPieces = [words("In"), quote(":- pragma foreign_proc"),
          words("declaration:")],
      parse_pred_or_func_and_args_general(yes(ModuleName), PredAndVarsTerm0,
          VarSet, ContextPieces, MaybePredAndArgs),
@@ -2249,7 +2249,7 @@
              PredOrFunc = pf_predicate,
              VarList = VarList0
          ),
-        parse_pragma_c_code_varlist(VarSet, VarList, MaybePragmaVars),
+        parse_pragma_foreign_proc_varlist(VarSet, VarList, MaybePragmaVars),
          (
              MaybePragmaVars = ok1(PragmaVars),
              varset.coerce(VarSet, ProgVarSet),
@@ -2268,14 +2268,15 @@
          MaybeItem = error1(Specs)
      ).

-    % Parse the variable list in the pragma c code declaration.
+    % Parse the variable list in the pragma foreign_proc declaration.
      % The final argument is 'no' for no error, or 'yes(ErrorMessage)'.
      %
-:- pred parse_pragma_c_code_varlist(varset::in, list(term)::in,
+:- pred parse_pragma_foreign_proc_varlist(varset::in, list(term)::in,
      maybe1(list(pragma_var))::out) is det.

-parse_pragma_c_code_varlist(_, [], ok1([])).
-parse_pragma_c_code_varlist(VarSet, [HeadTerm | TailTerm], MaybePragmaVars):-
+parse_pragma_foreign_proc_varlist(_, [], ok1([])).
+parse_pragma_foreign_proc_varlist(VarSet, [HeadTerm | TailTerm],
+        MaybePragmaVars):-
      (
          HeadTerm = term.functor(term.atom("::"), [VarTerm, ModeTerm], _),
          VarTerm = term.variable(Var, VarContext)
@@ -2286,7 +2287,7 @@
                  term.coerce_var(Var, ProgVar),
                  HeadPragmaVar = pragma_var(ProgVar, VarName, Mode,
                      native_if_possible),
-                parse_pragma_c_code_varlist(VarSet, TailTerm,
+                parse_pragma_foreign_proc_varlist(VarSet, TailTerm,
                      MaybeTailPragmaVars),
                  (
                      MaybeTailPragmaVars = ok1(TailPragmaVars),
@@ -2296,7 +2297,9 @@
                      MaybePragmaVars = MaybeTailPragmaVars
                  )
              ;
-                Pieces = [words("Error: unknown mode in pragma c_code."), nl],
+                Pieces = [
+                    words("Error: unknown mode in pragma foreign_proc."), nl
+                ],
                  Spec = error_spec(severity_error, phase_term_to_parse_tree,
                      [simple_msg(get_term_context(ModeTerm),
                          [always(Pieces)])]),
@@ -2306,7 +2309,7 @@
              % If the variable wasn't in the varset it must be an
              % underscore variable.
              Pieces = [words("Sorry, not implemented: "),
-                words("anonymous `_' variable in pragma c_code."), nl],
+                words("anonymous `_' variable in pragma foreign_proc."), nl],
              Spec = error_spec(severity_error, phase_term_to_parse_tree,
                  [simple_msg(VarContext, [always(Pieces)])]),
              MaybePragmaVars = error1([Spec])
Index: compiler/var_locn.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/var_locn.m,v
retrieving revision 1.76
diff -u -r1.76 var_locn.m
--- compiler/var_locn.m	23 May 2011 05:08:15 -0000	1.76
+++ compiler/var_locn.m	16 Jun 2011 06:38:47 -0000
@@ -302,7 +302,8 @@
      % var_locn_clear_r1(ModuleInfo, Code, !VarLocnInfo):
      %
      % Produces a code fragment Code to move whatever is in r1 to some other
-    % register, if r1 is live. This is used prior to semidet pragma c_codes.
+    % register, if r1 is live. This is used prior to semidet pragma
+    % foreign_procs.
      %
  :- pred var_locn_clear_r1(module_info::in, llds_code::out,
      var_locn_info::in, var_locn_info::out) is det.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list