[m-rev.] for review: reimplement source package name change
Peter Ross
peter.ross at miscrit.be
Thu Jun 21 20:22:16 AEST 2001
Hi,
===================================================================
Estimated hours taken: 4
Branches: main
The .NET backend requires that names are not only qualified with their
namespace but the source package the name comes from. In this change we
back out a previous solution to this problem and implement a much
neater solution where we hide the package name in the abstract type
mlds_module_name.
This solution is neater because the package name shouldn't change once
the name is defined. All that we may have to change is the qualifiers
to the name.
compiler/mlds.m:
Add the package name to the abstract type mlds_module_name.
compiler/ml_call_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_csharp.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_mcpp.m:
compiler/rtti_to_mlds.m:
Back out previous solution.
Index: compiler/ml_call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_call_gen.m,v
retrieving revision 1.23
diff -u -r1.23 ml_call_gen.m
--- compiler/ml_call_gen.m 2001/06/08 09:13:29 1.23
+++ compiler/ml_call_gen.m 2001/06/21 10:11:54
@@ -556,8 +556,7 @@
PredLabel, PredModule) },
{ Params = ml_gen_proc_params(ModuleInfo, PredId, ProcId) },
{ Signature = mlds__get_func_signature(Params) },
- { QualifiedProcLabel = qual(PredModule,
- PredModule, PredLabel - ProcId) },
+ { QualifiedProcLabel = qual(PredModule, PredLabel - ProcId) },
{ CodeAddrRval = const(code_addr_const(proc(QualifiedProcLabel,
Signature))) }.
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.88
diff -u -r1.88 ml_code_gen.m
--- compiler/ml_code_gen.m 2001/06/08 09:13:30 1.88
+++ compiler/ml_code_gen.m 2001/06/21 10:11:55
@@ -852,8 +852,7 @@
MLDS_Name, MLDS_ModuleName),
MLDS_FuncParams = ml_gen_proc_params(ModuleInfo, PredId, ProcId),
MLDS_Context = mlds__make_context(ProgContext),
- ML_Defn = ml_pragma_export(C_Name,
- qual(MLDS_ModuleName, MLDS_ModuleName, MLDS_Name),
+ ML_Defn = ml_pragma_export(C_Name, qual(MLDS_ModuleName, MLDS_Name),
MLDS_FuncParams, MLDS_Context).
@@ -2495,7 +2494,7 @@
{ ml_gen_proc_label(ModuleInfo, PredId, ProcId, MLDS_Name,
MLDS_Module) },
{ HashDefine = [raw_target_code("#define MR_PROC_LABEL "),
- name(qual(MLDS_Module, MLDS_Module, MLDS_Name)),
+ name(qual(MLDS_Module, MLDS_Name)),
raw_target_code("\n")] }.
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.37
diff -u -r1.37 ml_code_util.m
--- compiler/ml_code_util.m 2001/06/08 09:13:33 1.37
+++ compiler/ml_code_util.m 2001/06/21 10:11:56
@@ -1199,7 +1199,7 @@
),
Signature = mlds__func_signature(ArgTypes, [])
},
- { ProcLabel = qual(PredModule, PredModule, PredLabel - ProcId) },
+ { ProcLabel = qual(PredModule, PredLabel - ProcId) },
{ FuncLabelRval = const(code_addr_const(internal(ProcLabel,
FuncLabel, Signature))) }.
@@ -1342,8 +1342,8 @@
{ mercury_private_builtin_module(PrivateBuiltin) },
{ MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin) },
ml_gen_type(Type, MLDS_Type),
- { Lval = var(qual(MLDS_Module, MLDS_Module,
- var_name("dummy_var", no)), MLDS_Type) }
+ { Lval = var(qual(MLDS_Module, var_name("dummy_var", no)),
+ MLDS_Type) }
;
=(MLDSGenInfo),
{ ml_gen_info_get_varset(MLDSGenInfo, VarSet) },
@@ -1409,8 +1409,7 @@
=(MLDSGenInfo),
{ ml_gen_info_get_module_name(MLDSGenInfo, ModuleName) },
{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
- { QualifiedVarLval = var(
- qual(MLDS_Module, MLDS_Module, VarName), VarType) }.
+ { QualifiedVarLval = var(qual(MLDS_Module, VarName), VarType) }.
% Generate a declaration for an MLDS variable, given its HLDS type.
%
@@ -1732,7 +1731,7 @@
{ InnerFuncParams0 = func_params(InnerArgs0, Rets) },
{ InnerArgRvals = list__map(
(func(Data - Type)
- = lval(var(qual(MLDS_Module, MLDS_Module, VarName), Type)) :-
+ = lval(var(qual(MLDS_Module, VarName), Type)) :-
( Data = data(var(VarName0)) ->
VarName = VarName0
;
@@ -1742,8 +1741,7 @@
InnerArgs0) },
{ InnerFuncArgType = mlds__cont_type(ArgTypes0) },
{ PassedContVarName = mlds__var_name("passed_cont", no) },
- { InnerFuncRval = lval(var(
- qual(MLDS_Module, MLDS_Module, PassedContVarName),
+ { InnerFuncRval = lval(var(qual(MLDS_Module, PassedContVarName),
InnerFuncArgType)) },
{ InnerFuncParams = func_params(
[data(var(PassedContVarName)) - InnerFuncArgType | InnerArgs0],
@@ -1765,8 +1763,7 @@
yes(SeqNum), _), _, _, function(_, _, yes(_)))
->
% We call the proxy function.
- QualProcLabel = qual(MLDS_Module, MLDS_Module,
- PredLabel - ProcId),
+ QualProcLabel = qual(MLDS_Module, PredLabel - ProcId),
ProxyFuncRval = const(code_addr_const(
internal(QualProcLabel, SeqNum, ProxySignature))),
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.26
diff -u -r1.26 ml_elim_nested.m
--- compiler/ml_elim_nested.m 2001/06/08 09:13:34 1.26
+++ compiler/ml_elim_nested.m 2001/06/21 10:11:56
@@ -324,14 +324,13 @@
% struct:
% env_ptr->foo = foo;
%
- QualVarName = qual(ModuleName, ModuleName, VarName),
+ QualVarName = qual(ModuleName, VarName),
EnvModuleName = ml_env_module_name(ClassType),
FieldNameString = ml_var_name_to_string(VarName),
- FieldName = named_field(
- qual(EnvModuleName, EnvModuleName, FieldNameString),
+ FieldName = named_field(qual(EnvModuleName, FieldNameString),
EnvPtrTypeName),
Tag = yes(0),
- EnvPtr = lval(var(qual(ModuleName, ModuleName,
+ EnvPtr = lval(var(qual(ModuleName,
mlds__var_name("env_ptr", no)),
EnvPtrTypeName)),
EnvArgLval = field(Tag, EnvPtr, FieldName, FieldType,
@@ -374,7 +373,7 @@
% };
%
EnvTypeKind = mlds__struct,
- EnvTypeName = class_type(qual(ModuleName, ModuleName, EnvClassName), 0,
+ EnvTypeName = class_type(qual(ModuleName, EnvClassName), 0,
EnvTypeKind),
EnvTypeEntityName = type(EnvClassName, 0),
EnvTypeFlags = env_type_decl_flags,
@@ -399,7 +398,7 @@
% declare the `env_ptr' var, and
% initialize the `env_ptr' with the address of `env'
%
- EnvVar = qual(ModuleName, ModuleName, mlds__var_name("env", no)),
+ EnvVar = qual(ModuleName, mlds__var_name("env", no)),
globals__get_target(Globals, Target),
% IL uses classes instead of structs, so the code
% generated needs to be a little different.
@@ -467,10 +466,10 @@
Defn0 = mlds__defn(Name, Context, Flags, DefnBody0),
(
DefnBody0 = mlds__function(PredProcId, Params, yes(FuncBody0)),
- statement_contains_var(FuncBody0, qual(ModuleName, ModuleName,
+ statement_contains_var(FuncBody0, qual(ModuleName,
mlds__var_name("env_ptr", no)))
->
- EnvPtrVal = lval(var(qual(ModuleName, ModuleName,
+ EnvPtrVal = lval(var(qual(ModuleName,
mlds__var_name("env_ptr_arg", no)),
mlds__generic_env_ptr_type)),
ml_init_env(TypeName, EnvPtrVal, Context, ModuleName, Globals,
@@ -525,7 +524,7 @@
%
%
- EnvPtrVar = qual(ModuleName, ModuleName, mlds__var_name("env_ptr", no)),
+ EnvPtrVar = qual(ModuleName, mlds__var_name("env_ptr", no)),
AssignEnvPtr = assign(var(EnvPtrVar, EnvPtrVarType),
unop(cast(EnvPtrVarType), EnvPtrVal)),
InitEnvPtr = mlds__statement(atomic(AssignEnvPtr), Context).
@@ -875,7 +874,7 @@
ml_should_add_local_data(ModuleName, VarName,
FollowingDefns, FollowingStatements) :-
- QualVarName = qual(ModuleName, ModuleName, VarName),
+ QualVarName = qual(ModuleName, VarName),
(
list__member(FollowingDefn, FollowingDefns)
;
@@ -961,8 +960,7 @@
fixup_target_code_component(target_code_output(Lval0),
target_code_output(Lval)) -->
fixup_lval(Lval0, Lval).
-fixup_target_code_component(name(Name `with_type` mlds__qualified_entity_name),
- name(Name)) --> [].
+fixup_target_code_component(name(Name), name(Name)) --> [].
:- pred fixup_trail_op(trail_op, trail_op, elim_info, elim_info).
:- mode fixup_trail_op(in, out, in, out) is det.
@@ -1041,7 +1039,7 @@
:- mode fixup_var(in, in, out, in, out) is det.
fixup_var(ThisVar, ThisVarType, Lval, ElimInfo, ElimInfo) :-
- ThisVar = qual(_ThisVarPackageName, ThisVarModuleName, ThisVarName),
+ ThisVar = qual(ThisVarModuleName, ThisVarName),
ModuleName = elim_info_get_module_name(ElimInfo),
Locals = elim_info_get_local_data(ElimInfo),
ClassType = elim_info_get_env_type_name(ElimInfo),
@@ -1061,13 +1059,12 @@
),
solutions(IsLocalVar, [FieldType])
->
- EnvPtr = lval(var(qual(ModuleName, ModuleName,
+ EnvPtr = lval(var(qual(ModuleName,
mlds__var_name("env_ptr", no)),
EnvPtrVarType)),
EnvModuleName = ml_env_module_name(ClassType),
ThisVarFieldName = ml_var_name_to_string(ThisVarName),
- FieldName = named_field(
- qual(EnvModuleName, EnvModuleName, ThisVarFieldName),
+ FieldName = named_field(qual(EnvModuleName, ThisVarFieldName),
EnvPtrVarType),
Tag = yes(0),
Lval = field(Tag, EnvPtr, FieldName, FieldType, ClassType)
@@ -1150,11 +1147,7 @@
:- func ml_env_module_name(mlds__type) = mlds_module_name.
ml_env_module_name(ClassType) = EnvModuleName :-
- (
- ClassType = class_type(
- qual(_ClassPackage, ClassModule, ClassName),
- Arity, _Kind)
- ->
+ ( ClassType = class_type(qual(ClassModule, ClassName), Arity, _Kind) ->
EnvModuleName = mlds__append_class_qualifier(ClassModule,
ClassName, Arity)
;
@@ -1472,8 +1465,8 @@
target_code_component_contains_var(target_code_output(Lval), Name) :-
lval_contains_var(Lval, Name).
target_code_component_contains_var(name(EntityName), VarName) :-
- EntityName = qual(PackageName, ModuleName, data(var(UnqualVarName))),
- VarName = qual(PackageName, ModuleName, UnqualVarName).
+ EntityName = qual(ModuleName, data(var(UnqualVarName))),
+ VarName = qual(ModuleName, UnqualVarName).
%-----------------------------------------------------------------------------%
Index: compiler/ml_optimize.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_optimize.m,v
retrieving revision 1.9
diff -u -r1.9 ml_optimize.m
--- compiler/ml_optimize.m 2001/06/08 09:13:35 1.9
+++ compiler/ml_optimize.m 2001/06/21 10:11:57
@@ -192,8 +192,7 @@
(
Stmt0 = call(_Signature, _FuncRval, _MaybeObject, CallArgs,
_Results, _IsTailCall),
- ModuleName = OptInfo ^ module_name,
- can_optimize_tailcall(qual(ModuleName, ModuleName,
+ can_optimize_tailcall(qual(OptInfo ^ module_name,
OptInfo ^ entity_name), Stmt0)
->
CommentStatement = statement(
@@ -239,8 +238,7 @@
%
Name = data(var(VarName))
->
- QualVarName = qual(OptInfo ^ module_name,
- OptInfo ^ module_name, VarName),
+ QualVarName = qual(OptInfo ^ module_name, VarName),
(
%
% don't bother assigning a variable to itself
@@ -270,7 +268,7 @@
TempName = mlds__var_name(VarNameStr ++ "__tmp_copy",
MaybeNum),
QualTempName = qual(OptInfo ^ module_name,
- OptInfo ^ module_name, TempName),
+ TempName),
Initializer = init_obj(Arg),
TempDefn = ml_gen_mlds_var_decl(var(TempName),
Type, Initializer, OptInfo ^ context),
@@ -309,9 +307,8 @@
(
stmt_contains_statement(Stmt0, Call),
Call = mlds__statement(CallStmt, _),
- ModuleName = OptInfo ^ module_name,
can_optimize_tailcall(
- qual(ModuleName, ModuleName, OptInfo ^ entity_name),
+ qual(OptInfo ^ module_name, OptInfo ^ entity_name),
CallStmt)
->
Comment = atomic(comment("tailcall optimized into a loop")),
@@ -426,9 +423,8 @@
Statements0 = [AssignStatement | Statements1],
AssignStatement = statement(atomic(assign(LHS, RHS)), _),
LHS = var(ThisVar, _ThisType),
- ThisVar = qual(PackageName, Qualifier, VarName),
+ ThisVar = qual(Qualifier, VarName),
Qualifier = OptInfo ^ module_name,
- PackageName = OptInfo ^ module_name,
list__takewhile(isnt(var_defn(VarName)), Defns0,
_PrecedingDefns, [_VarDefn | FollowingDefns]),
@@ -443,8 +439,7 @@
list__member(OtherDefn, FollowingDefns),
OtherDefn = mlds__defn(data(var(OtherVarName)),
_, _, data(_Type, OtherInitializer)),
- ( rval_contains_var(RHS,
- qual(PackageName, Qualifier, OtherVarName))
+ ( rval_contains_var(RHS, qual(Qualifier, OtherVarName))
; initializer_contains_var(OtherInitializer, ThisVar)
)
)
Index: compiler/ml_tailcall.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_tailcall.m,v
retrieving revision 1.7
diff -u -r1.7 ml_tailcall.m
--- compiler/ml_tailcall.m 2001/06/08 09:13:36 1.7
+++ compiler/ml_tailcall.m 2001/06/21 10:11:57
@@ -454,8 +454,7 @@
; Const = data_addr_const(DataAddr) ->
DataAddr = data_addr(ModuleName, DataName),
( DataName = var(VarName) ->
- \+ var_is_local(
- qual(ModuleName, ModuleName, VarName), Locals)
+ \+ var_is_local(qual(ModuleName, VarName), Locals)
;
true
)
@@ -480,7 +479,7 @@
var_is_local(Var, Locals) :-
% XXX we ignore the ModuleName --
% that is safe, but overly conservative
- Var = qual(_PackageName, _ModuleName, VarName),
+ Var = qual(_ModuleName, VarName),
some [Local] (
locals_member(Local, Locals),
Local = data(var(VarName))
@@ -504,7 +503,7 @@
),
% XXX we ignore the ModuleName --
% that is safe, but might be overly conservative
- QualifiedProcLabel = qual(_PackageName, _ModuleName, ProcLabel),
+ QualifiedProcLabel = qual(_ModuleName, ProcLabel),
ProcLabel = PredLabel - ProcId,
some [Local] (
locals_member(Local, Locals),
Index: compiler/ml_type_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_type_gen.m,v
retrieving revision 1.8
diff -u -r1.8 ml_type_gen.m
--- compiler/ml_type_gen.m 2001/06/08 09:13:36 1.8
+++ compiler/ml_type_gen.m 2001/06/21 10:11:57
@@ -137,7 +137,7 @@
MLDS_Context = mlds__make_context(Context),
% generate the class name
- ml_gen_type_name(TypeId, qual(_, _, MLDS_ClassName), MLDS_ClassArity),
+ ml_gen_type_name(TypeId, qual(_, MLDS_ClassName), MLDS_ClassArity),
% generate the class members
ValueMember = ml_gen_enum_value_member(Context),
@@ -270,8 +270,7 @@
ml_gen_type_name(TypeId, QualBaseClassName, BaseClassArity),
BaseClassId = mlds__class_type(QualBaseClassName, BaseClassArity,
mlds__class),
- QualBaseClassName = qual(_BaseClassPackageName,
- BaseClassModuleName, BaseClassName),
+ QualBaseClassName = qual(BaseClassModuleName, BaseClassName),
BaseClassQualifier = mlds__append_class_qualifier(
BaseClassModuleName, BaseClassName, BaseClassArity),
@@ -412,8 +411,7 @@
% Note: the secondary tag class is nested inside the
% base class for this type.
UnqualClassName = "tag_type",
- ClassName = qual(BaseClassQualifier,
- BaseClassQualifier, UnqualClassName),
+ ClassName = qual(BaseClassQualifier, UnqualClassName),
ClassArity = 0,
SecondaryTagClassId = mlds__class_type(ClassName, ClassArity,
mlds__class),
@@ -566,8 +564,7 @@
% Miscellaneous helper routines.
%
-ml_gen_type_name(Name - Arity,
- qual(MLDS_Module, MLDS_Module, TypeName), Arity) :-
+ml_gen_type_name(Name - Arity, qual(MLDS_Module, TypeName), Arity) :-
(
Name = qualified(ModuleName, TypeName)
;
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.35
diff -u -r1.35 ml_unify_gen.m
--- compiler/ml_unify_gen.m 2001/06/08 09:13:36 1.35
+++ compiler/ml_unify_gen.m 2001/06/21 10:11:57
@@ -446,7 +446,6 @@
{ MLDS_PrivateBuiltinModule = mercury_module_name_to_mlds(
PrivateBuiltinModule) },
{ ClosureLayoutType = mlds__class_type(qual(MLDS_PrivateBuiltinModule,
- MLDS_PrivateBuiltinModule,
"closure_layout"), 0, mlds__class) },
{ ClosureLayoutRval = const(null(ClosureLayoutType)) },
@@ -476,8 +475,7 @@
%
{ Tag = 0 },
{ CtorDefn = ctor_id("<closure>", 0) },
- { QualifiedCtorId = qual(MLDS_PrivateBuiltinModule,
- MLDS_PrivateBuiltinModule, CtorDefn) },
+ { QualifiedCtorId = qual(MLDS_PrivateBuiltinModule, CtorDefn) },
%
% put all the extra arguments of the closure together
@@ -1247,7 +1245,7 @@
{ ConsId = ctor_id(ConsName, 0) },
{ ModuleName = mercury_module_name_to_mlds(unqualified("")) }
),
- { QualifiedConsId = qual(ModuleName, ModuleName, ConsId) }.
+ { QualifiedConsId = qual(ModuleName, ConsId) }.
:- pred ml_gen_cons_args(list(mlds__lval), list(prog_type),
list(uni_mode), module_info, list(mlds__rval)).
@@ -1821,16 +1819,15 @@
type_to_type_id(Type, TypeId, _)
->
ml_gen_type_name(TypeId,
- qual(_Package, MLDS_Module, TypeName), TypeArity),
+ qual(MLDS_Module, TypeName), TypeArity),
ClassQualifier = mlds__append_class_qualifier(
MLDS_Module, TypeName, TypeArity),
- QualClassName = qual(ClassQualifier, ClassQualifier, ClassName),
+ QualClassName = qual(ClassQualifier, ClassName),
ClassPtrType = mlds__ptr_type(mlds__class_type(
QualClassName, ClassArity, mlds__class)),
FieldQualifier = mlds__append_class_qualifier(
ClassQualifier, ClassName, ClassArity),
- QualifiedFieldName = qual(FieldQualifier,
- FieldQualifier, FieldName),
+ QualifiedFieldName = qual(FieldQualifier, FieldName),
FieldId = named_field(QualifiedFieldName, ClassPtrType)
;
error("ml_gen_field_id: invalid type")
Index: compiler/ml_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_util.m,v
retrieving revision 1.10
diff -u -r1.10 ml_util.m
--- compiler/ml_util.m 2001/06/08 09:13:37 1.10
+++ compiler/ml_util.m 2001/06/21 10:11:58
@@ -165,9 +165,9 @@
CodeAddr = internal(QualifiedProcLabel, SeqNum, _Sig),
MaybeSeqNum = yes(SeqNum)
),
- QualifiedProcLabel = qual(PackageName, ModuleName, PredLabel - ProcId),
+ QualifiedProcLabel = qual(ModuleName, PredLabel - ProcId),
% check that the module name matches
- Name = qual(PackageName, ModuleName, FuncName),
+ Name = qual(ModuleName, FuncName),
% check that the PredLabel, ProcId, and MaybeSeqNum match
FuncName = function(PredLabel, ProcId, MaybeSeqNum, _),
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.54
diff -u -r1.54 mlds.m
--- compiler/mlds.m 2001/06/08 09:13:38 1.54
+++ compiler/mlds.m 2001/06/21 10:11:58
@@ -327,12 +327,16 @@
% Given the name of a Mercury module, return the name of the corresponding
% MLDS package.
-:- func mercury_module_name_to_mlds(mercury_module_name) = mlds__package_name.
+:- func mercury_module_name_to_mlds(mercury_module_name) = mlds_module_name.
-% Given the name of a Mercury module, return the name of the corresponding
-% MLDS package.
+% Given the name of a Mercury module which qualifies a name, return the
+% qualification part of the name.
:- func mlds_module_name_to_sym_name(mlds__package_name) = sym_name.
+% Give the name of a Mercury module, return the name of the corresponding
+% MLDS package.
+:- func mlds_module_name_to_package_name(mlds_module_name) = sym_name.
+
% Given an MLDS module name (e.g. `foo.bar'), append another class qualifier
% (e.g. for a class `baz'), and return the result (e.g. `foo.bar.baz').
% The `arity' argument specifies the arity of the class.
@@ -360,18 +364,7 @@
% in identifiers, then it is the responsibility of the target language
% generator to mangle these names accordingly.
:- type mlds__fully_qualified_name(T)
- ---> qual(
- % Package which contains this name.
- % ie mscorlib
- package :: mlds__package_name,
-
- % Qualifers for this name.
- % ie 'System'
- qualifiers :: mlds_module_name,
-
- % The name ie 'Object'
- name :: T
- ).
+ ---> qual(mlds_module_name, T).
:- type mlds__qualified_entity_name
== mlds__fully_qualified_name(mlds__entity_name).
@@ -1448,9 +1441,14 @@
% e.g. `mercury.builtin', `mercury.io', `mercury.std_util', etc.,
% when mapped to MLDS package names.
-:- type mlds_module_name == prog_data__module_name.
+% :- type mlds_module_name == prog_data__module_name.
+:- type mlds_module_name
+ ---> name(
+ package_name :: prog_data__module_name,
+ module_name :: prog_data__module_name
+ ).
-mercury_module_name_to_mlds(MercuryModule) = MLDS_Package :-
+mercury_module_name_to_mlds(MercuryModule) = name(MLDS_Package, MLDS_Package) :-
(
MercuryModule = unqualified(ModuleName),
mercury_std_library_module(ModuleName)
@@ -1459,11 +1457,13 @@
;
MLDS_Package = MercuryModule
).
+
+mlds_module_name_to_sym_name(Module) = Module ^ module_name.
-mlds_module_name_to_sym_name(MLDS_Package) = MLDS_Package.
+mlds_module_name_to_package_name(Module) = Module ^ package_name.
-mlds__append_class_qualifier(Package, ClassName, ClassArity) =
- qualified(Package, ClassQualifier) :-
+mlds__append_class_qualifier(name(Package, Module), ClassName, ClassArity) =
+ name(Package, qualified(Module, ClassQualifier)) :-
string__format("%s_%d", [s(ClassName), i(ClassArity)],
ClassQualifier).
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.87
diff -u -r1.87 mlds_to_c.m
--- compiler/mlds_to_c.m 2001/06/08 09:13:38 1.87
+++ compiler/mlds_to_c.m 2001/06/21 10:11:59
@@ -458,8 +458,7 @@
mlds_output_calls_to_init_entry(ModuleName, [FuncDefn | FuncDefns]) -->
{ FuncDefn = mlds__defn(EntityName, _, _, _) },
io__write_string("\tMR_init_entry("),
- mlds_output_fully_qualified_name(
- qual(ModuleName, ModuleName, EntityName)),
+ mlds_output_fully_qualified_name(qual(ModuleName, EntityName)),
io__write_string(");\n"),
mlds_output_calls_to_init_entry(ModuleName, FuncDefns).
@@ -474,8 +473,7 @@
[TypeCtorInfoDefn | TypeCtorInfoDefns]) -->
{ TypeCtorInfoDefn = mlds__defn(EntityName, _, _, _) },
io__write_string("\tMR_register_type_ctor_info(&"),
- mlds_output_fully_qualified_name(
- qual(ModuleName, ModuleName, EntityName)),
+ mlds_output_fully_qualified_name(qual(ModuleName, EntityName)),
io__write_string(");\n"),
mlds_output_calls_to_register_tci(ModuleName, TypeCtorInfoDefns).
@@ -572,7 +570,7 @@
mlds_output_pragma_export_func_name(ModuleName, Indent,
ml_pragma_export(C_name, _MLDS_Name, Signature, Context)) -->
- { Name = qual(ModuleName, ModuleName, export(C_name)) },
+ { Name = qual(ModuleName, export(C_name)) },
mlds_indent(Context, Indent),
% For functions exported using `pragma export',
% we use the default C calling convention.
@@ -678,7 +676,7 @@
mlds_output_name_with_cast(ModuleName, Name - Type) -->
mlds_output_cast(Type),
- mlds_output_fully_qualified_name(qual(ModuleName, ModuleName, Name)).
+ mlds_output_fully_qualified_name(qual(ModuleName, Name)).
%
% Generates the signature for det functions in the forward mode.
@@ -791,8 +789,8 @@
%
mlds_indent(Context, Indent),
mlds_output_decl_flags(Flags, forward_decl, Name, DefnBody),
- mlds_output_decl_body(Indent,
- qual(ModuleName, ModuleName, Name), Context, DefnBody)
+ mlds_output_decl_body(Indent, qual(ModuleName, Name), Context,
+ DefnBody)
).
:- pred mlds_output_type_forward_decls(indent, list(mlds__type),
@@ -871,8 +869,8 @@
),
mlds_indent(Context, Indent),
mlds_output_decl_flags(Flags, definition, Name, DefnBody),
- mlds_output_defn_body(Indent, qual(ModuleName, ModuleName, Name),
- Context, DefnBody).
+ mlds_output_defn_body(Indent, qual(ModuleName, Name), Context,
+ DefnBody).
:- pred mlds_output_decl_body(indent, mlds__qualified_entity_name,
mlds__context, mlds__entity_defn, io__state, io__state).
@@ -945,7 +943,7 @@
% of discriminated union types.)
% Here we compute the appropriate qualifier.
%
- { Name = qual(_PackageName, ModuleName, UnqualName) },
+ { Name = qual(ModuleName, UnqualName) },
{ UnqualName = type(ClassName, ClassArity) ->
ClassModuleName = mlds__append_class_qualifier(ModuleName,
ClassName, ClassArity)
@@ -1061,8 +1059,7 @@
{ DefnBody = data(Type, Initializer) }
->
mlds_indent(Context, Indent),
- mlds_output_fully_qualified_name(
- qual(EnumModuleName, EnumModuleName, Name)),
+ mlds_output_fully_qualified_name(qual(EnumModuleName, Name)),
mlds_output_initializer(Type, Initializer)
;
{ error("mlds_output_enum_constant: constant is not data") }
@@ -1237,7 +1234,7 @@
io__write_char(' '),
io__write_string(CallingConvention),
mlds_output_fully_qualified_name(QualifiedName),
- { QualifiedName = qual(_, ModuleName, _) },
+ { QualifiedName = qual(ModuleName, _) },
mlds_output_params(OutputPrefix, OutputSuffix,
Indent, ModuleName, Context, Parameters),
( { RetTypes = [RetType2] } ->
@@ -1276,7 +1273,7 @@
ModuleName, Context, Name - Type) -->
mlds_indent(Context, Indent),
mlds_output_data_decl_ho(OutputPrefix, OutputSuffix,
- qual(ModuleName, ModuleName, Name), Type).
+ qual(ModuleName, Name), Type).
:- pred mlds_output_func_type_prefix(func_params, io__state, io__state).
:- mode mlds_output_func_type_prefix(in, di, uo) is det.
@@ -1332,7 +1329,7 @@
:- mode mlds_output_fully_qualified_name(in, di, uo) is det.
mlds_output_fully_qualified_name(QualifiedName) -->
- { QualifiedName = qual(_Package, _ModuleName, Name) },
+ { QualifiedName = qual(_ModuleName, Name) },
(
(
%
@@ -1371,7 +1368,7 @@
%
% don't module-qualify main/2
%
- { QualifiedName = qual(_Package, _ModuleName, Name) },
+ { QualifiedName = qual(_ModuleName, Name) },
{ Name = PredLabel - _ProcId },
{ PredLabel = pred(predicate, no, "main", 2, model_det, no) }
->
@@ -1386,7 +1383,7 @@
:- mode mlds_output_fully_qualified(in, pred(in, di, uo) is det,
di, uo) is det.
-mlds_output_fully_qualified(qual(_Package, ModuleName, Name), OutputFunc) -->
+mlds_output_fully_qualified(qual(ModuleName, Name), OutputFunc) -->
{ SymName = mlds_module_name_to_sym_name(ModuleName) },
{ llds_out__sym_name_mangle(SymName, MangledModuleName) },
io__write_string(MangledModuleName),
@@ -1869,7 +1866,7 @@
io__write_string("{\n"),
( { Defns \= [] } ->
{ FuncInfo = func_info(FuncName, _) },
- { FuncName = qual(_, ModuleName, _) },
+ { FuncName = qual(ModuleName, _) },
mlds_output_defns(Indent + 1, ModuleName, Defns),
io__write_string("\n")
;
@@ -2275,7 +2272,7 @@
io__write_string(""", "),
( { MaybeCtorName = yes(CtorId) } ->
io__write_char('"'),
- { CtorId = qual(_Package, _ModuleName, CtorDefn) },
+ { CtorId = qual(_ModuleName, CtorDefn) },
{ CtorDefn = ctor_id(CtorName, _CtorArity) },
c_util__output_quoted_string(CtorName),
io__write_char('"')
@@ -2429,7 +2426,7 @@
io__write_string(", "),
( { MaybeCtorName = yes(QualifiedCtorId) } ->
io__write_char('"'),
- { QualifiedCtorId = qual(_Package, _ModuleName, CtorDefn) },
+ { QualifiedCtorId = qual(_ModuleName, CtorDefn) },
{ CtorDefn = ctor_id(CtorName, _CtorArity) },
c_util__output_quoted_string(CtorName),
io__write_char('"')
Index: compiler/mlds_to_csharp.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_csharp.m,v
retrieving revision 1.5
diff -u -r1.5 mlds_to_csharp.m
--- compiler/mlds_to_csharp.m 2001/06/08 09:13:41 1.5
+++ compiler/mlds_to_csharp.m 2001/06/21 10:11:59
@@ -91,7 +91,6 @@
{ MLDS = mlds(ModuleName, ForeignCode, _Imports, Defns) },
{ ClassName = mlds_module_name_to_class_name(
- mercury_module_name_to_mlds(ModuleName),
mercury_module_name_to_mlds(ModuleName), yes) },
io__nl,
@@ -278,7 +277,7 @@
write_csharp_code_component(raw_target_code(Code)) -->
io__write_string(Code).
% XXX we don't handle name yet.
-write_csharp_code_component(name(_ `with_type` qualified_entity_name)) --> [].
+write_csharp_code_component(name(_)) --> [].
write_csharp_code_component(target_code_input(Rval)) -->
write_csharp_rval(Rval).
write_csharp_code_component(target_code_output(Lval)) -->
@@ -376,7 +375,7 @@
write_csharp_rval(Rval),
io__write_string(")"),
io__write_string("."),
- { FieldId = qual(_, _, FieldName) },
+ { FieldId = qual(_, FieldName) },
io__write_string(FieldName).
write_csharp_lval(field(_, Rval, offset(OffSet), _, _)) -->
@@ -391,7 +390,7 @@
io__write_string("*"),
write_csharp_rval(Rval).
write_csharp_lval(var(Var, _VarType)) -->
- { Var = qual(_, _, VarName) },
+ { Var = qual(_, VarName) },
write_mlds_var_name_for_parameter(VarName).
:- pred write_csharp_defn_decl(mlds__defn, io__state, io__state).
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.33
diff -u -r1.33 mlds_to_il.m
--- compiler/mlds_to_il.m 2001/06/18 09:18:01 1.33
+++ compiler/mlds_to_il.m 2001/06/21 10:12:00
@@ -123,8 +123,8 @@
% Turn an MLDS module name into a class_name name, adding a
% "mercury_code" suffix if the bool is "yes".
-:- func mlds_module_name_to_class_name(mlds__package_name,
- mlds_module_name, bool) = ilds__class_name.
+:- func mlds_module_name_to_class_name(mlds_module_name, bool) =
+ ilds__class_name.
% Return the class_name for the generic class.
@@ -214,7 +214,7 @@
Info3),
list__condense(OtherDeclsList, OtherDecls),
- ClassName = mlds_module_name_to_class_name(ModuleName, ModuleName, yes),
+ ClassName = mlds_module_name_to_class_name(ModuleName, yes),
% Make this module an assembly unless it is in the standard
% library. Standard library modules all go in the one
@@ -397,8 +397,7 @@
generate_method_defn(DataDefn) -->
{ DataDefn = defn(data(DataName), Context, _DeclsFlags, Entity) },
il_info_get_module_name(ModuleName),
- { ClassName = mlds_module_name_to_class_name(
- ModuleName, ModuleName, yes) },
+ { ClassName = mlds_module_name_to_class_name(ModuleName, yes) },
% Generate a term (we use it to emit the complete
% method definition as a comment, which is nice
@@ -510,8 +509,7 @@
:- mode generate_other_decls(in, out, in, out) is det.
generate_other_decls(MLDSDefn, Decls) -->
ModuleName =^ module_name,
- { ClassName = mlds_module_name_to_class_name(ModuleName,
- ModuleName, yes) },
+ { ClassName = mlds_module_name_to_class_name(ModuleName, yes) },
{ MLDSDefn = mlds__defn(EntityName, _Context, _DeclFlags, Entity) },
{ term__type_to_term(MLDSDefn, MLDSDefnTerm) },
( { EntityName = type(TypeName0, Arity) },
@@ -569,8 +567,7 @@
;
( { DataName = var(VarName) } ->
il_info_get_module_name(ModuleName),
- { Lval = var(
- qual(ModuleName, ModuleName, VarName),
+ { Lval = var(qual(ModuleName, VarName),
MLDSType) },
get_load_store_lval_instrs(Lval,
LoadMemRefInstrs, StoreLvalInstrs),
@@ -999,7 +996,7 @@
{ mangle_foreign_code_module(ModuleName, Lang,
OutlineLangModuleName) },
{ ClassName = mlds_module_name_to_class_name(
- OutlineLangModuleName, OutlineLangModuleName, yes) },
+ OutlineLangModuleName, yes) },
signature(_, RetType, Params) =^ signature,
( { ReturnLvals = [] } ->
@@ -1047,7 +1044,7 @@
^ method_foreign_lang := yes(managed_cplusplus),
{ mangle_dataname_module(no, ModuleName, NewModuleName) },
{ ClassName = mlds_module_name_to_class_name(NewModuleName,
- NewModuleName, yes) },
+ no) },
signature(_, RetType, Params) =^ signature,
% If there is a return value, put it in succeeded.
% XXX this is incorrect for functions, which might
@@ -1784,7 +1781,7 @@
test_rtti_initialization_field(DoneFieldRef, TestInstrs),
set_rtti_initialization_field(DoneFieldRef, SetInstrs),
{ CCtorCalls = list__map((func(X) = call_class_constructor(
- mlds_module_name_to_class_name(X, X, yes))), Imports) },
+ mlds_module_name_to_class_name(X, yes))), Imports) },
{ AllInstrs = list__condense([TestInstrs, AllocInstrs, SetInstrs,
CCtorCalls, InitInstrs, [ret]]) },
{ MethodDecls = [instrs(AllInstrs)] }.
@@ -1984,12 +1981,11 @@
:- func mlds_class_name_to_ilds_class_name(mlds__class, arity) =
ilds__class_name.
-mlds_class_name_to_ilds_class_name(qual(MldsPackageName,
- MldsModuleName, MldsClassName0), Arity) = IldsClassName :-
+mlds_class_name_to_ilds_class_name(
+ qual(MldsModuleName, MldsClassName0), Arity) = IldsClassName :-
MldsClassName = string__format("%s_%d", [s(MldsClassName0), i(Arity)]),
IldsClassName = append_class_name(
- mlds_module_name_to_class_name(MldsPackageName,
- MldsModuleName, yes),
+ mlds_module_name_to_class_name(MldsModuleName, yes),
[MldsClassName]).
mlds_type_to_ilds_class_name(DataRep, MldsType) =
@@ -2132,11 +2128,10 @@
:- func make_fieldref_for_handdefined_var(il_data_rep, mlds__var, mlds__type)
= fieldref.
make_fieldref_for_handdefined_var(DataRep, Var, VarType) = FieldRef :-
- Var = qual(Package, ModuleName, _),
+ Var = qual(ModuleName, _),
mangle_mlds_var(Var, MangledVarStr),
- % XXX Do we need to mangle the package name?
mangle_dataname_module(no, ModuleName, NewModuleName),
- ClassName = mlds_module_name_to_class_name(Package, NewModuleName, yes),
+ ClassName = mlds_module_name_to_class_name(NewModuleName, yes),
FieldRef = make_fieldref(
mlds_type_to_ilds_type(DataRep, VarType), ClassName,
MangledVarStr).
@@ -2236,9 +2231,9 @@
error("unimplemented: mangling tabling_pointer").
% We turn procedures into methods of classes.
-mangle_mlds_proc_label(qual(Package, ModuleName, PredLabel - ProcId),
- MaybeSeqNum, ClassName, PredStr) :-
- ClassName = mlds_module_name_to_class_name(Package, ModuleName, yes),
+mangle_mlds_proc_label(qual(ModuleName, PredLabel - ProcId), MaybeSeqNum,
+ ClassName, PredStr) :-
+ ClassName = mlds_module_name_to_class_name(ModuleName, yes),
predlabel_to_id(PredLabel, ProcId, MaybeSeqNum, PredStr).
:- pred mangle_entity_name(mlds__entity_name, string).
@@ -2255,7 +2250,7 @@
% Any valid Mercury identifier will be fine here too.
% We quote all identifiers before we output them, so
% even funny characters should be fine.
-mangle_mlds_var(qual(_Package, _ModuleName, VarName), Str) :-
+mangle_mlds_var(qual(_ModuleName, VarName), Str) :-
Str = mangle_mlds_var_name(VarName).
:- func mangle_mlds_var_name(mlds__var_name) = string.
@@ -2285,18 +2280,17 @@
mlds_to_il__sym_name_to_string_2(unqualified(Name), _) -->
[Name].
-mlds_module_name_to_class_name(Package, MldsModuleName, AddMercuryCode) =
+mlds_module_name_to_class_name(MldsModuleName, AddMercuryCode) =
structured_name(AssemblyName, ClassName) :-
SymName = mlds_module_name_to_sym_name(MldsModuleName),
+ PackageSymName = mlds_module_name_to_package_name(MldsModuleName),
sym_name_to_class_name(SymName, AddMercuryCode, ClassName),
(
ClassName = ["mercury" | _]
->
AssemblyName = "mercury"
;
- mlds_to_il__sym_name_to_string(
- mlds_module_name_to_sym_name(Package),
- AssemblyName)
+ mlds_to_il__sym_name_to_string(PackageSymName, AssemblyName)
).
:- pred sym_name_to_class_name(sym_name, bool, list(ilds__id)).
@@ -2368,19 +2362,19 @@
% XXX can we just call error?
rval_to_type(mkword(_Tag, _Rval), Type, I, I) :-
ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, ModuleName, "invalid"),
+ Type = mlds__class_type(qual(ModuleName, "invalid"),
0, mlds__class).
rval_to_type(unop(_, _), Type, I, I) :-
ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, ModuleName, "invalid"),
+ Type = mlds__class_type(qual(ModuleName, "invalid"),
0, mlds__class).
rval_to_type(binop(_, _, _), Type, I, I) :-
ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, ModuleName, "invalid"),
+ Type = mlds__class_type(qual(ModuleName, "invalid"),
0, mlds__class).
rval_to_type(mem_addr(_), Type, I, I) :-
ModuleName = mercury_module_name_to_mlds(unqualified("mercury")),
- Type = mlds__class_type(qual(ModuleName, ModuleName, "invalid"),
+ Type = mlds__class_type(qual(ModuleName, "invalid"),
0, mlds__class).
rval_to_type(const(Const), Type, I, I) :-
Type = rval_const_to_type(Const).
@@ -2433,8 +2427,7 @@
data_addr_constant_to_fieldref(data_addr(ModuleName, DataName), FieldRef) :-
mangle_dataname(DataName, FieldName),
mangle_dataname_module(yes(DataName), ModuleName, NewModuleName),
- ClassName = mlds_module_name_to_class_name(
- NewModuleName, NewModuleName, yes),
+ ClassName = mlds_module_name_to_class_name(NewModuleName, yes),
FieldRef = make_fieldref(il_array_type, ClassName, FieldName).
@@ -2469,12 +2462,10 @@
"offsets for non-int_const rvals")
)
;
- FieldNum = named_field(
- qual(PackageName, ModuleName, FieldId),
+ FieldNum = named_field(qual(ModuleName, FieldId),
_Type),
- ClassName =
- mlds_module_name_to_class_name(PackageName,
- ModuleName, no)
+ ClassName = mlds_module_name_to_class_name(ModuleName,
+ no)
),
FieldRef = make_fieldref(FieldILType, ClassName, FieldId).
@@ -2490,7 +2481,7 @@
( Name = data(DataName),
Entity = mlds__data(MLDSType0, _Initializer) ->
mangle_dataname(DataName, MangledDataName),
- mangle_mlds_var(qual(ModuleName, ModuleName,
+ mangle_mlds_var(qual(ModuleName,
var_name(MangledDataName, no)), Id),
MLDSType0 = MLDSType
;
@@ -2687,7 +2678,7 @@
mlds_to_il__generate_extern_assembly(Imports, AllDecls) :-
Gen = (pred(Import::in, Decl::out) is semidet :-
- ClassName = mlds_module_name_to_class_name(Import, Import, yes),
+ ClassName = mlds_module_name_to_class_name(Import, yes),
ClassName = structured_name(Assembly, _),
not (Assembly = "mercury"),
Decl = extern_assembly(Assembly, [])
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.5
diff -u -r1.5 mlds_to_java.m
--- compiler/mlds_to_java.m 2001/06/08 09:13:43 1.5
+++ compiler/mlds_to_java.m 2001/06/21 10:12:01
@@ -362,8 +362,7 @@
),
InterfaceModuleName = mercury_module_name_to_mlds(
qualified(unqualified("mercury"), "runtime")),
- Interface = qual(InterfaceModuleName,
- InterfaceModuleName, InterfaceName),
+ Interface = qual(InterfaceModuleName, InterfaceName),
%
% Create the new class
%
@@ -482,7 +481,6 @@
Flags = ml_gen_local_var_decl_flags,
ArrayIndex = const(int_const(Count)),
NewVarName = qual(mercury_module_name_to_mlds(ModuleName),
- mercury_module_name_to_mlds(ModuleName),
var_name("args", no)),
NewArgLval = var(NewVarName, mlds__generic_type),
%
@@ -616,8 +614,7 @@
{ Defn = mlds__defn(Name, Context, Flags, DefnBody) },
indent_line(Context, Indent),
output_decl_flags(Flags, Name),
- output_defn_body(Indent,
- qual(ModuleName, ModuleName, Name), Context, DefnBody).
+ output_defn_body(Indent, qual(ModuleName, Name), Context, DefnBody).
:- pred output_defn_body(indent, mlds__qualified_entity_name,
mlds__context, mlds__entity_defn, io__state, io__state).
@@ -642,7 +639,7 @@
:- mode output_class(in, in, in, in, di, uo) is det.
output_class(Indent, Name, _Context, ClassDefn) -->
- { Name = qual(_Package, ModuleName, UnqualName) },
+ { Name = qual(ModuleName, UnqualName) },
( { UnqualName = type(_, _) } ->
[]
;
@@ -696,10 +693,7 @@
:- mode output_interface(in, di, uo) is det.
output_interface(Interface) -->
- (
- { Interface = class_type(qual(_Package, ModuleQualifier, Name),
- Arity, _) }
- ->
+ ( { Interface = class_type(qual(ModuleQualifier, Name), Arity, _) } ->
{ SymName = mlds_module_name_to_sym_name(ModuleQualifier) },
{ mangle_mlds_sym_name_for_java(SymName, ModuleName) },
io__format("%s.%s", [s(ModuleName), s(Name)]),
@@ -738,7 +732,7 @@
output_class_body(Indent, mlds__enum, Name, AllMembers, _) -->
{ list__filter(defn_is_const, AllMembers, EnumConsts) },
- { Name = qual(_Package, ModuleName, UnqualName) },
+ { Name = qual(ModuleName, UnqualName) },
output_enum_constants(Indent + 1, ModuleName, EnumConsts),
indent_line(Indent + 1),
io__write_string("public int value;\n\n"),
@@ -803,8 +797,7 @@
->
indent_line(Indent),
io__write_string("public static final int "),
- output_fully_qualified_name(
- qual(EnumModuleName, EnumModuleName, Name)),
+ output_fully_qualified_name(qual(EnumModuleName, Name)),
output_initializer(Type, Initializer),
io__write_char(';')
;
@@ -1008,7 +1001,7 @@
io__write_string("java.lang.Object []")
),
io__write_char(' '),
- { QualifiedName = qual(_Package, ModuleName, Name) },
+ { QualifiedName = qual(ModuleName, Name) },
output_name(Name),
output_params(Indent, ModuleName, Context, Parameters).
@@ -1035,7 +1028,7 @@
indent_line(Context, Indent),
output_type(Type),
io__write_char(' '),
- output_fully_qualified_name(qual(ModuleName, ModuleName, Name)).
+ output_fully_qualified_name(qual(ModuleName, Name)).
%-----------------------------------------------------------------------------%
%
@@ -1048,7 +1041,7 @@
:- mode output_fully_qualified_name(in, di, uo) is det.
output_fully_qualified_name(QualifiedName) -->
- { QualifiedName = qual(_Package, _ModuleName, Name) },
+ { QualifiedName = qual(_ModuleName, Name) },
%
% Don't module qualify data names, otherwise all
% variable declarations will be qualified with the
@@ -1073,7 +1066,7 @@
pred(T, io__state, io__state), io__state, io__state).
:- mode output_fully_qualified(in, pred(in, di, uo) is det, di, uo) is det.
-output_fully_qualified(qual(_Package, ModuleName, Name), OutputFunc) -->
+output_fully_qualified(qual(ModuleName, Name), OutputFunc) -->
{ SymName = mlds_module_name_to_sym_name(ModuleName) },
{ mangle_mlds_sym_name_for_java(SymName, MangledModuleName) },
( { qualified_name_is_stdlib(SymName) } ->
@@ -1408,7 +1401,7 @@
io__write_string("{\n"),
( { Defns \= [] } ->
{ FuncInfo = func_info(FuncName, _) },
- { FuncName = qual(_Package, ModuleName, _) },
+ { FuncName = qual(ModuleName, _) },
output_defns(Indent + 1, ModuleName, Defns),
io__write_string("\n")
;
@@ -1575,7 +1568,7 @@
(
{ Rval = mlds__lval(Lval) },
{ Lval = var(VarName, _) },
- { VarName = qual(_, _, UnqualName) },
+ { VarName = qual(_, UnqualName) },
{ UnqualName = var_name("dummy_var", no) }
->
[]
@@ -1779,7 +1772,7 @@
( { MaybeCtorName = yes(QualifiedCtorId) } ->
output_type(Type),
io__write_char('.'),
- { QualifiedCtorId = qual(_Package, _ModuleName, CtorDefn) },
+ { QualifiedCtorId = qual(_ModuleName, CtorDefn) },
{ CtorDefn = ctor_id(CtorName, CtorArity) },
{ llds_out__name_mangle(CtorName, MangledCtorName) },
io__format("%s_%d", [s(MangledCtorName), i(CtorArity)])
@@ -1920,7 +1913,7 @@
output_lval(field(_MaybeTag, PtrRval, named_field(FieldName, CtorType),
_FieldType, _PtrType)) -->
(
- { FieldName = qual(_, _, UnqualFieldName) },
+ { FieldName = qual(_, UnqualFieldName) },
{ llds_out__name_mangle(UnqualFieldName, MangledFieldName) },
{ MangledFieldName = "data_tag" }
->
@@ -1943,13 +1936,13 @@
output_bracketed_rval(PtrRval), % the actual variable
io__write_string(").")
),
- { FieldName = qual(_, _, UnqualFieldName) },
+ { FieldName = qual(_, UnqualFieldName) },
output_mangled_name(UnqualFieldName). % the field name
output_lval(mem_ref(Rval, _Type)) -->
output_bracketed_rval(Rval).
-output_lval(var(qual(_Package, _ModuleName, Name), _VarType)) -->
+output_lval(var(qual(_ModuleName, Name), _VarType)) -->
output_mlds_var_name(Name).
:- pred output_mangled_name(string, io__state, io__state).
Index: compiler/mlds_to_mcpp.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_mcpp.m,v
retrieving revision 1.6
diff -u -r1.6 mlds_to_mcpp.m
--- compiler/mlds_to_mcpp.m 2001/06/08 09:13:45 1.6
+++ compiler/mlds_to_mcpp.m 2001/06/21 10:12:01
@@ -94,7 +94,6 @@
{ MLDS = mlds(ModuleName, ForeignCode, _Imports, Defns) },
{ prog_out__sym_name_to_string(ModuleName, ModuleNameStr) },
{ ClassName = mlds_module_name_to_class_name(
- mercury_module_name_to_mlds(ModuleName),
mercury_module_name_to_mlds(ModuleName), yes) },
io__nl,
@@ -375,8 +374,7 @@
write_managed_cpp_code_component(raw_target_code(Code)) -->
io__write_string(Code).
% XXX we don't handle name yet.
-write_managed_cpp_code_component(
- name(_ `with_type` qualified_entity_name)) --> [].
+write_managed_cpp_code_component(name(_)) --> [].
write_managed_cpp_code_component(target_code_input(Rval)) -->
write_managed_cpp_rval(Rval).
write_managed_cpp_code_component(target_code_output(Lval)) -->
@@ -473,7 +471,7 @@
write_managed_cpp_rval(Rval),
io__write_string(")"),
io__write_string("->"),
- { FieldId = qual(_, _, FieldName) },
+ { FieldId = qual(_, FieldName) },
io__write_string(FieldName).
write_managed_cpp_lval(field(_, Rval, offset(OffSet), _, _)) -->
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.15
diff -u -r1.15 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m 2001/06/08 09:13:45 1.15
+++ compiler/rtti_to_mlds.m 2001/06/21 10:12:09
@@ -530,7 +530,7 @@
ml_gen_pred_label_from_rtti(ModuleInfo, RttiProcId, PredLabel,
PredModule),
ProcId = RttiProcId^proc_id,
- QualifiedProcLabel = qual(PredModule, PredModule, PredLabel - ProcId),
+ QualifiedProcLabel = qual(PredModule, PredLabel - ProcId),
Params = ml_gen_proc_params_from_rtti(ModuleInfo, RttiProcId),
Signature = mlds__get_func_signature(Params),
ProcAddrRval = const(code_addr_const(proc(QualifiedProcLabel,
@@ -569,8 +569,7 @@
% Perhaps we should be using an enumeration type here,
% rather than `mlds__native_int_type'.
Type = mlds__native_int_type,
- Rval = lval(var(
- qual(MLDS_Module, MLDS_Module, var_name(Name, no)), Type)).
+ Rval = lval(var(qual(MLDS_Module, var_name(Name, no)), Type)).
%-----------------------------------------------------------------------------%
%
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list