[m-rev.] diff: delete code previously required for pragma import
Julien Fischer
juliensf at csse.unimelb.edu.au
Thu Jun 16 15:12:19 AEST 2011
Branches: main
Delete some code previously required for `pragam import'.
compiler/foreign.m:
Delete some dead code.
compiler/mlds.m:
Fix a typo in my last change.
Delete the XXX regarding initialisers and finalisers
not working with non-C backends; they do work with
non-C backends.
Julien.
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.88
diff -u -r1.88 foreign.m
--- compiler/foreign.m 23 May 2011 05:08:02 -0000 1.88
+++ compiler/foreign.m 16 Jun 2011 04:55:04 -0000
@@ -325,86 +325,6 @@
make_pred_name_rest(lang_java, _SymName) = "some_java_name".
make_pred_name_rest(lang_erlang, _SymName) = "some_erlang_name".
- % handle_return_value(Contxt, DeclaredDetism, CodeModel, PredOrFunc, Args0,
- % M, Args, C_Code0):
- %
- % Figures out what to do with the C function's return value, based on
- % Mercury procedure's code model, whether it is a predicate or a function,
- % and (if it is a function) the type and mode of the function result.
- % Constructs a C code fragment `C_Code0' which is a string of the form
- % "<Something> =" that assigns the return value to the appropriate place,
- % if there is a return value, or is an empty string, if there is no return
- % value. Returns in Args all of Args0 that must be passed as arguments
- % (i.e. all of them, or all of them except the return value).
- %
- % Causes an error message to be emitted if the code_model is not compatible
- % with the use of pragma import (ie. it is model_non).
- %
-:- pred handle_return_value(prog_context::in, maybe(determinism)::in,
- code_model::in, pred_or_func::in,
- assoc_list(pragma_var, mer_type)::in,
- assoc_list(pragma_var, mer_type)::out,
- string::out, module_info::in, module_info::out,
- list(error_spec)::in, list(error_spec)::out) is det.
-
-handle_return_value(Context, MaybeDeclaredDetism, CodeModel, PredOrFunc,
- !Args, C_Code0, !ModuleInfo, !Specs) :-
- (
- CodeModel = model_det,
- (
- PredOrFunc = pf_function,
- pred_args_to_func_args(!Args, RetArg),
- RetArg = pragma_var(_, RetArgName, RetMode, _) - RetType,
- mode_to_arg_mode(!.ModuleInfo, RetMode, RetType, RetArgMode),
- RetArgMode = top_out,
- check_dummy_type(!.ModuleInfo, RetType) = is_not_dummy_type
- ->
- C_Code0 = RetArgName ++ " = "
- ;
- C_Code0 = ""
- )
- ;
- CodeModel = model_semi,
- % We treat semidet functions the same as semidet predicates, which
- % means that for Mercury functions the Mercury return value becomes
- % the last argument, and the C return value is a bool that is used to
- % indicate success or failure.
- C_Code0 = "SUCCESS_INDICATOR = "
- ;
- CodeModel = model_non,
- (
- MaybeDeclaredDetism = yes(DeclaredDetism),
- DetismStr = determinism_to_string(DeclaredDetism)
- ;
- MaybeDeclaredDetism = no,
- DetismStr = "multi or nondet"
- ),
- Pieces = [words("Error: `pragma_import' declaration for"),
- words("a procedure that has a determinism of"),
- fixed(DetismStr), suffix("."), nl],
- Msg = simple_msg(Context, [always(Pieces)]),
- Spec = error_spec(severity_error, phase_parse_tree_to_hlds, [Msg]),
- !:Specs = [Spec | !.Specs],
-
- % This is just a dummy - it will never actually be used.
- C_Code0 = "\n#error ""cannot import nondet procedure""\n"
- ),
- list.filter(include_import_arg(!.ModuleInfo), !Args).
-
- % include_import_arg(M, Arg):
- %
- % Succeeds iff Arg should be included in the arguments of the C function.
- % Fails if `Arg' has a type such as `io.state' that is just a dummy
- % argument that should not be passed to C.
- %
-:- pred include_import_arg(module_info::in, pair(pragma_var, mer_type)::in)
- is semidet.
-
-include_import_arg(ModuleInfo, pragma_var(_Var, _Name, Mode, _Box) - Type) :-
- mode_to_arg_mode(ModuleInfo, Mode, Type, ArgMode),
- ArgMode \= top_unused,
- check_dummy_type(ModuleInfo, Type) = is_not_dummy_type.
-
% create_pragma_vars(Vars, Modes, ArgNum0, PragmaVars):
%
% Given list of vars and modes, and an initial argument number, allocate
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.191
diff -u -r1.191 mlds.m
--- compiler/mlds.m 15 Jun 2011 17:30:09 -0000 1.191
+++ compiler/mlds.m 16 Jun 2011 05:00:02 -0000
@@ -364,7 +364,7 @@
mlds_name :: mercury_module_name,
% Code defined in some other language, e.g. for
- % `pragma foreign-decl', etc.
+ % `pragma foreign_decl', etc.
mlds_foreign_code_map :: map(foreign_language,
mlds_foreign_code),
@@ -380,11 +380,9 @@
mlds_defns :: list(mlds_defn),
% The names of init and final preds.
- % XXX These only work for the C backend because initialisers
- % and finalisers do not (yet) work for the other backends.
- % (These should possibly be moved into mlds_foreign_code_map.)
mlds_init_preds :: list(string),
mlds_final_preds :: list(string),
+
mlds_exported_enums :: list(mlds_exported_enum)
).
--------------------------------------------------------------------------
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