[m-rev.] diff: rename classdecl as class_member.
Tyson Dowd
trd at miscrit.be
Fri Aug 24 20:42:23 AEST 2001
Hi,
This change was made on the dotnet-foreign branch and causes trouble for
merges, so I have decided to merge it onto the main branch.
===================================================================
Estimated hours taken: 0.5
Branches: main
classdecl sounds too much like we are declaring an entire class, in fact
it is just a member of a class declaration.
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/mlds_to_il.m:
Rename classdecl (or sometimes class_decl) as class_member.
Index: compiler/il_peephole.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/il_peephole.m,v
retrieving revision 1.5
diff -u -r1.5 il_peephole.m
--- compiler/il_peephole.m 24 Jul 2001 15:28:24 -0000 1.5
+++ compiler/il_peephole.m 24 Aug 2001 10:43:56 -0000
@@ -64,10 +64,10 @@
% optimizations.
:- pred optimize_decl(decl::in, decl::out, bool::in, bool::out) is det.
optimize_decl(Decl0, Decl, Mod0, Mod) :-
- ( Decl0 = class(A, B, C, D, ClassDecls0) ->
- list__map_foldl(optimize_class_decl, ClassDecls0, ClassDecls,
- Mod0, Mod),
- Decl = class(A, B, C, D, ClassDecls)
+ ( Decl0 = class(A, B, C, D, ClassMembers0) ->
+ list__map_foldl(optimize_class_member, ClassMembers0,
+ ClassMembers, Mod0, Mod),
+ Decl = class(A, B, C, D, ClassMembers)
; Decl0 = method(A, MethodDecls0) ->
list__map_foldl(optimize_method_decl, MethodDecls0,
MethodDecls, Mod0, Mod),
@@ -81,9 +81,9 @@
Decl0 = Decl
).
-:- pred optimize_class_decl(classdecl::in, classdecl::out,
+:- pred optimize_class_member(class_member::in, class_member::out,
bool::in, bool::out) is det.
-optimize_class_decl(Decl0, Decl, Mod0, Mod) :-
+optimize_class_member(Decl0, Decl, Mod0, Mod) :-
( Decl0 = method(A, MethodDecls0) ->
list__map_foldl(optimize_method_decl, MethodDecls0,
MethodDecls1, Mod0, Mod),
Index: compiler/ilasm.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ilasm.m,v
retrieving revision 1.20
diff -u -r1.20 ilasm.m
--- compiler/ilasm.m 14 Aug 2001 14:00:06 -0000 1.20
+++ compiler/ilasm.m 24 Aug 2001 10:43:57 -0000
@@ -47,7 +47,7 @@
extends, % what is the parent class
implements, % what interfaces are
% implemented
- list(classdecl) % methods and fields
+ list(class_member) % methods and fields
)
% .namespace declaration
; namespace(
@@ -110,7 +110,7 @@
list(implattr) % implementation attributes
).
-:- type classdecl
+:- type class_member
% .method (a class method)
---> method(
methodhead, % name, signature, attributes
@@ -138,7 +138,7 @@
extends, % what is the parent class
implements, % what interfaces are
% implemented
- list(classdecl) % methods and fields
+ list(class_member) % methods and fields
)
% comments
; comment_term(term)
@@ -335,7 +335,7 @@
{ Info2 = Info1 }
),
io__write_string(" {\n"),
- ilasm__write_list(Contents, "\n", output_classdecl, Info2, Info),
+ ilasm__write_list(Contents, "\n", output_class_member, Info2, Info),
io__write_string("\n}").
ilasm__output_decl(namespace(DottedName, Contents), Info0, Info) -->
( { DottedName \= [] } ->
@@ -412,10 +412,10 @@
{ Info = Info0 ^ current_assembly := AsmName },
io__write_string(" { }").
-:- pred ilasm__output_classdecl(classdecl::in, ilasm_info::in, ilasm_info::out,
- io__state::di, io__state::uo) is det.
+:- pred ilasm__output_class_member(class_member::in, ilasm_info::in,
+ ilasm_info::out, io__state::di, io__state::uo) is det.
-ilasm__output_classdecl(method(MethodHead, MethodDecls), Info0, Info) -->
+ilasm__output_class_member(method(MethodHead, MethodDecls), Info0, Info) -->
% Don't do debug output on class constructors, since
% they are automatically generated and take forever to
% run.
@@ -438,7 +438,7 @@
io__write_string(".module extern "),
output_id(ModName).
-ilasm__output_classdecl(
+ilasm__output_class_member(
field(FieldAttrs, Type, IlId, MaybeOffset, Initializer),
Info0, Info) -->
io__write_string(".field "),
@@ -455,7 +455,7 @@
output_id(IlId),
output_field_initializer(Initializer).
-ilasm__output_classdecl(
+ilasm__output_class_member(
property(Type, Name, MaybeGet, MaybeSet), Info0, Info) -->
io__write_string(".property instance "),
output_type(Type, Info0, Info1),
@@ -480,12 +480,12 @@
),
io__write_string("\n}\n").
-ilasm__output_classdecl(nested_class(Attrs, Id, Extends, Implements,
+ilasm__output_class_member(nested_class(Attrs, Id, Extends, Implements,
Contents), Info0, Info) -->
ilasm__output_decl(class(Attrs, Id, Extends, Implements, Contents),
Info0, Info).
-ilasm__output_classdecl(comment(CommentStr), Info, Info) -->
+ilasm__output_class_member(comment(CommentStr), Info, Info) -->
globals__io_lookup_bool_option(auto_comments, PrintComments),
( { PrintComments = yes } ->
output_comment_string(CommentStr)
@@ -493,7 +493,7 @@
[]
).
-ilasm__output_classdecl(comment_term(CommentTerm), Info, Info) -->
+ilasm__output_class_member(comment_term(CommentTerm), Info, Info) -->
globals__io_lookup_bool_option(auto_comments, PrintComments),
( { PrintComments = yes } ->
io__write_string("// "),
@@ -504,7 +504,7 @@
[]
).
-ilasm__output_classdecl(comment_thing(Thing), Info, Info) -->
+ilasm__output_class_member(comment_thing(Thing), Info, Info) -->
globals__io_lookup_bool_option(auto_comments, PrintComments),
( { PrintComments = yes } ->
{ Doc = label("// ", to_doc(Thing)) },
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.77
diff -u -r1.77 mlds_to_il.m
--- compiler/mlds_to_il.m 23 Aug 2001 09:28:03 -0000 1.77
+++ compiler/mlds_to_il.m 24 Aug 2001 10:44:02 -0000
@@ -167,7 +167,7 @@
% class-wide attributes (all accumulate)
alloc_instrs :: instr_tree, % .cctor allocation instructions
init_instrs :: instr_tree, % .cctor init instructions
- classdecls :: list(classdecl), % class methods and fields
+ class_members :: list(class_member), % class methods and fields
has_main :: bool, % class contains main
class_foreign_langs :: set(foreign_language),% class foreign code
field_names :: field_names_set, % field names
@@ -526,7 +526,7 @@
AllocDoneFieldRef, AllocDoneField),
% Generate a class constructor.
- make_class_constructor_classdecl(AllocDoneFieldRef,
+ make_class_constructor_class_member(AllocDoneFieldRef,
Imports, AllocInstrs, InitInstrs, CCtor,
Info2, Info),
@@ -552,11 +552,11 @@
:- pred generate_class_body(mlds__entity_name::in, mlds__context::in,
mlds__class_defn::in,
ilds__class_name::out, ilds__id::out, extends::out,
- implements::out, list(classdecl)::out,
+ implements::out, list(class_member)::out,
il_info::in, il_info::out) is det.
generate_class_body(Name, Context, ClassDefn,
- ClassName, EntityName, Extends, Interfaces, ClassDecls,
+ ClassName, EntityName, Extends, Interfaces, ClassMembers,
Info0, Info) :-
EntityName = entity_name_to_ilds_id(Name),
ClassDefn = class_defn(Kind, _Imports, Inherits, Implements,
@@ -571,7 +571,7 @@
Ctors = maybe_add_empty_ctor(Ctors0, Kind, Context),
list__map_foldl(generate_method(ClassName, yes(Parent)), Ctors,
IlCtors, Info1, Info),
- ClassDecls = IlCtors ++ MethodsAndFields.
+ ClassMembers = IlCtors ++ MethodsAndFields.
% For IL, every class needs a constructor,
% otherwise you can't use the newobj instruction to
@@ -788,10 +788,11 @@
%-----------------------------------------------------------------------------%
:- pred generate_method(ilds__class_name::in, maybe(ilds__class_name)::in,
- mlds__defn::in, classdecl::out,
+ mlds__defn::in, class_membmers::out,
il_info::in, il_info::out) is det.
-generate_method(ClassName, _, defn(Name, Context, Flags, Entity), ClassDecl) -->
+generate_method(ClassName, _, defn(Name, Context, Flags, Entity),
+ ClassMembers) -->
{ Entity = data(Type, DataInitializer) },
{ FieldName = entity_name_to_ilds_id(Name) },
@@ -881,10 +882,10 @@
{ MaybeOffset = no },
{ Initializer = none },
- { ClassDecl = field(Attrs, ILType, FieldName,
+ { ClassMember = field(Attrs, ILType, FieldName,
MaybeOffset, Initializer) }.
-generate_method(_, IsCons, defn(Name, Context, Flags, Entity), ClassDecl) -->
+generate_method(_, IsCons, defn(Name, Context, Flags, Entity), ClassMember) -->
{ Entity = function(_MaybePredProcId, Params, MaybeStatement) },
il_info_get_module_name(ModuleName),
@@ -1059,15 +1060,15 @@
InstrsTree) },
{ list__append(EntryPoint, MethodBody, MethodContents) },
- { ClassDecl = ilasm__method(methodhead(Attrs, MemberName,
+ { ClassMember = ilasm__method(methodhead(Attrs, MemberName,
ILSignature, []), MethodContents)}.
-generate_method(_, _, defn(Name, Context, Flags, Entity), ClassDecl) -->
+generate_method(_, _, defn(Name, Context, Flags, Entity), ClassMember) -->
{ Entity = class(ClassDefn) },
generate_class_body(Name, Context, ClassDefn, _ClassName, EntityName,
- Extends, Interfaces, ClassDecls),
- { ClassDecl = nested_class(decl_flags_to_nestedclassattrs(Flags),
- EntityName, Extends, Interfaces, ClassDecls) }.
+ Extends, Interfaces, ClassMembers),
+ { ClassMember = nested_class(decl_flags_to_nestedclassattrs(Flags),
+ EntityName, Extends, Interfaces, ClassMembers) }.
%-----------------------------------------------------------------------------%
@@ -2592,10 +2593,11 @@
% <initialization instructions generated by field initializers>
%
-:- pred make_class_constructor_classdecl(fieldref, mlds__imports,
- list(instr), list(instr), classdecl, il_info, il_info).
-:- mode make_class_constructor_classdecl(in, in, in, in, out, in, out) is det.
-make_class_constructor_classdecl(DoneFieldRef, Imports, AllocInstrs,
+:- pred make_class_constructor_class_member(fieldref, mlds__imports,
+ list(instr), list(instr), class_member, il_info, il_info).
+:- mode make_class_constructor_class_member(in, in, in, in, out,
+ in, out) is det.
+make_class_constructor_class_member(DoneFieldRef, Imports, AllocInstrs,
InitInstrs, Method) -->
{ Method = method(methodhead([public, static], cctor,
signature(call_conv(no, default), void, []), []),
@@ -2624,7 +2626,7 @@
:- pred generate_rtti_initialization_field(ilds__class_name,
- fieldref, classdecl).
+ fieldref, class_member).
:- mode generate_rtti_initialization_field(in, out, out) is det.
generate_rtti_initialization_field(ClassName, AllocDoneFieldRef,
AllocDoneField) :-
@@ -3836,8 +3838,8 @@
methoddef(call_conv(no, default), RetType,
class_member_name(ClassName, MethodName), TypeParams).
-:- func make_constructor_classdecl(method_defn) = classdecl.
-make_constructor_classdecl(MethodDecls) = method(
+:- func make_constructor_class_member(method_defn) = class_member.
+make_constructor_class_member(MethodDecls) = method(
methodhead([], ctor, signature(call_conv(no, default),
void, []), []), MethodDecls).
@@ -3891,7 +3893,7 @@
},
^ alloc_instrs := empty,
^ init_instrs := empty,
- ^ classdecls := [],
+ ^ class_members := [],
^ has_main := no,
^ class_foreign_langs := set__init,
^ field_names := set__list_to_set(FieldNames).
@@ -3974,11 +3976,11 @@
map__delete_list(Info0 ^ locals, Keys, NewLocals),
Info = Info0 ^ locals := NewLocals.
-:- pred il_info_add_classdecls(list(classdecl), il_info, il_info).
-:- mode il_info_add_classdecls(in, in, out) is det.
-il_info_add_classdecls(ClassDecls, Info0, Info) :-
- Info = Info0 ^ classdecls :=
- list__append(ClassDecls, Info0 ^ classdecls).
+:- pred il_info_add_class_member(list(class_members), il_info, il_info).
+:- mode il_info_add_class_member(in, in, out) is det.
+il_info_add_class_member(ClassMembers, Info0, Info) :-
+ Info = Info0 ^ class_members :=
+ list__append(ClassMembers, Info0 ^ class_members).
:- pred il_info_add_instructions(list(instr), il_info, il_info).
:- mode il_info_add_instructions(in, in, out) is det.
--------------------------------------------------------------------------
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