mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
Estimated hours taken: 2 Branches: main The runtime had two different conventions for naming types. One convention, used mostly in the debugger-related modules, added underscores between capitalized words; example: MR_Label_Layout. The other convention, used in most modules, used capitalized words without underscores (e.g. MR_TypeInfo). This diff standardizes on the second convention. It has no algorithmic changes, only renames of types. runtime/*.[ch]: trace/*.[ch]: compiler/*.m: library/*.m: mdbcomp/*.m: Effect the change described above. The only substantive change is that runtime/mercury_stack_layout.h used to define *two* types for trace levels: MR_TraceLevel and MR_Trace_Level, and this diff standardizes on just one (they had equivalent definitions). runtime/mercury_bootstrap.h: Add a #define from the old name to the new for all the changed type names that the installed compiler can put into .c files. We can delete these #defines some time after this diff has bootstrapped. slice/.mgnuc_opts: Restore the --no-mercury-stdlib-dir option, without which the slice directory won't compile after this change (because it looks for type names in the installed runtime header files, which define the old versions of type names).
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
/*
|
|
** vim:sw=4 ts=4 expandtab
|
|
*/
|
|
/*
|
|
** Copyright (C) 2005-2006 The University of Melbourne.
|
|
** This file may only be copied under the terms of the GNU Library General
|
|
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
*/
|
|
|
|
/*
|
|
** This file implements utility functions operating on the data structures
|
|
** defined in the corresponding header file.
|
|
**
|
|
** Author: Zoltan Somogyi
|
|
*/
|
|
|
|
#include "mercury_imp.h"
|
|
#include "mercury_stack_layout.h"
|
|
|
|
MR_ConstString
|
|
MR_hlds_var_name(const MR_ProcLayout *entry, int hlds_var_num)
|
|
{
|
|
const char *string_table;
|
|
MR_Integer string_table_size;
|
|
int offset;
|
|
|
|
string_table = entry->MR_sle_module_layout->MR_ml_string_table;
|
|
string_table_size = entry->MR_sle_module_layout->MR_ml_string_table_size;
|
|
|
|
if (hlds_var_num == 0) {
|
|
/* this value is not a variable */
|
|
return NULL;
|
|
}
|
|
|
|
if (hlds_var_num > entry->MR_sle_max_named_var_num) {
|
|
/* this value is a compiler-generated variable */
|
|
return NULL;
|
|
}
|
|
|
|
/* variable number 1 is stored at offset 0 */
|
|
offset = entry->MR_sle_used_var_names[hlds_var_num - 1];
|
|
if (offset > string_table_size) {
|
|
MR_fatal_error("MR_hlds_var_name: bounds error on string table");
|
|
}
|
|
|
|
return string_table + offset;
|
|
}
|
|
|
|
int
|
|
MR_find_start_of_num_suffix(const char *str)
|
|
{
|
|
int len;
|
|
const char *s;
|
|
|
|
len = strlen(str);
|
|
s = str + len - 1;
|
|
while (s > str && MR_isdigit(*s)) {
|
|
s--;
|
|
}
|
|
|
|
if (s == str + len - 1) {
|
|
return -1;
|
|
} else {
|
|
/* *(s+1) is the first character of the numerical suffix */
|
|
return (s + 1) - str;
|
|
}
|
|
}
|