runtime/mercury_float.c:
Fix a bug in MR_sprintf_float where it would convert 1.8e-10
into "1.80000000000000e-1" instead of "1.8e-10".
The problem was that it was stripping the zeros off the end of the string
produced by sprintf without considering the case where the output
was in scientific notation.
The fix is to remove the `#' from the sprintf format string and then to
append ".0" to the string if there is no "." or "e".
tests/general/float_roundtrip.m:
tests/general/float_roundtrip.exp:
Add regression test.
tests/hard_coded/deep_copy.exp:
tests/hard_coded/expand.exp:
tests/hard_coded/float_reg.exp:
tests/hard_coded/write.exp:
tests/hard_coded/write_binary.exp:
tests/hard_coded/write_reg1.exp:
tests/hard_coded/write_xml.exp:
Update the expected output of these tests as trailing zeros are now
also removed from the base part of scientific notation float strings.
Estimated hours taken: 0.5
Branches: main
runtime/*.c:
Convert all remaining C source files to four-space indentation.
Fix some deviations from our style guide.
Estimated hours taken: 0.5
Branches: main
Move implementation of is_nan and is_inf into the runtime.
This avoids problems with warnings about implicit declarations of
functions isnan and isinf when compiling with --ansi.
library/float.m:
runtime/mercury_float.c:
runtime/mercury_float.h:
Move the bodies of is_nan and is_inf into the runtime.
Estimated hours taken: 1
Branches: main
Fix a bug where we weren't outputting floats to enough precision when
deconstructing them.
runtime/mercury_ml_expand_body.h:
Use MR_sprintf_float to determine the representation of the
deconstructed float.
library/string.m:
library/io.m:
runtime/mercury_float.c:
runtime/mercury_float.h:
Move ML_sprintf_float to mercury_float.h.
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
Adapt the test case to test floats which require 17 digits of
precision.
Estimated hours taken: 10
Make everything in the runtime use MR_ prefixes, and make the compiler
bootstrap with -DMR_NO_BACKWARDS_COMPAT.
runtime/mercury_*.[ch]
Add MR_ prefixes to all functions, global variables and almost all
macros that could pollute the namespace. The (intentional) exceptions
are
1. some function, variable, type and label names that already start
with MR_, mercury_, Mercury or _entry;
2. some standard C macros in mercury_std.h;
3. the macros used in autoconfiguration (since they are used in scripts
as well as the runtime, the MR_ prefix may not be appropriate for
those).
In some cases, I deleted things instead of adding prefixes
if the "things" were obsolete and not user visible.
runtime/mercury_bootstrap.h:
Provide MR_-less forms of the macros for bootstrapping and for
backward compatibility for user code.
runtime/mercury_debug.[ch]:
Add a FILE * parameter to a function that needs it.
compiler/code_info.m:
compiler/export.m:
compiler/fact_table.m:
compiler/llds.m:
compiler/llds_out.m:
compiler/pragma_c_gen.m:
compiler/trace.m:
Add MR_ prefixes to the C code generated by the compiler.
library/*.m:
Add MR_ prefixes to handwritten code.
trace/mercury_trace_*.c:
util/mkinit.c:
Add MR_ prefixes as necessary.
extras/concurrency/semaphore.m:
Add MR_ prefixes as necessary.
Estimated hours taken: 4
Add MR_ prefixes to the types used when generating C code.
This means types such as Word, String, Bool, Float become MR_Word,
MR_String, MR_Bool, MR_Float. Also define MR_Box for both the LLDS and
MLDS backends so we can use it uniformly.
This is very important in environments where String or Bool have already
been used as system types (for example, managed C++). And besides, we
should do it anyway as part of the grand namespace cleanup.
I have fixed all of the uses of the non-prefixed types in the runtime
and trace directories. I haven't done it for the library and compiler
directories yet (no promises that I will do it in future either). But
if you see a non-prefixed type in code from now on, please consider it a
bug and fix it.
mercury_bootstrap.h contains #defines to map the non-prefixed types into
the prefixed ones. Like many of the other namespace cleaning backwards
compatibility macros, this can be turned off with
MR_NO_BACKWARDS_COMPAT.
This shouldn't break any code, but this kind of change affects so many
things that of course there could be problems lurking in there somewhere.
If you start getting errors from the C compiler after this change is
installed, you will want to make sure you at least have the runtime
system updated so that you are getting the backwards compatibility
definitions in mercury_bootstrap.h. Then if you continue to have
problems you can bug me about it.
compiler/export.m:
compiler/llds_out.m:
compiler/mlds_to_c.m:
Use MR_Word, MR_Float, MR_Bool, etc when generating C.
doc/reference_manual.texi:
Update the reference manual to talk about MR_Word, MR_String,
MR_Char, etc.
runtime/mercury_bootstrap.h:
Add bootstrapping typedefs.
runtime/*:
trace/*:
Change Word, Float, Bool, Code, String, etc to
MR_Word, MR_Float, MR_Bool, MR_Code, MR_String.
Estimated hours taken: 1
runtime/*.h:
runtime/*.c:
runtime/mercury_conf.h.in:
Remove old .h files.
Update #includes to refer to mercury_*.h
Update #ifdef MODULE_H to be #ifdef MERCURY_MODULE_H
Estimated hours taken: 4
Add new predicate `float__hash' to the standard library for computing a
non-negative integer hash value for a float.
Add a C function to the runtime to do the actual hashing. This
function is in the runtime so that it can be called from both
the library and from C code generated for `pragma fact_table'
indexing.
library/float.m
Add a new predicate `float__hash' that calls the runtime
function `hash_float()'.
runtime/mercury_float.h
Add a declaration for `hash_float()'.
runtime/mercury_float.c
Add new file mercury_float.c for runtime code related to
floats.
Add a new function `hash_float()' for hashing floats.