[m-rev.] for review: item sequence numbers
Zoltan Somogyi
zs at csse.unimelb.edu.au
Mon Jul 28 14:09:34 AEST 2008
For review by Julien.
Zoltan.
Add a sequence number to the information we collect for each kind of item.
The purpose of this is to prepare for a later change that will switch from
representing the stuff we read in from a file as a list of items to
representing it is a data structure that groups all items of a given kind
together. This will lose the original order of the items. The sequence number
will allow us to recreate it if necessary, e.g. for pretty-printing.
compiler/prog_item.m:
Add the sequence number field to the information we have about each
kind of item.
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
Add code to generate the item sequence numbers.
In prog_io.m, change some predicates that used to return an
intermediate type such as processed_type_body to make them return
an item, since this simplifies adding sequence numbers; it also
simplifies the code in general and reduces memory allocation.
Rename some uninformatively-named variables that I missed in my last
diff.
compiler/*.m:
Minor changes to conform to the above. Mostly this involves either
ignoring the seqnum field, or copying it when an item is updated.
cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/add_class.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_class.m,v
retrieving revision 1.30
diff -u -b -r1.30 add_class.m
--- compiler/add_class.m 16 Jul 2008 03:30:26 -0000 1.30
+++ compiler/add_class.m 16 Jul 2008 03:41:20 -0000
@@ -75,7 +75,7 @@
module_add_class_defn(ItemTypeClassInfo, Status, !ModuleInfo, !Specs) :-
ItemTypeClassInfo = item_typeclass_info(Constraints, FunDeps, Name, Vars,
- Interface, VarSet, Context),
+ Interface, VarSet, Context, _SeqNum),
module_info_get_class_table(!.ModuleInfo, Classes0),
list.length(Vars, ClassArity),
ClassId = class_id(Name, ClassArity),
@@ -653,7 +653,7 @@
produce_instance_method_clause(PredOrFunc, Context, Status, InstanceClause,
!ModuleInfo, !QualInfo, !ClausesInfo, !Specs) :-
InstanceClause = item_clause_info(_Origin, CVarSet, ClausePredOrFunc,
- PredName, HeadTerms0, Body, _ClauseContext),
+ PredName, HeadTerms0, Body, _ClauseContext, _SeqNum),
% XXX Can this ever fail? If yes, we should generate an error message
% instead of aborting.
expect(unify(PredOrFunc, ClausePredOrFunc), this_file,
Index: compiler/add_mode.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_mode.m,v
retrieving revision 1.14
diff -u -b -r1.14 add_mode.m
--- compiler/add_mode.m 15 Feb 2008 02:26:53 -0000 1.14
+++ compiler/add_mode.m 15 Jul 2008 14:22:37 -0000
@@ -49,7 +49,7 @@
!Specs) :-
ItemStatus = item_status(Status, _NeedQual),
ItemInstDefnInfo = item_inst_defn_info(VarSet, Name, Params, InstDefn,
- Cond, Context),
+ Cond, Context, _SeqNum),
% Add the definition of this inst to the HLDS inst table.
module_info_get_inst_table(!.ModuleInfo, InstTable0),
inst_table_get_user_insts(InstTable0, Insts0),
@@ -129,7 +129,7 @@
module_add_mode_defn(ItemModeDefnInfo, InvalidMode, ItemStatus, !ModuleInfo,
!Specs) :-
ItemModeDefnInfo = item_mode_defn_info(VarSet, Name, Params, ModeDefn,
- Cond, Context),
+ Cond, Context, _SeqNum),
ItemStatus = item_status(Status, _NeedQual),
module_info_get_mode_table(!.ModuleInfo, Modes0),
modes_add(VarSet, Name, Params, ModeDefn, Cond, Context, Status,
Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.83
diff -u -b -r1.83 add_pragma.m
--- compiler/add_pragma.m 16 Jul 2008 03:30:26 -0000 1.83
+++ compiler/add_pragma.m 16 Jul 2008 03:41:20 -0000
@@ -197,7 +197,7 @@
%-----------------------------------------------------------------------------%
add_pragma(ItemPragma, !Status, !ModuleInfo, !Specs) :-
- ItemPragma = item_pragma_info(Origin, Pragma, Context),
+ ItemPragma = item_pragma_info(Origin, Pragma, Context, _SeqNum),
% Check for invalid pragmas in the `interface' section.
!.Status = item_status(ImportStatus, _),
Allowed = pragma_allowed_in_interface(Pragma),
@@ -2784,7 +2784,7 @@
StatsPredDecl = item_pred_decl_info(Origin, VarSet0, InstVarSet,
ExistQVars, pf_predicate, StatsPredSymName, ArgDecls,
WithType, WithInst, yes(detism_det), Condition, purity_pure,
- Constraints, Context),
+ Constraints, Context, -1),
StatsPredDeclItem = item_pred_decl(StatsPredDecl),
ItemStatus0 = item_status(!.Status, may_be_unqualified),
add_item_decl_pass_1(StatsPredDeclItem, _, ItemStatus0, _,
@@ -2813,7 +2813,7 @@
StatsPragma = pragma_foreign_proc(!.Attrs, StatsPredSymName,
pf_predicate, [Arg1, Arg2, Arg3], !.VarSet, InstVarSet, StatsImpl),
StatsPragmaInfo = item_pragma_info(compiler(pragma_memo_attribute),
- StatsPragma, Context),
+ StatsPragma, Context, -1),
StatsImplItem = item_pragma(StatsPragmaInfo)
),
% XXX Instead of calling add_item_pass_3, we should call what *it* calls.
@@ -2844,7 +2844,7 @@
ResetPredDecl = item_pred_decl_info(Origin, VarSet0, InstVarSet,
ExistQVars, pf_predicate, ResetPredSymName, ArgDecls,
WithType, WithInst, yes(detism_det), Condition, purity_pure,
- Constraints, Context),
+ Constraints, Context, -1),
ResetPredDeclItem = item_pred_decl(ResetPredDecl),
ItemStatus0 = item_status(!.Status, may_be_unqualified),
add_item_decl_pass_1(ResetPredDeclItem, _, ItemStatus0, _,
@@ -2868,7 +2868,7 @@
ResetPragma = pragma_foreign_proc(!.Attrs, ResetPredSymName,
pf_predicate, [Arg1, Arg2], !.VarSet, InstVarSet, ResetImpl),
ResetPragmaInfo = item_pragma_info(compiler(pragma_memo_attribute),
- ResetPragma, Context),
+ ResetPragma, Context, -1),
ResetImplItem = item_pragma(ResetPragmaInfo)
),
% XXX Instead of calling add_item_pass_3, we should call what *it* calls.
Index: compiler/add_solver.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_solver.m,v
retrieving revision 1.21
diff -u -b -r1.21 add_solver.m
--- compiler/add_solver.m 15 Feb 2008 02:26:53 -0000 1.21
+++ compiler/add_solver.m 15 Jul 2008 14:23:56 -0000
@@ -227,7 +227,7 @@
Impl
),
ToGroundRepnItemPragma = item_pragma_info(compiler(solver_type),
- ToGroundRepnForeignProc, Context),
+ ToGroundRepnForeignProc, Context, -1),
ToGroundRepnItem = item_pragma(ToGroundRepnItemPragma),
add_item_pass_3(ToGroundRepnItem, !Status, !ModuleInfo,
!QualInfo, !Specs),
@@ -249,7 +249,7 @@
Impl
),
ToAnyRepnItemPragma = item_pragma_info(compiler(solver_type),
- ToAnyRepnForeignProc, Context),
+ ToAnyRepnForeignProc, Context, -1),
ToAnyRepnItem = item_pragma(ToAnyRepnItemPragma),
add_item_pass_3(ToAnyRepnItem, !Status, !ModuleInfo,
!QualInfo, !Specs),
@@ -271,7 +271,7 @@
Impl
),
FromGroundRepnItemPragma = item_pragma_info(compiler(solver_type),
- FromGroundRepnForeignProc, Context),
+ FromGroundRepnForeignProc, Context, -1),
FromGroundRepnItem = item_pragma(FromGroundRepnItemPragma),
add_item_pass_3(FromGroundRepnItem, !Status, !ModuleInfo,
!QualInfo, !Specs),
@@ -293,7 +293,7 @@
Impl
),
FromAnyRepnItemPragma = item_pragma_info(compiler(solver_type),
- FromAnyRepnForeignProc, Context),
+ FromAnyRepnForeignProc, Context, -1),
FromAnyRepnItem = item_pragma(FromAnyRepnItemPragma),
add_item_pass_3(FromAnyRepnItem, !Status, !ModuleInfo,
!QualInfo, !Specs).
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.81
diff -u -b -r1.81 equiv_type.m
--- compiler/equiv_type.m 15 Feb 2008 08:31:58 -0000 1.81
+++ compiler/equiv_type.m 15 Jul 2008 14:52:33 -0000
@@ -175,7 +175,7 @@
build_eqv_map([Item | Items], !EqvMap, !EqvInstMap) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _Context, _SeqNum),
ModuleDefn = md_abstract_imported
->
skip_abstract_imported_items(Items, AfterSkipItems),
@@ -184,7 +184,7 @@
(
Item = item_type_defn(ItemTypeDefn),
ItemTypeDefn = item_type_defn_info(VarSet, Name, Args,
- parse_tree_eqv_type(Body), _, _)
+ parse_tree_eqv_type(Body), _, _, _SeqNum)
->
list.length(Args, Arity),
TypeCtor = type_ctor(Name, Arity),
@@ -192,7 +192,7 @@
;
Item = item_inst_defn(ItemInstDefn),
ItemInstDefn = item_inst_defn_info(VarSet, Name, Args,
- eqv_inst(Body), _, _)
+ eqv_inst(Body), _, _, _SeqNum)
->
list.length(Args, Arity),
InstId = inst_id(Name, Arity),
@@ -209,7 +209,7 @@
skip_abstract_imported_items([Item0 | Items0], Items) :-
(
Item0 = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _SeqNum),
is_section_defn(ModuleDefn) = yes,
ModuleDefn \= md_abstract_imported
->
@@ -254,7 +254,7 @@
replace_in_item_list(ModuleName, Location0, [Item0 | Items0],
EqvMap, EqvInstMap, !ReplItems, !RecompInfo, !UsedModules, !Specs) :-
( Item0 = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _SeqNum),
(
ModuleDefn = md_interface,
Location = eqv_type_in_interface
@@ -372,7 +372,7 @@
replace_in_type_defn_info(ModuleName, Location, EqvMap, _EqvInstMap,
Info0, Info, !RecompInfo, !UsedModules, Specs) :-
Info0 = item_type_defn_info(VarSet0, SymName, TArgs, TypeDefn0, Cond,
- Context),
+ Context, SeqNum),
list.length(TArgs, Arity),
maybe_start_recording_expanded_items(ModuleName, SymName, !.RecompInfo,
UsedTypeCtors0),
@@ -397,7 +397,7 @@
ItemId = item_id(type_body_item, item_name(SymName, Arity)),
finish_recording_expanded_items(ItemId, UsedTypeCtors, !RecompInfo),
Info = item_type_defn_info(VarSet, SymName, TArgs, TypeDefn, Cond,
- Context).
+ Context, SeqNum).
:- pred replace_in_pred_decl_info(module_name::in, eqv_type_location::in,
eqv_map::in, eqv_inst_map::in,
@@ -409,7 +409,7 @@
Info0, Info, !RecompInfo, !UsedModules, Specs) :-
Info0 = item_pred_decl_info(Origin, TypeVarSet0, InstVarSet, ExistQVars,
PredOrFunc, PredName, TypesAndModes0, MaybeWithType0,
- MaybeWithInst0, Det0, Cond, Purity, ClassContext0, Context),
+ MaybeWithInst0, Det0, Cond, Purity, ClassContext0, Context, SeqNum),
maybe_start_recording_expanded_items(ModuleName, PredName, !.RecompInfo,
ExpandedItems0),
replace_in_pred_type(Location, PredName, PredOrFunc, Context, EqvMap,
@@ -424,7 +424,7 @@
finish_recording_expanded_items(ItemId, ExpandedItems, !RecompInfo),
Info = item_pred_decl_info(Origin, TypeVarSet, InstVarSet, ExistQVars,
PredOrFunc, PredName, TypesAndModes, MaybeWithType,
- MaybeWithInst, Det, Cond, Purity, ClassContext, Context).
+ MaybeWithInst, Det, Cond, Purity, ClassContext, Context, SeqNum).
:- pred replace_in_mode_decl_info(module_name::in, eqv_type_location::in,
eqv_map::in, eqv_inst_map::in,
@@ -435,7 +435,7 @@
replace_in_mode_decl_info(ModuleName, Location, _EqvMap, EqvInstMap,
Info0, Info, !RecompInfo, !UsedModules, Specs) :-
Info0 = item_mode_decl_info(InstVarSet, MaybePredOrFunc0, PredName,
- Modes0, WithInst0, Det0, Cond, Context),
+ Modes0, WithInst0, Det0, Cond, Context, SeqNum),
maybe_start_recording_expanded_items(ModuleName, PredName, !.RecompInfo,
ExpandedItems0),
replace_in_pred_mode(Location, PredName, length(Modes0), Context,
@@ -460,7 +460,7 @@
MaybePredOrFunc = no
),
Info = item_mode_decl_info(InstVarSet, MaybePredOrFunc, PredName,
- Modes, WithInst, Det, Cond, Context).
+ Modes, WithInst, Det, Cond, Context, SeqNum).
:- pred replace_in_typeclass_info(module_name::in, eqv_type_location::in,
eqv_map::in, eqv_inst_map::in,
@@ -471,7 +471,7 @@
replace_in_typeclass_info(ModuleName, Location, EqvMap, EqvInstMap,
Info0, Info, !RecompInfo, !UsedModules, Specs) :-
Info0 = item_typeclass_info(Constraints0, FunDeps, ClassName, Vars,
- ClassInterface0, VarSet0, Context),
+ ClassInterface0, VarSet0, Context, SeqNum),
list.length(Vars, Arity),
maybe_start_recording_expanded_items(ModuleName, ClassName, !.RecompInfo,
ExpandedItems0),
@@ -492,7 +492,7 @@
ItemId = item_id(typeclass_item, item_name(ClassName, Arity)),
finish_recording_expanded_items(ItemId, ExpandedItems, !RecompInfo),
Info = item_typeclass_info(Constraints, FunDeps, ClassName, Vars,
- ClassInterface, VarSet, Context).
+ ClassInterface, VarSet, Context, SeqNum).
:- pred replace_in_instance_info(module_name::in, eqv_type_location::in,
eqv_map::in, eqv_inst_map::in,
@@ -503,7 +503,7 @@
replace_in_instance_info(ModuleName, Location, EqvMap, _EqvInstMap,
Info0, Info, !RecompInfo, !UsedModules, []) :-
Info0 = item_instance_info(Constraints0, ClassName, Ts0, InstanceBody,
- VarSet0, ContainingModuleName, Context),
+ VarSet0, ContainingModuleName, Context, SeqNum),
(
( !.RecompInfo = no
; ContainingModuleName = ModuleName
@@ -522,7 +522,7 @@
ItemId = item_id(typeclass_item, item_name(ClassName, Arity)),
finish_recording_expanded_items(ItemId, UsedTypeCtors, !RecompInfo),
Info = item_instance_info(Constraints, ClassName, Ts, InstanceBody,
- VarSet, ContainingModuleName, Context).
+ VarSet, ContainingModuleName, Context, SeqNum).
:- pred replace_in_pragma_info(module_name::in, eqv_type_location::in,
eqv_map::in, eqv_inst_map::in,
@@ -532,7 +532,7 @@
replace_in_pragma_info(ModuleName, Location, EqvMap, _EqvInstMap,
Info0, Info, !RecompInfo, !UsedModules, []) :-
- Info0 = item_pragma_info(Origin, Pragma0, Context),
+ Info0 = item_pragma_info(Origin, Pragma0, Context, SeqNum),
(
Pragma0 = pragma_type_spec(PredName, NewName, Arity,
PorF, Modes, Subst0, VarSet0, ItemIds0),
@@ -619,7 +619,7 @@
),
Pragma = Pragma0
),
- Info = item_pragma_info(Origin, Pragma, Context).
+ Info = item_pragma_info(Origin, Pragma, Context, SeqNum).
:- pred replace_in_mutable_info(module_name::in, eqv_type_location::in,
eqv_map::in, eqv_inst_map::in,
@@ -630,7 +630,7 @@
replace_in_mutable_info(ModuleName, Location, EqvMap, EqvInstMap,
Info0, Info, !RecompInfo, !UsedModules, []) :-
Info0 = item_mutable_info(MutName, Type0, InitValue, Inst0, Attrs, Varset,
- Context),
+ Context, SeqNum),
QualName = qualified(ModuleName, MutName),
maybe_start_recording_expanded_items(ModuleName, QualName, !.RecompInfo,
ExpandedItems0),
@@ -642,7 +642,7 @@
ItemId = item_id(mutable_item, item_name(QualName, 0)),
finish_recording_expanded_items(ItemId, ExpandedItems, !RecompInfo),
Info = item_mutable_info(MutName, Type, InitValue, Inst, Attrs, Varset,
- Context).
+ Context, SeqNum).
:- pred replace_in_event_spec_list(
assoc_list(string, event_spec)::in, assoc_list(string, event_spec)::out,
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.233
diff -u -b -r1.233 intermod.m
--- compiler/intermod.m 21 Jul 2008 03:10:08 -0000 1.233
+++ compiler/intermod.m 21 Jul 2008 03:23:19 -0000
@@ -1304,7 +1304,7 @@
TypeBody = parse_tree_solver_type(SolverTypeDetails, MaybeUserEqComp)
),
MainItemTypeDefn = item_type_defn_info(VarSet, Name, Args, TypeBody,
- cond_true, Context),
+ cond_true, Context, -1),
MainItem = item_type_defn(MainItemTypeDefn),
mercury_output_item(MainItem, !IO),
(
@@ -1321,7 +1321,7 @@
ILItemTypeDefn = item_type_defn_info(VarSet, Name, Args,
parse_tree_foreign_type(il(ILForeignType),
ILMaybeUserEqComp, AssertionsIL),
- cond_true, Context),
+ cond_true, Context, -1),
ILItem = item_type_defn(ILItemTypeDefn),
mercury_output_item(ILItem, !IO)
;
@@ -1334,7 +1334,7 @@
CItemTypeDefn = item_type_defn_info(VarSet, Name, Args,
parse_tree_foreign_type(c(CForeignType),
CMaybeUserEqComp, AssertionsC),
- cond_true, Context),
+ cond_true, Context, -1),
CItem = item_type_defn(CItemTypeDefn),
mercury_output_item(CItem, !IO)
;
@@ -1347,7 +1347,7 @@
JavaItemTypeDefn = item_type_defn_info(VarSet, Name, Args,
parse_tree_foreign_type(java(JavaForeignType),
JavaMaybeUserEqComp, AssertionsJava),
- cond_true, Context),
+ cond_true, Context, -1),
JavaItem = item_type_defn(JavaItemTypeDefn),
mercury_output_item(JavaItem, !IO)
;
@@ -1360,7 +1360,7 @@
ErlangItemTypeDefn = item_type_defn_info(VarSet, Name, Args,
parse_tree_foreign_type(erlang(ErlangForeignType),
ErlangMaybeUserEqComp, AssertionsErlang),
- cond_true, Context),
+ cond_true, Context, -1),
ErlangItem = item_type_defn(ErlangItemTypeDefn),
mercury_output_item(ErlangItem, !IO)
;
@@ -1375,7 +1375,7 @@
->
% The pragma_origin doesn't matter here.
ReserveItemPragma = item_pragma_info(user,
- pragma_reserve_tag(Name, Arity), Context),
+ pragma_reserve_tag(Name, Arity), Context, -1),
ReserveItem = item_pragma(ReserveItemPragma),
mercury_output_item(ReserveItem, !IO)
;
@@ -1388,7 +1388,7 @@
map.foldl(gather_foreign_enum_value_pair, ConsTagVals, [],
ForeignEnumVals),
Pragma = pragma_foreign_enum(Lang, Name, Arity, ForeignEnumVals),
- ForeignItemPragma = item_pragma_info(user, Pragma, Context),
+ ForeignItemPragma = item_pragma_info(user, Pragma, Context, -1),
ForeignItem = item_pragma(ForeignItemPragma),
mercury_output_item(ForeignItem, !IO)
;
@@ -1432,7 +1432,7 @@
import_status_to_write(ImportStatus)
->
ItemModeDefn = item_mode_defn_info(Varset, SymName, Args,
- eqv_mode(Mode), cond_true, Context),
+ eqv_mode(Mode), cond_true, Context, -1),
Item = item_mode_defn(ItemModeDefn),
mercury_output_item(Item, !IO)
;
@@ -1466,7 +1466,7 @@
InstBody = abstract_inst
),
ItemInstDefn = item_inst_defn_info(Varset, SymName, Args, InstBody,
- cond_true, Context),
+ cond_true, Context, -1),
Item = item_inst_defn(ItemInstDefn),
mercury_output_item(Item, !IO)
;
@@ -1494,7 +1494,7 @@
->
FunDeps = list.map(unmake_hlds_class_fundep(TVars), HLDSFunDeps),
ItemTypeClass = item_typeclass_info(Constraints, FunDeps,
- QualifiedClassName, TVars, Interface, TVarSet, Context),
+ QualifiedClassName, TVars, Interface, TVarSet, Context, -1),
Item = item_typeclass(ItemTypeClass),
mercury_output_item(Item, !IO)
;
@@ -1531,7 +1531,7 @@
Types, Body, _, TVarSet, _),
ClassId = class_id(ClassName, _),
ItemInstance = item_instance_info(Constraints, ClassName, Types, Body,
- TVarSet, ModuleName, Context),
+ TVarSet, ModuleName, Context, -1),
Item = item_instance(ItemInstance),
mercury_output_item(Item, !IO).
@@ -2300,10 +2300,10 @@
set.init, [], LocalItems, no, UA_SR_Error, !IO),
KeepPragma = (pred(Item::in) is semidet :-
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
(
UnusedArgs = yes,
- Pragma = pragma_unused_args(_,_,_,_,_)
+ Pragma = pragma_unused_args(_, _, _, _, _)
;
StructureReuse = yes,
Pragma = pragma_structure_reuse(_, _, _, _, _, _)
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.80
diff -u -b -r1.80 make_hlds_passes.m
--- compiler/make_hlds_passes.m 21 Jul 2008 03:10:09 -0000 1.80
+++ compiler/make_hlds_passes.m 21 Jul 2008 03:23:20 -0000
@@ -372,7 +372,7 @@
% into ordinary constructions/deconstructions, but preserve the
% corresponding impurity annotations.
ItemTypeDefnInfo = item_type_defn_info(TVarSet, SymName, TypeParams,
- TypeDefn, _Cond, Context),
+ TypeDefn, _Cond, Context, _SeqNum),
( TypeDefn = parse_tree_solver_type(SolverTypeDetails, _MaybeUserEqComp) ->
add_solver_type_decl_items(TVarSet, SymName, TypeParams,
SolverTypeDetails, Context, !Status, !ModuleInfo, !Specs),
@@ -389,7 +389,7 @@
add_pass_1_pred_decl(ItemPredDecl, Status, !ModuleInfo, !Specs) :-
ItemPredDecl = item_pred_decl_info(Origin, TypeVarSet, InstVarSet,
ExistQVars, PredOrFunc, PredName, TypesAndModes, _WithType, _WithInst,
- MaybeDet, _Cond, Purity, ClassContext, Context),
+ MaybeDet, _Cond, Purity, ClassContext, Context, _SeqNum),
init_markers(Markers0),
% If this predicate was added as a result of the mutable transformation
@@ -423,7 +423,7 @@
add_pass_1_mode_decl(ItemModeDecl, Status, !ModuleInfo, !Specs) :-
ItemModeDecl = item_mode_decl_info(VarSet, MaybePredOrFunc, PredName,
- Modes, _WithInst, MaybeDet, _Cond, Context),
+ Modes, _WithInst, MaybeDet, _Cond, Context, _SeqNum),
(
MaybePredOrFunc = yes(PredOrFunc),
Status = item_status(ImportStatus, _),
@@ -443,7 +443,7 @@
list(error_spec)::in, list(error_spec)::out) is det.
add_pass_1_module_defn(ItemModuleDefn, !Status, !ModuleInfo, !Specs) :-
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _SeqNum),
( module_defn_update_import_status(ModuleDefn, StatusPrime) ->
!:Status = StatusPrime
; ModuleDefn = md_import(ModuleSpecifiers) ->
@@ -501,7 +501,7 @@
% We add the initialise decl and the foreign_decl on the second pass and
% the foreign_proc clauses on the third pass.
Item = item_mutable_info(Name, Type, _InitValue, Inst, MutAttrs,
- _MutVarset, Context),
+ _MutVarset, Context, _SeqNum),
Status = item_status(ImportStatus, _),
DefinedThisModule = status_defined_in_this_module(ImportStatus),
(
@@ -657,7 +657,7 @@
add_item_decl_pass_2(Item, !Status, !ModuleInfo, !Specs) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _SeqNum),
( module_defn_update_import_status(ModuleDefn, NewStatus) ->
!:Status = NewStatus
;
@@ -702,7 +702,7 @@
add_pass_2_type_defn(ItemTypeDefn, Status, !ModuleInfo, !Specs) :-
ItemTypeDefn = item_type_defn_info(VarSet, Name, Args, TypeDefn, Cond,
- Context),
+ Context, _SeqNum),
module_add_type_defn(VarSet, Name, Args, TypeDefn, Cond, Context,
Status, !ModuleInfo, !Specs),
( TypeDefn = parse_tree_solver_type(SolverTypeDetails, _MaybeUserEqComp) ->
@@ -719,7 +719,7 @@
add_pass_2_pred_decl(ItemPredDecl, _Status, !ModuleInfo, !Specs) :-
ItemPredDecl = item_pred_decl_info(_Origin, _TypeVarSet, _InstVarSet,
_ExistQVars, PredOrFunc, SymName, TypesAndModes, _WithType, _WithInst,
- _MaybeDet, _Cond, _Purity, _ClassContext, _Context),
+ _MaybeDet, _Cond, _Purity, _ClassContext, _Context, _SeqNum),
% Add default modes for function declarations, if necessary.
(
PredOrFunc = pf_predicate
@@ -747,7 +747,7 @@
add_pass_2_instance(ItemInstance, Status, !ModuleInfo, !Specs) :-
ItemInstance = item_instance_info(Constraints, Name, Types, Body, VarSet,
- InstanceModuleName, Context),
+ InstanceModuleName, Context, _SeqNum),
Status = item_status(ImportStatus, _),
(
Body = instance_body_abstract,
@@ -766,7 +766,7 @@
add_pass_2_initialise(ItemInitialise, Status, !ModuleInfo, !Specs) :-
% These are processed properly during pass 3, we just do some
% error checking at this point.
- ItemInitialise = item_initialise_info(Origin, _, _, Context),
+ ItemInitialise = item_initialise_info(Origin, _, _, Context, _SeqNum),
Status = item_status(ImportStatus, _),
( ImportStatus = status_exported ->
(
@@ -799,7 +799,7 @@
add_pass_2_finalise(ItemFinalise, Status, !ModuleInfo, !Specs) :-
% There are processed properly during pass 3, we just do some error
% checking at this point.
- ItemFinalise = item_finalise_info(Origin, _, _, Context),
+ ItemFinalise = item_finalise_info(Origin, _, _, Context, _SeqNum),
Status = item_status(ImportStatus, _),
( ImportStatus = status_exported ->
(
@@ -821,7 +821,7 @@
add_pass_2_mutable(ItemMutable, Status, !ModuleInfo, !Specs) :-
ItemMutable = item_mutable_info(Name, _Type, _InitTerm, Inst,
- MutAttrs, _MutVarset, Context),
+ MutAttrs, _MutVarset, Context, _SeqNum),
Status = item_status(ImportStatus, _),
( ImportStatus = status_exported ->
error_is_exported(Context, "`mutable' declaration", !Specs)
@@ -875,7 +875,8 @@
SetPredName = mutable_set_pred_sym_name(ModuleName, Name),
IOSetPromisePurePragma = pragma_promise_pure(SetPredName, 3),
IOSetPromisePureItemPragma = item_pragma_info(
- compiler(mutable_decl), IOSetPromisePurePragma, Context),
+ compiler(mutable_decl), IOSetPromisePurePragma, Context,
+ -1),
add_pragma(IOSetPromisePureItemPragma, Status, _,
!ModuleInfo, !Specs)
;
@@ -1038,7 +1039,7 @@
add_pass_3_clause(ItemClause, Status, !ModuleInfo, !QualInfo, !Specs) :-
ItemClause = item_clause_info(Origin, VarSet, PredOrFunc,
- PredName, Args, Body, Context),
+ PredName, Args, Body, Context, _SeqNum),
( Status = status_exported ->
(
Origin = user,
@@ -1082,7 +1083,7 @@
add_pass_3_type_defn(ItemTypeDefn, Status, !ModuleInfo, !QualInfo, !Specs) :-
ItemTypeDefn = item_type_defn_info(_TVarSet, SymName, TypeParams, TypeDefn,
- _Cond, Context),
+ _Cond, Context, _SeqNum),
% If this is a solver type, then we need to also add the clauses for
% the compiler generated inst cast predicate (the declaration for which
% was added in pass 1). We should only add the clauses if this is the
@@ -1107,7 +1108,7 @@
add_pass_3_pred_decl(ItemPredDecl, Status, !ModuleInfo, !QualInfo, !Specs) :-
ItemPredDecl = item_pred_decl_info(_, _, _, _, PredOrFunc, SymName,
- TypesAndModes, _WithType, _WithInst, _, _, _, _, Context),
+ TypesAndModes, _WithType, _WithInst, _, _, _, _, Context, _SeqNum),
(
PredOrFunc = pf_predicate
;
@@ -1125,7 +1126,7 @@
add_pass_3_module_defn(ItemModuleDefn, !Status, !ModuleInfo, !QualInfo,
!Specs) :-
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _Context, _SeqNum),
( ModuleDefn = md_version_numbers(ModuleName, ModuleVersionNumbers) ->
% Record the version numbers for each imported module
% if smart recompilation is enabled.
@@ -1149,7 +1150,7 @@
list(error_spec)::in, list(error_spec)::out) is det.
add_pass_3_pragma(ItemPragma, !Status, !ModuleInfo, !QualInfo, !Specs) :-
- ItemPragma = item_pragma_info(Origin, Pragma, Context),
+ ItemPragma = item_pragma_info(Origin, Pragma, Context, _SeqNum),
(
Pragma = pragma_foreign_proc(Attributes, Pred, PredOrFunc,
Vars, ProgVarSet, InstVarSet, PragmaImpl),
@@ -1280,7 +1281,7 @@
add_pass_3_promise(ItemPromise, Status, !ModuleInfo, !QualInfo, !Specs) :-
ItemPromise = item_promise_info(PromiseType, Goal, VarSet, UnivVars,
- Context),
+ Context, _SeqNum),
% If the outermost universally quantified variables are placed in the head
% of the dummy predicate, the typechecker will avoid warning about unbound
% type variables as this implicitly adds a universal quantification of the
@@ -1307,7 +1308,8 @@
add_pass_3_initialise(ItemInitialise, Status, !ModuleInfo, !QualInfo,
!Specs) :-
- ItemInitialise = item_initialise_info(Origin, SymName, Arity, Context),
+ ItemInitialise = item_initialise_info(Origin, SymName, Arity, Context,
+ _SeqNum),
Origin = user,
% To handle a `:- initialise initpred.' declaration for C backends we need
@@ -1351,7 +1353,7 @@
ExportPragma = pragma_foreign_export(ExportLang, SymName,
pf_predicate, [di_mode, uo_mode], CName),
ExportItemPragma = item_pragma_info(compiler(initialise_decl),
- ExportPragma, Context),
+ ExportPragma, Context, -1),
ExportItem = item_pragma(ExportItemPragma),
add_item_pass_3(ExportItem, Status, _,
!ModuleInfo, !QualInfo, !Specs)
@@ -1373,7 +1375,7 @@
ExportPragma = pragma_foreign_export(ExportLang, SymName,
pf_predicate, [], CName),
ExportItemPragma = item_pragma_info(compiler(initialise_decl),
- ExportPragma, Context),
+ ExportPragma, Context, -1),
ExportItem = item_pragma(ExportItemPragma),
add_item_pass_3(ExportItem, Status, _,
!ModuleInfo, !QualInfo, !Specs)
@@ -1405,7 +1407,8 @@
).
add_pass_3_initialise(ItemInitialise, Status, !ModuleInfo, !QualInfo,
!Specs) :-
- ItemInitialise = item_initialise_info(Origin, SymName, Arity, Context),
+ ItemInitialise = item_initialise_info(Origin, SymName, Arity, Context,
+ _SeqNum),
Origin = compiler(Details),
% The compiler introduces initialise declarations that call impure
@@ -1420,7 +1423,7 @@
ExportPragma = pragma_foreign_export(ExportLang, SymName, pf_predicate,
[], CName),
ExportItemPragma = item_pragma_info(compiler(mutable_decl),
- ExportPragma, Context),
+ ExportPragma, Context, -1),
ExportItem = item_pragma(ExportItemPragma),
add_item_pass_3(ExportItem, Status, _,
!ModuleInfo, !QualInfo, !Specs)
@@ -1440,7 +1443,8 @@
list(error_spec)::in, list(error_spec)::out) is det.
add_pass_3_finalise(ItemFinalise, Status, !ModuleInfo, !QualInfo, !Specs) :-
- ItemFinalise = item_finalise_info(Origin, SymName, Arity, Context),
+ ItemFinalise = item_finalise_info(Origin, SymName, Arity, Context,
+ _SeqNum),
% To handle a `:- finalise finalpred.' declaration for C backends we need
% to:
@@ -1492,7 +1496,7 @@
ExportPragma = pragma_foreign_export(ExportLang, SymName,
pf_predicate, [di_mode, uo_mode], CName),
ExportItemPragma = item_pragma_info(compiler(finalise_decl),
- ExportPragma, Context),
+ ExportPragma, Context, -1),
ExportItem = item_pragma(ExportItemPragma),
add_item_pass_3(ExportItem, Status, _,
!ModuleInfo, !QualInfo, !Specs)
@@ -1514,7 +1518,7 @@
ExportPragma = pragma_foreign_export(ExportLang, SymName,
pf_predicate, [], CName),
ExportItemPragma = item_pragma_info(compiler(finalise_decl),
- ExportPragma, Context),
+ ExportPragma, Context, -1),
ExportItem = item_pragma(ExportItemPragma),
add_item_pass_3(ExportItem, Status, _,
!ModuleInfo, !QualInfo, !Specs)
@@ -1560,7 +1564,7 @@
add_pass_3_mutable(ItemMutable, Status, !ModuleInfo, !QualInfo, !Specs) :-
ItemMutable = item_mutable_info(MercuryMutableName, Type, _InitTerm, _Inst,
- MutAttrs, _MutVarset, Context),
+ MutAttrs, _MutVarset, Context, _SeqNum),
% The transformation here is documented in the comments at the
% beginning of prog_mutable.m.
@@ -1728,7 +1732,7 @@
DeclPragma =
pragma_foreign_decl(lang_c, foreign_decl_is_exported, DeclBody),
DeclItemPragma = item_pragma_info(compiler(mutable_decl), DeclPragma,
- Context),
+ Context, -1),
DeclItem = item_pragma(DeclItemPragma).
% Create the C foreign_defn for the mutable.
@@ -1775,7 +1779,7 @@
TypeName, " ", TargetMutableName, ";\n" | LockDefn]),
DefnPragma = pragma_foreign_code(lang_c, DefnBody),
DefnItemPragma = item_pragma_info(compiler(mutable_decl), DefnPragma,
- Context),
+ Context, -1),
DefnItem = item_pragma(DefnItemPragma).
:- func global_foreign_type_name(bool, foreign_language, module_info,
@@ -1796,7 +1800,7 @@
!QualInfo, !Specs) :-
module_info_get_name(!.ModuleInfo, ModuleName),
ItemMutableInfo = item_mutable_info(MercuryMutableName, Type, InitTerm,
- Inst, MutAttrs, MutVarset, Context),
+ Inst, MutAttrs, MutVarset, Context, _SeqNum),
IsConstant = mutable_var_constant(MutAttrs),
IsThreadLocal = mutable_var_thread_local(MutAttrs),
@@ -1864,7 +1868,7 @@
fc_impl_ordinary("X = " ++ TargetMutableName ++ ";", yes(Context))
),
ConstantGetItemPragma = item_pragma_info(compiler(mutable_decl),
- ConstantGetForeignProc, Context),
+ ConstantGetForeignProc, Context, -1),
ConstantGetItem = item_pragma(ConstantGetItemPragma),
add_item_pass_3(ConstantGetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -1880,7 +1884,7 @@
fc_impl_ordinary(TargetMutableName ++ " = X;", yes(Context))
),
ConstantSetItemPragma = item_pragma_info(compiler(mutable_decl),
- ConstantSetForeignProc, Context),
+ ConstantSetForeignProc, Context, -1),
ConstantSetItem = item_pragma(ConstantSetItemPragma),
add_item_pass_3(ConstantSetItem, !Status, !ModuleInfo, !QualInfo, !Specs).
@@ -1926,7 +1930,7 @@
fc_impl_ordinary(LockForeignProcBody, yes(Context))
),
LockItemPragma = item_pragma_info(compiler(mutable_decl),
- LockForeignProc, Context),
+ LockForeignProc, Context, -1),
LockItem = item_pragma(LockItemPragma),
add_item_pass_3(LockItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -1954,7 +1958,7 @@
fc_impl_ordinary(UnlockForeignProcBody, yes(Context))
),
UnlockItemPragma = item_pragma_info(compiler(mutable_decl),
- UnlockForeignProc, Context),
+ UnlockForeignProc, Context, -1),
UnlockItem = item_pragma(UnlockItemPragma),
add_item_pass_3(UnlockItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -1980,7 +1984,7 @@
fc_impl_ordinary(UnsafeGetCode, yes(Context))
),
UnsafeGetItemPragma = item_pragma_info(compiler(mutable_decl),
- UnsafeGetForeignProc, Context),
+ UnsafeGetForeignProc, Context, -1),
UnsafeGetItem = item_pragma(UnsafeGetItemPragma),
add_item_pass_3(UnsafeGetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2031,7 +2035,7 @@
fc_impl_ordinary(TrailCode ++ SetCode, yes(Context))
),
UnsafeSetItemPragma = item_pragma_info(compiler(mutable_decl),
- UnsafeSetForeignProc, Context),
+ UnsafeSetForeignProc, Context, -1),
UnsafeSetItem = item_pragma(UnsafeSetItemPragma),
add_item_pass_3(UnsafeSetItem, !Status, !ModuleInfo, !QualInfo, !Specs).
@@ -2067,14 +2071,9 @@
StdGetBody = promise_purity_expr(dont_make_implicit_promises,
purity_semipure, GetBody) - Context,
- StdGetItemClause = item_clause_info(
- compiler(mutable_decl),
- ProgVarSet0,
- pf_predicate,
- GetPredName,
- [variable(X, context_init)],
- StdGetBody,
- Context
+ StdGetItemClause = item_clause_info(compiler(mutable_decl), ProgVarSet0,
+ pf_predicate, GetPredName, [variable(X, context_init)], StdGetBody,
+ Context, -1
),
StdSetItem = item_clause(StdSetItemClause),
add_item_pass_3(StdGetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2089,14 +2088,9 @@
StdSetBody = goal_list_to_conj(Context,
[CallLock, StdSetCallUnsafeSet, CallUnlock]),
- StdSetItemClause = item_clause_info(
- compiler(mutable_decl),
- ProgVarSet0,
- pf_predicate,
- SetPredName,
- [variable(X, context_init)],
- StdSetBody,
- Context
+ StdSetItemClause = item_clause_info(compiler(mutable_decl), ProgVarSet0,
+ pf_predicate, SetPredName, [variable(X, context_init)], StdSetBody,
+ Context, -1
),
StdGetItem = item_clause(StdGetItemClause),
add_item_pass_3(StdSetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2111,14 +2105,10 @@
purity_pure, GetBody) - Context,
Ctxt = context_init,
- IOGetItemClause = item_clause_info(
- compiler(mutable_decl),
- ProgVarSet,
- pf_predicate,
- GetPredName,
+ IOGetItemClause = item_clause_info(compiler(mutable_decl), ProgVarSet,
+ pf_predicate, GetPredName,
[variable(X, Ctxt), variable(IO, Ctxt), variable(IO, Ctxt)],
- IOGetBody,
- Context
+ IOGetBody, Context, -1
),
IOGetItem = item_clause(IOGetItemClause),
add_item_pass_3(IOGetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2131,14 +2121,10 @@
IOSetBody = StdSetBody,
- IOSetItemClause = item_clause_info(
- compiler(mutable_decl),
- ProgVarSet,
- pf_predicate,
- SetPredName,
+ IOSetItemClause = item_clause_info(compiler(mutable_decl), ProgVarSet,
+ pf_predicate, SetPredName,
[variable(X, Ctxt), variable(IO, Ctxt), variable(IO, Ctxt)],
- IOSetBody,
- Context
+ IOSetBody, Context, -1
),
IOSetItem = item_clause(IOSetItemClause),
add_item_pass_3(IOSetItem, !Status, !ModuleInfo, !QualInfo, !Specs)
@@ -2164,7 +2150,7 @@
InitPredArity = 0,
InitItemInitialise = item_initialise_info(compiler(mutable_decl),
- InitPredName, InitPredArity, Context),
+ InitPredName, InitPredArity, Context, -1),
InitItem = item_initialise(InitItemInitialise),
add_item_pass_3(InitItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2204,7 +2190,7 @@
fc_impl_ordinary(PreInitCode, yes(Context))
),
PreInitItemPragma = item_pragma_info(compiler(mutable_decl),
- PreInitForeignProc, Context),
+ PreInitForeignProc, Context, -1),
PreInitItem = item_pragma(PreInitItemPragma),
add_item_pass_3(PreInitItem, !Status, !ModuleInfo, !QualInfo,
!Specs),
@@ -2212,22 +2198,15 @@
CallPreInitExpr =
call_expr(PreInitPredName, [], purity_impure) - Context,
CallSetPredExpr =
- call_expr(InitSetPredName, [InitTerm], purity_impure)
- - Context,
+ call_expr(InitSetPredName, [InitTerm], purity_impure) - Context,
InitClauseExpr = conj_expr(CallPreInitExpr, CallSetPredExpr)
- Context
),
% See the comments for prog_io.parse_mutable_decl for the reason
% why we _must_ use MutVarset here.
- PredItemClause = item_clause_info(compiler(mutable_decl),
- MutVarset,
- pf_predicate,
- InitPredName,
- [],
- InitClauseExpr,
- Context
- ),
+ PredItemClause = item_clause_info(compiler(mutable_decl), MutVarset,
+ pf_predicate, InitPredName, [], InitClauseExpr, Context, -1),
PredItem = item_clause(PredItemClause),
add_item_pass_3(PredItem, !Status, !ModuleInfo, !QualInfo, !Specs).
@@ -2245,7 +2224,7 @@
!Status, !ModuleInfo, !QualInfo, !Specs) :-
module_info_get_name(!.ModuleInfo, ModuleName),
ItemMutable = item_mutable_info(MutableName, _Type, InitTerm, Inst,
- MutAttrs, MutVarset, Context),
+ MutAttrs, MutVarset, Context, _SeqNum),
IsConstant = mutable_var_constant(MutAttrs),
(
IsConstant = yes,
@@ -2295,7 +2274,7 @@
fc_impl_ordinary(GetCode, yes(Context))
),
ConstantGetItemPragma = item_pragma_info(compiler(mutable_decl),
- ConstantGetForeignProc, Context),
+ ConstantGetForeignProc, Context, -1),
ConstantGetItem = item_pragma(ConstantGetItemPragma),
add_item_pass_3(ConstantGetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2310,7 +2289,7 @@
fc_impl_ordinary(SetCode, yes(Context))
),
ConstantSetItemPragma = item_pragma_info(compiler(mutable_decl),
- ConstantSetForeignProc, Context),
+ ConstantSetForeignProc, Context, -1),
ConstantSetItem = item_pragma(ConstantSetItemPragma),
add_item_pass_3(ConstantSetItem, !Status, !ModuleInfo, !QualInfo, !Specs).
@@ -2356,7 +2335,7 @@
fc_impl_ordinary(GetCode, yes(Context))
),
GetItemPragma = item_pragma_info(compiler(mutable_decl), GetForeignProc,
- Context),
+ Context, -1),
GetItem = item_pragma(GetItemPragma),
add_item_pass_3(GetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2382,7 +2361,7 @@
fc_impl_ordinary(SetCode, yes(Context))
),
SetItemPragma = item_pragma_info(compiler(mutable_decl), SetForeignProc,
- Context),
+ Context, -1),
SetItem = item_pragma(SetItemPragma),
add_item_pass_3(SetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2400,15 +2379,10 @@
IOGetBody = promise_purity_expr(dont_make_implicit_promises,
purity_pure, CallSemipureGet) - Context,
- IOGetItemClause = item_clause_info(
- compiler(mutable_decl),
- ProgVarSet,
- pf_predicate,
- GetPredName,
+ IOGetItemClause = item_clause_info(compiler(mutable_decl), ProgVarSet,
+ pf_predicate, GetPredName,
[variable(X, Ctxt), variable(IO, Ctxt), variable(IO, Ctxt)],
- IOGetBody,
- Context
- ),
+ IOGetBody, Context, -1),
IOGetItem = item_clause(IOGetItemClause),
add_item_pass_3(IOGetItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2419,15 +2393,10 @@
% stage 2.)
CallImpureSet = call_expr(SetPredName, [variable(X, Context)],
purity_impure) - Context,
- IOSetItemClause = item_clause_info(
- compiler(mutable_decl),
- ProgVarSet,
- pf_predicate,
- SetPredName,
+ IOSetItemClause = item_clause_info(compiler(mutable_decl), ProgVarSet,
+ pf_predicate, SetPredName,
[variable(X, Ctxt), variable(IO, Ctxt), variable(IO, Ctxt)],
- CallImpureSet,
- Context
- ),
+ CallImpureSet, Context, -1),
IOSetItem = item_clause(IOSetItemClause),
add_item_pass_3(IOSetItem, !Status, !ModuleInfo, !QualInfo, !Specs)
;
@@ -2468,7 +2437,7 @@
InitPredName = mutable_init_pred_sym_name(ModuleName, MutableName),
InitPredArity = 0,
InitItemInitialise = item_initialise_info(compiler(mutable_decl),
- InitPredName, InitPredArity, Context),
+ InitPredName, InitPredArity, Context, -1),
InitItem = item_initialise(InitItemInitialise),
add_item_pass_3(InitItem, !Status, !ModuleInfo, !QualInfo, !Specs),
@@ -2476,13 +2445,10 @@
%
% See the comments for prog_io.parse_mutable_decl for the reason
% why we _must_ use MutVarset here.
- PredItemClause = item_clause_info(compiler(mutable_decl),
- MutVarset,
- pf_predicate,
- InitPredName,
- [],
+ PredItemClause = item_clause_info(compiler(mutable_decl), MutVarset,
+ pf_predicate, InitPredName, [],
call_expr(InitSetPredName, [InitTerm], purity_impure) - Context,
- Context
+ Context, -1
),
PredItem = item_clause(PredItemClause),
add_item_pass_3(PredItem, !Status, !ModuleInfo, !QualInfo, !Specs).
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.331
diff -u -b -r1.331 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m 16 Jul 2008 03:30:28 -0000 1.331
+++ compiler/mercury_to_mercury.m 16 Jul 2008 03:41:20 -0000
@@ -545,7 +545,7 @@
mercury_output_item_type_defn(UnqualifiedItemNames, ItemTypeDefn, !IO) :-
ItemTypeDefn = item_type_defn_info(VarSet, Name0, Args, TypeDefn, _Cond,
- Context),
+ Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, Name0, Name),
maybe_output_line_number(Context, !IO),
mercury_output_type_defn(VarSet, Name, Args, TypeDefn, Context, !IO).
@@ -555,7 +555,7 @@
mercury_output_item_inst_defn(UnqualifiedItemNames, ItemInstDefn, !IO) :-
ItemInstDefn = item_inst_defn_info(VarSet, Name0, Args, InstDefn, _Cond,
- Context),
+ Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, Name0, Name1),
% If the unqualified name is a builtin inst, then output the qualified
% name. This prevents the compiler giving an error about redefining
@@ -573,7 +573,7 @@
mercury_output_item_mode_defn(UnqualifiedItemNames, ItemModeDefn, !IO) :-
ItemModeDefn = item_mode_defn_info(VarSet, Name0, Args, ModeDefn, _Cond,
- Context),
+ Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, Name0, Name),
maybe_output_line_number(Context, !IO),
mercury_format_mode_defn(VarSet, Name, Args, ModeDefn, Context, !IO).
@@ -584,7 +584,7 @@
mercury_output_item_pred_decl(UnqualifiedItemNames, ItemPredDecl, !IO) :-
ItemPredDecl = item_pred_decl_info(_Origin, TypeVarSet, InstVarSet,
ExistQVars, PredOrFunc, PredName0, TypesAndModes, WithType, WithInst,
- Det, _Cond, Purity, ClassContext, Context),
+ Det, _Cond, Purity, ClassContext, Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, PredName0, PredName),
maybe_output_line_number(Context, !IO),
(
@@ -610,7 +610,7 @@
mercury_output_item_mode_decl(UnqualifiedItemNames, ItemModeDecl, !IO) :-
ItemModeDecl = item_mode_decl_info(VarSet, PredOrFunc, PredName0, Modes,
- WithInst, MaybeDet, _Cond, Context),
+ WithInst, MaybeDet, _Cond, Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, PredName0, PredName),
maybe_output_line_number(Context, !IO),
(
@@ -631,7 +631,7 @@
io::di, io::uo) is det.
mercury_output_item_module_defn(_, ItemModuleDefn, !IO) :-
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _SeqNum),
maybe_output_line_number(Context, !IO),
mercury_output_module_defn(ModuleDefn, Context, !IO).
@@ -640,7 +640,7 @@
mercury_output_item_clause(UnqualifiedItemNames, ItemClause, !IO) :-
ItemClause = item_clause_info(_, VarSet, PredOrFunc, PredName0, Args,
- Body, Context),
+ Body, Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, PredName0, PredName),
maybe_output_line_number(Context, !IO),
(
@@ -658,7 +658,7 @@
io::di, io::uo) is det.
mercury_output_item_pragma(_UnqualifiedItemNames, ItemPragma, !IO) :-
- ItemPragma = item_pragma_info(_, Pragma, Context),
+ ItemPragma = item_pragma_info(_, Pragma, Context, _SeqNum),
maybe_output_line_number(Context, !IO),
(
Pragma = pragma_source_file(SourceFile),
@@ -872,7 +872,7 @@
mercury_output_item_promise(_, ItemPromise, !IO) :-
ItemPromise = item_promise_info(PromiseType, Goal0, VarSet, UnivVars,
- _Context),
+ _Context, _SeqNum),
Indent = 1,
(
PromiseType = promise_type_true,
@@ -913,7 +913,7 @@
mercury_output_item_typeclass(UnqualifiedItemNames, ItemTypeClass, !IO) :-
ItemTypeClass = item_typeclass_info(Constraints, FunDeps, ClassName0,
- Vars, Interface, VarSet, _Context),
+ Vars, Interface, VarSet, _Context, _SeqNum),
maybe_unqualify_sym_name(UnqualifiedItemNames, ClassName0, ClassName),
io.write_string(":- typeclass ", !IO),
@@ -945,7 +945,7 @@
mercury_output_item_instance(_, ItemInstance, !IO) :-
ItemInstance = item_instance_info(Constraints, ClassName, Types, Body,
- VarSet, _InstanceModuleName, _),
+ VarSet, _InstanceModuleName, _Context, _SeqNum),
io.write_string(":- instance ", !IO),
% We put an extra set of brackets around the class name in case
% the name is an operator.
@@ -972,7 +972,8 @@
io::di, io::uo) is det.
mercury_output_item_initialise(_, ItemInitialise, !IO) :-
- ItemInitialise = item_initialise_info(_, PredSymName, Arity, _),
+ ItemInitialise = item_initialise_info(_, PredSymName, Arity, _Context,
+ _SeqNum),
io.write_string(":- initialise ", !IO),
mercury_output_sym_name(PredSymName, !IO),
io.write_string("/", !IO),
@@ -983,7 +984,8 @@
io::di, io::uo) is det.
mercury_output_item_finalise(_, ItemFinalise, !IO) :-
- ItemFinalise = item_finalise_info(_, PredSymName, Arity, _),
+ ItemFinalise = item_finalise_info(_, PredSymName, Arity, _Context,
+ _SeqNum),
io.write_string(":- finalise ", !IO),
mercury_output_sym_name(PredSymName, !IO),
io.write_string("/", !IO),
@@ -995,7 +997,7 @@
mercury_output_item_mutable(_, ItemMutable, !IO) :-
ItemMutable = item_mutable_info(Name, Type, InitTerm, Inst, Attrs,
- MutVarset, _Context),
+ MutVarset, _Context, _SeqNum),
io.write_string(":- mutable(", !IO),
io.write_string(Name, !IO),
io.write_string(", ", !IO),
@@ -1106,7 +1108,7 @@
output_instance_method_clause(Name1, ItemClause, !IO) :-
ItemClause = item_clause_info(_, VarSet, PredOrFunc, _PredName,
- HeadTerms, Body, Context),
+ HeadTerms, Body, Context, _SeqNum),
(
PredOrFunc = pf_predicate,
mercury_output_pred_clause(VarSet, Name1, HeadTerms, Body, Context,
Index: compiler/module_imports.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_imports.m,v
retrieving revision 1.1
diff -u -b -r1.1 module_imports.m
--- compiler/module_imports.m 21 Jul 2008 03:10:11 -0000 1.1
+++ compiler/module_imports.m 24 Jul 2008 06:42:37 -0000
@@ -309,7 +309,7 @@
list.member(Item, Items),
Item = item_pred_decl(ItemPredDecl),
ItemPredDecl = item_pred_decl_info(_, _, _, _, pf_predicate, Name,
- [_, _], WithType, _, _, _, _, _, _),
+ [_, _], WithType, _, _, _, _, _, _, _),
unqualify_name(Name) = "main",
% XXX We should allow `main/2' to be declared using `with_type`,
@@ -358,7 +358,7 @@
get_dependencies_implementation([Item | Items],
!IntImportDeps, !IntUseDeps, !ImpImportDeps, !ImpUseDeps) :-
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_interface ->
get_dependencies_interface(Items,
!IntImportDeps, !IntUseDeps, !ImpImportDeps, !ImpUseDeps)
@@ -389,7 +389,7 @@
get_dependencies_interface([Item | Items],
!IntImportDeps, !IntUseDeps, !ImpImportDeps, !ImpUseDeps) :-
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_implementation ->
get_dependencies_implementation(Items,
!IntImportDeps, !IntUseDeps, !ImpImportDeps, !ImpUseDeps)
@@ -516,7 +516,7 @@
!ItemsNeedTablingStatistics, !ItemsNeedSTM) :-
(
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
Pragma = pragma_tabled(_, _, _, _, _, MaybeAttributes)
->
!:ItemsNeedTabling = yes,
@@ -646,7 +646,7 @@
get_fact_table_dependencies_2([Item | Items], !Deps) :-
(
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
Pragma = pragma_fact_table(_SymName, _Arity, FileName)
->
!:Deps = [FileName | !.Deps]
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.167
diff -u -b -r1.167 module_qual.m
--- compiler/module_qual.m 21 Jul 2008 03:10:11 -0000 1.167
+++ compiler/module_qual.m 21 Jul 2008 03:23:20 -0000
@@ -263,7 +263,7 @@
collect_mq_info([Item | Items], !Info) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _SeqNum),
ModuleDefn = md_transitively_imported
->
% Don't process the transitively imported items (from `.int2' files).
@@ -279,7 +279,7 @@
collect_mq_info_item(Item, !Info) :-
(
Item = item_type_defn(ItemTypeDefn),
- ItemTypeDefn = item_type_defn_info(_, SymName, Params, _, _, _),
+ ItemTypeDefn = item_type_defn_info(_, SymName, Params, _, _, _, _),
( mq_info_get_import_status(!.Info, mq_status_abstract_imported) ->
% This item is not visible in the current module.
true
@@ -296,7 +296,7 @@
)
;
Item = item_inst_defn(ItemInstDefn),
- ItemInstDefn = item_inst_defn_info(_, SymName, Params, _, _, _),
+ ItemInstDefn = item_inst_defn_info(_, SymName, Params, _, _, _, _),
( mq_info_get_import_status(!.Info, mq_status_abstract_imported) ->
% This item is not visible in the current module.
true
@@ -309,7 +309,7 @@
)
;
Item = item_mode_defn(ItemModeDefn),
- ItemModeDefn = item_mode_defn_info(_, SymName, Params, _, _, _),
+ ItemModeDefn = item_mode_defn_info(_, SymName, Params, _, _, _, _),
( mq_info_get_import_status(!.Info, mq_status_abstract_imported) ->
% This item is not visible in the current module.
true
@@ -322,12 +322,12 @@
)
;
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
process_module_defn(ModuleDefn, !Info)
;
Item = item_promise(ItemPromise),
ItemPromise = item_promise_info(_PromiseType, Goal, _ProgVarSet,
- _UnivVars, _Context),
+ _UnivVars, _Context, _SeqNum),
process_assert(Goal, SymNames, Success),
(
Success = yes,
@@ -342,7 +342,7 @@
)
;
Item = item_typeclass(ItemTypeClass),
- ItemTypeClass = item_typeclass_info(_, _, SymName, Params, _, _, _),
+ ItemTypeClass = item_typeclass_info(_, _, SymName, Params, _, _, _, _),
( mq_info_get_import_status(!.Info, mq_status_abstract_imported) ->
% This item is not visible in the current module.
true
@@ -686,50 +686,50 @@
;
Item0 = item_type_defn(ItemTypeDefn0),
ItemTypeDefn0 = item_type_defn_info(TVarSet, SymName, Params,
- TypeDefn0, C, Context),
+ TypeDefn0, C, Context, SeqNum),
list.length(Params, Arity),
mq_info_set_error_context(mqec_type(mq_id(SymName, Arity)) - Context,
!Info),
qualify_type_defn(TypeDefn0, TypeDefn, !Info, !Specs),
ItemTypeDefn = item_type_defn_info(TVarSet, SymName, Params,
- TypeDefn, C, Context),
+ TypeDefn, C, Context, SeqNum),
Item = item_type_defn(ItemTypeDefn),
Continue = yes
;
Item0 = item_inst_defn(ItemInstDefn0),
ItemInstDefn0 = item_inst_defn_info(A, SymName, Params, InstDefn0, C,
- Context),
+ Context, SeqNum),
list.length(Params, Arity),
mq_info_set_error_context(mqec_inst(mq_id(SymName, Arity)) - Context,
!Info),
qualify_inst_defn(InstDefn0, InstDefn, !Info, !Specs),
ItemInstDefn = item_inst_defn_info(A, SymName, Params, InstDefn, C,
- Context),
+ Context, SeqNum),
Item = item_inst_defn(ItemInstDefn),
Continue = yes
;
Item0 = item_mode_defn(ItemModeDefn0),
ItemModeDefn0 = item_mode_defn_info(A, SymName, Params, ModeDefn0, C,
- Context),
+ Context, SeqNum),
list.length(Params, Arity),
mq_info_set_error_context(mqec_mode(mq_id(SymName, Arity)) - Context,
!Info),
qualify_mode_defn(ModeDefn0, ModeDefn, !Info, !Specs),
ItemModeDefn = item_mode_defn_info(A, SymName, Params, ModeDefn, C,
- Context),
+ Context, SeqNum),
Item = item_mode_defn(ItemModeDefn),
Continue = yes
;
Item0 = item_module_defn(ItemModuleDefn0),
- ItemModuleDefn0 = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn0 = item_module_defn_info(ModuleDefn, Context, SeqNum),
update_import_status(ModuleDefn, !Info, Continue),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn)
;
Item0 = item_pred_decl(ItemPredDecl0),
ItemPredDecl0 = item_pred_decl_info(Origin, A, IVs, B, PredOrFunc,
SymName, TypesAndModes0, WithType0, WithInst0, C, D, E,
- Constraints0, Context),
+ Constraints0, Context, SeqNum),
list.length(TypesAndModes0, Arity),
mq_info_set_error_context(
mqec_pred_or_func(PredOrFunc, mq_id(SymName, Arity)) - Context,
@@ -740,13 +740,13 @@
map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !Specs),
ItemPredDecl = item_pred_decl_info(Origin, A, IVs, B, PredOrFunc,
SymName, TypesAndModes, WithType, WithInst, C, D, E,
- Constraints, Context),
+ Constraints, Context, SeqNum),
Item = item_pred_decl(ItemPredDecl),
Continue = yes
;
Item0 = item_mode_decl(ItemModeDecl0),
ItemModeDecl0 = item_mode_decl_info(A, PredOrFunc, SymName, Modes0,
- WithInst0, C, D, Context),
+ WithInst0, C, D, Context, SeqNum),
list.length(Modes0, Arity),
mq_info_set_error_context(
mqec_pred_or_func_mode(PredOrFunc, mq_id(SymName, Arity))
@@ -755,15 +755,15 @@
qualify_mode_list(Modes0, Modes, !Info, !Specs),
map_fold2_maybe(qualify_inst, WithInst0, WithInst, !Info, !Specs),
ItemModeDecl = item_mode_decl_info(A, PredOrFunc, SymName, Modes,
- WithInst, C, D, Context),
+ WithInst, C, D, Context, SeqNum),
Item = item_mode_decl(ItemModeDecl),
Continue = yes
;
Item0 = item_pragma(ItemPragma0),
- ItemPragma0 = item_pragma_info(Origin, Pragma0, Context),
+ ItemPragma0 = item_pragma_info(Origin, Pragma0, Context, SeqNum),
mq_info_set_error_context(mqec_pragma - Context, !Info),
qualify_pragma(Pragma0, Pragma, !Info, !Specs),
- ItemPragma = item_pragma_info(Origin, Pragma, Context),
+ ItemPragma = item_pragma_info(Origin, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
Continue = yes
;
@@ -777,7 +777,7 @@
;
Item0 = item_typeclass(ItemTypeClass0),
ItemTypeClass0 = item_typeclass_info(Constraints0, FunDeps,
- Name, Vars, Interface0, VarSet, Context),
+ Name, Vars, Interface0, VarSet, Context, SeqNum),
list.length(Vars, Arity),
mq_info_set_error_context(mqec_class(mq_id(Name, Arity)) - Context,
!Info),
@@ -791,13 +791,13 @@
Interface = class_interface_concrete(Methods)
),
ItemTypeClass = item_typeclass_info(Constraints, FunDeps,
- Name, Vars, Interface, VarSet, Context),
+ Name, Vars, Interface, VarSet, Context, SeqNum),
Item = item_typeclass(ItemTypeClass),
Continue = yes
;
Item0 = item_instance(ItemInstance0),
ItemInstance0 = item_instance_info(Constraints0, Name0, Types0,
- Body0, VarSet, ModName, Context),
+ Body0, VarSet, ModName, Context, SeqNum),
list.length(Types0, Arity),
Id = mq_id(Name0, Arity),
mq_info_set_error_context(mqec_instance(Id) - Context, !Info),
@@ -809,7 +809,7 @@
qualify_type_list(Types0, Types, !Info, !Specs),
qualify_instance_body(Name, Body0, Body),
ItemInstance = item_instance_info(Constraints, Name, Types,
- Body, VarSet, ModName, Context),
+ Body, VarSet, ModName, Context, SeqNum),
Item = item_instance(ItemInstance),
Continue = yes
;
@@ -823,12 +823,12 @@
;
Item0 = item_mutable(ItemMutable0),
ItemMutable0 = item_mutable_info(Name, Type0, InitTerm, Inst0,
- Attrs, Varset, Context),
+ Attrs, Varset, Context, SeqNum),
mq_info_set_error_context(mqec_mutable(Name) - Context, !Info),
qualify_type(Type0, Type, !Info, !Specs),
qualify_inst(Inst0, Inst, !Info, !Specs),
ItemMutable = item_mutable_info(Name, Type, InitTerm, Inst,
- Attrs, Varset, Context),
+ Attrs, Varset, Context, SeqNum),
Item = item_mutable(ItemMutable),
Continue = yes
).
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.449
diff -u -b -r1.449 modules.m
--- compiler/modules.m 21 Jul 2008 03:10:11 -0000 1.449
+++ compiler/modules.m 25 Jul 2008 11:51:07 -0000
@@ -480,7 +480,7 @@
handle_mutable_in_private_interface(ModuleName, Item, !Items) :-
( Item = item_mutable(ItemMutable) ->
ItemMutable = item_mutable_info(MutableName, Type, _Value, Inst, Attrs,
- _Varset, Context),
+ _Varset, Context, _SeqNum),
ConstantInterface = mutable_var_constant(Attrs),
(
ConstantInterface = yes,
@@ -623,7 +623,7 @@
strip_imported_items_2([], !RevItems).
strip_imported_items_2([Item | Items], !RevItems) :-
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
(
( ModuleDefn = md_imported(_)
; ModuleDefn = md_used(_)
@@ -661,7 +661,7 @@
strip_assertions([Head | Tail], Items) :-
(
Head = item_promise(ItemPromise),
- ItemPromise = item_promise_info(promise_type_true, _, _, _, _)
+ ItemPromise = item_promise_info(promise_type_true, _, _, _, _, _)
->
strip_assertions(Tail, Items)
;
@@ -789,7 +789,7 @@
wrap_import_module_spec(ModuleSpecInDefn) = Item :-
ModuleSpecInDefn = module_specifier_in_defn(Context, ModuleSpec),
ModuleDefn = md_import([ModuleSpec]),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, -1),
Item = item_module_defn(ItemModuleDefn).
:- func wrap_use_module_spec(module_specifier_in_defn) = item.
@@ -797,7 +797,7 @@
wrap_use_module_spec(ModuleSpecInDefn) = Item :-
ModuleSpecInDefn = module_specifier_in_defn(Context, ModuleSpec),
ModuleDefn = md_use([ModuleSpec]),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, -1),
Item = item_module_defn(ItemModuleDefn).
:- pred do_standardize_impl_items(list(item)::in, bool::in, bool::out,
@@ -811,7 +811,7 @@
do_standardize_impl_items([Item | Items], !Unexpected,
!RevRemainderItems, !ImportSpecs, !UseSpecs, !TypeDefns) :-
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _),
(
ModuleDefn = md_import(ImportModules),
( ImportModules = [ModuleSpec] ->
@@ -878,8 +878,8 @@
insert_type_defn(New, [], [New]).
insert_type_defn(New, [Head | Tail], Result) :-
- New = item_type_defn_info(_, NewSymName, NewParams, _, _, _),
- Head = item_type_defn_info(_, HeadSymName, HeadParams, _, _, _),
+ New = item_type_defn_info(_, NewSymName, NewParams, _, _, _, _),
+ Head = item_type_defn_info(_, HeadSymName, HeadParams, _, _, _, _),
compare(CompareSymName, NewSymName, HeadSymName),
(
(
@@ -935,7 +935,7 @@
is_not_unnecessary_impl_import(NecessaryImports, Item) :-
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
(
( ModuleDefn = md_use(Modules)
; ModuleDefn = md_import(Modules)
@@ -969,7 +969,7 @@
is_not_unnecessary_impl_type(NecessaryTypeCtors, Item) :-
( Item = item_type_defn(ItemTypeDefn) ->
- ItemTypeDefn = item_type_defn_info(_, SymName, Params, _, _, _),
+ ItemTypeDefn = item_type_defn_info(_, SymName, Params, _, _, _, _),
TypeCtor = type_ctor(SymName, list.length(Params)),
set.member(TypeCtor, NecessaryTypeCtors)
;
@@ -1142,7 +1142,7 @@
!RevIntItems, !RevImplItems, !IntTypesMap, !ImplTypesMap) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
(
ModuleDefn = md_interface,
NewInInterface = yes
@@ -1155,7 +1155,7 @@
;
Item = item_type_defn(ItemTypeDefn)
->
- ItemTypeDefn = item_type_defn_info(_, Name, Args, Body, _, _),
+ ItemTypeDefn = item_type_defn_info(_, Name, Args, Body, _, _, _),
TypeCtor = type_ctor(Name, length(Args)),
(
!.InInterface = yes,
@@ -1292,7 +1292,7 @@
foreign_enum_is_local(TypeDefnMap, Item) :-
(
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
Pragma = pragma_foreign_enum(_Lang, TypeName, TypeArity, _Values)
->
% We only add a pragma foreign_enum pragma to the interface file
@@ -1320,7 +1320,7 @@
check_for_clauses_in_interface(Items0, Items, !Specs)
;
Item0 = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, Context),
+ ItemPragma = item_pragma_info(_, Pragma, Context, _),
AllowedInInterface = pragma_allowed_in_interface(Pragma),
(
AllowedInInterface = no,
@@ -1383,7 +1383,7 @@
split_clauses_and_decls([Item | Items], !:ClauseItems, !:InterfaceItems) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_interface
; ModuleDefn = md_implementation
)
@@ -1394,7 +1394,7 @@
Item = item_clause(_)
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
pragma_allowed_in_interface(Pragma) = no
;
Item = item_initialise(_)
@@ -1491,7 +1491,7 @@
Item = item_nothing(_)
;
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
ModuleDefn \= md_include_module(_)
)
->
@@ -1568,13 +1568,13 @@
InterfaceItems0, MaybeOldItems, VersionNumbers),
VersionNumberItemModuleDefn = item_module_defn_info(
md_version_numbers(ModuleName, VersionNumbers),
- term.context_init),
+ term.context_init, -1),
VersionNumberItem = item_module_defn(VersionNumberItemModuleDefn),
(
InterfaceItems0 = [FirstItem | InterfaceItems1],
FirstItem = item_module_defn(FirstItemModuleDefn),
FirstItemModuleDefn =
- item_module_defn_info(FirstModuleDefn, _),
+ item_module_defn_info(FirstModuleDefn, _, _),
FirstModuleDefn = md_interface
->
InterfaceItems = [FirstItem, VersionNumberItem
@@ -1864,7 +1864,7 @@
Module = Module0 ^ items := Items.
make_pseudo_decl(PseudoDecl) = Item :-
- ItemModuleDefn = item_module_defn_info(PseudoDecl, term.context_init),
+ ItemModuleDefn = item_module_defn_info(PseudoDecl, term.context_init, -1),
Item = item_module_defn(ItemModuleDefn).
%-----------------------------------------------------------------------------%
@@ -2807,7 +2807,7 @@
% so we need to search the item list again to find them.
FindImports = (pred(Item::in, ImportInfo::out) is semidet :-
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _),
(
ModuleDefn = md_import(ItemModuleSpecs),
DeclName = "import_module"
@@ -2955,7 +2955,7 @@
replace_section_decl(IntStatusItem, ImpStatusItem, Item0, Item) :-
(
Item0 = item_module_defn(ItemModuleDefn0),
- ItemModuleDefn0 = item_module_defn_info(ModuleDefn0, _),
+ ItemModuleDefn0 = item_module_defn_info(ModuleDefn0, _, _),
(
ModuleDefn0 = md_interface,
ItemPrime = IntStatusItem
@@ -2991,7 +2991,7 @@
get_children_2([Item | Items], !IncludeDeps) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
ModuleDefn = md_include_module(Modules)
->
!:IncludeDeps = !.IncludeDeps ++ Modules
@@ -3016,7 +3016,7 @@
get_accessible_children_2(_, [], !IncludeDeps).
get_accessible_children_2(!.Visible, [Item | Items], !IncludeDeps) :-
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
(
( ModuleDefn = md_abstract_imported
; ModuleDefn = md_opt_imported
@@ -3115,7 +3115,7 @@
% Check for a `module' declaration, which signals the start
% of a nested module.
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
ModuleDefn = md_module(SubModuleName)
->
% Parse in the items for the nested submodule.
@@ -3133,14 +3133,14 @@
% Replace the nested submodule with an `include_module' declaration.
IncludeSubModModuleDefn = md_include_module([SubModuleName]),
IncludeSubModItemModuleDefn = item_module_defn_info(
- IncludeSubModModuleDefn, Context),
+ IncludeSubModModuleDefn, Context, SeqNum),
IncludeSubModItem = item_module_defn(IncludeSubModItemModuleDefn),
ThisModuleItems = [IncludeSubModItem | ThisModuleItems0],
OtherItems = Items3
;
% Check for a matching `end_module' declaration.
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _Context, _),
ModuleDefn = md_end_module(EndModuleName),
EndModuleName = ModuleName
->
@@ -3155,7 +3155,8 @@
% interface section, and report an error if there is an
% `implementation' section inside an `interface' section.
( Item = item_module_defn(ItemModuleDefn) ->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context,
+ _SeqNum),
( ModuleDefn = md_interface ->
!:InInterface = yes
; ModuleDefn = md_implementation ->
@@ -3249,7 +3250,7 @@
is_duplicate_error(Duplicates, Items, SubModuleName - Context) :-
list.member(Item, Items),
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _),
(
ModuleDefn = md_module(SubModuleName)
;
@@ -3346,7 +3347,7 @@
make_foreign_import(ModuleName, Lang) = Item :-
Origin = compiler(foreign_imports),
Pragma = pragma_foreign_import_module(Lang, ModuleName),
- ItemPragma = item_pragma_info(Origin, Pragma, term.context_init),
+ ItemPragma = item_pragma_info(Origin, Pragma, term.context_init, -1),
Item = item_pragma(ItemPragma).
get_foreign_self_imports(Items, Langs) :-
@@ -3369,7 +3370,7 @@
!.InInterface, !RevIntItems, AddImplItem, !RevImplItems) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_interface
; ModuleDefn = md_implementation
; ModuleDefn = md_imported(_)
@@ -3491,7 +3492,7 @@
Include = yes
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
% XXX This if-then-else should be a switch, or (even better)
% we should take pragma_foreign_import_modules out of the pragma items
% and given them their own item type.
@@ -3567,7 +3568,7 @@
)
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
(
Pragma = pragma_import(_, _, _, _, _),
% `:- pragma import' is only supported for C.
@@ -3642,7 +3643,7 @@
Include = yes
;
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
(
% XXX Some of these should yield an exception.
( ModuleDefn = md_module(_)
@@ -3668,7 +3669,7 @@
)
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
(
( Pragma = pragma_foreign_import_module(_, _)
; Pragma = pragma_foreign_enum(_, _, _, _)
@@ -3847,7 +3848,7 @@
(pred(ThisItem::in) is semidet :-
\+ (
ThisItem = item_pragma(ThisItemPragma),
- ThisItemPragma = item_pragma_info(_, Pragma, _),
+ ThisItemPragma = item_pragma_info(_, Pragma, _, _),
Pragma = pragma_foreign_import_module(_, _)
)
),
@@ -3881,7 +3882,7 @@
interface_or_import_marker(Item) :-
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_interface
; ModuleDefn = md_implementation
).
@@ -3895,7 +3896,7 @@
import_or_use_item(Item) :-
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_import(_)
; ModuleDefn = md_use(_)
).
@@ -3919,28 +3920,28 @@
(
CurPos = in_interface,
Item1 = item_module_defn(ItemModuleDefn1),
- ItemModuleDefn1 = item_module_defn_info(md_implementation, _),
+ ItemModuleDefn1 = item_module_defn_info(md_implementation, _, _),
Item2 = item_module_defn(ItemModuleDefn2),
- ItemModuleDefn2 = item_module_defn_info(md_interface, _)
+ ItemModuleDefn2 = item_module_defn_info(md_interface, _, _)
->
filter_unnecessary_flips(Items0, CurPos, Items)
;
CurPos = in_implementation,
Item1 = item_module_defn(ItemModuleDefn1),
- ItemModuleDefn1 = item_module_defn_info(md_interface, _),
+ ItemModuleDefn1 = item_module_defn_info(md_interface, _, _),
Item2 = item_module_defn(ItemModuleDefn2),
- ItemModuleDefn2 = item_module_defn_info(md_implementation, _)
+ ItemModuleDefn2 = item_module_defn_info(md_implementation, _, _)
->
filter_unnecessary_flips(Items0, CurPos, Items)
;
(
Item1 = item_module_defn(ItemModuleDefn1),
- ItemModuleDefn1 = item_module_defn_info(md_implementation, _)
+ ItemModuleDefn1 = item_module_defn_info(md_implementation, _, _)
->
NextPos = in_implementation
;
Item1 = item_module_defn(ItemModuleDefn1),
- ItemModuleDefn1 = item_module_defn_info(md_interface, _)
+ ItemModuleDefn1 = item_module_defn_info(md_interface, _, _)
->
NextPos = in_interface
;
@@ -3996,7 +3997,7 @@
:- pred import_or_use(item::in) is semidet.
import_or_use(item_module_defn(ItemModuleDefn)) :-
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
( ModuleDefn = md_import(_)
; ModuleDefn = md_use(_)
).
@@ -4022,11 +4023,11 @@
reorderable_item(Item) = Reorderable :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
Reorderable = reorderable_module_defn(ModuleDefn)
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
Reorderable = reorderable_pragma_type(Pragma)
;
( Item = item_type_defn(_)
@@ -4125,11 +4126,11 @@
chunkable_item(Item) = Chunkable :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, _, _),
Chunkable = chunkable_module_defn(ModuleDefn)
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, Pragma, _),
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
Chunkable = chunkable_pragma_type(Pragma)
;
( Item = item_clause(_)
Index: compiler/prog_io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.293
diff -u -b -r1.293 prog_io.m
--- compiler/prog_io.m 24 Jul 2008 06:20:31 -0000 1.293
+++ compiler/prog_io.m 26 Jul 2008 08:44:57 -0000
@@ -142,24 +142,25 @@
:- pred find_module_name(file_name::in, maybe(module_name)::out,
io::di, io::uo) is det.
- % parse_item(ModuleName, VarSet, Term, MaybeItem):
+ % parse_item(ModuleName, VarSet, Term, SeqNum, MaybeItem):
%
- % Parse Term. If successful, MaybeItem is bound to the parsed item,
- % otherwise it is bound to an appropriate error message. Qualify
+ % Parse Term. If successful, bind MaybeItem to the parsed item,
+ % otherwise bind it to an appropriate error message. Qualify
% appropriate parts of the item, with ModuleName as the module name.
+ % Use SeqNum as the item's sequence number.
%
-:- pred parse_item(module_name::in, varset::in, term::in, maybe1(item)::out)
- is det.
+:- pred parse_item(module_name::in, varset::in, term::in, int::in,
+ maybe1(item)::out) is det.
- % parse_decl(ModuleName, VarSet, Term, Result):
+ % parse_decl(ModuleName, VarSet, Term, SeqNum, MaybeItem):
%
- % Parse Term as a declaration. If successful, Result is bound to the
+ % Parse Term as a declaration. If successful, bind MaybeItem to the
% parsed item, otherwise it is bound to an appropriate error message.
% Qualify appropriate parts of the item, with ModuleName as the module
- % name.
+ % name. Use SeqNum as the item's sequence number.
%
-:- pred parse_decl(module_name::in, varset::in, term::in, maybe1(item)::out)
- is det.
+:- pred parse_decl(module_name::in, varset::in, term::in, int::in,
+ maybe1(item)::out) is det.
% parse_type_defn_head(ModuleName, VarSet, Head, HeadResult):
%
@@ -283,6 +284,7 @@
:- import_module assoc_list.
:- import_module bool.
+:- import_module counter.
:- import_module dir.
:- import_module int.
:- import_module map.
@@ -536,7 +538,7 @@
RevItems0 = [Item | RevItemsPrime],
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, _SeqNum),
ModuleDefn = md_end_module(ModuleName)
->
RevItems = RevItemsPrime,
@@ -562,7 +564,7 @@
(
!.Items = [Item | !:Items],
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(md_module(ModuleName1), _)
+ ItemModuleDefn = item_module_defn_info(md_module(ModuleName1), _, _)
->
% Check that the end module declaration (if any) matches
% the begin module declaration.
@@ -627,8 +629,9 @@
BaseName = ""
),
file_name_to_module_name(BaseName, DefaultModuleName),
+ counter.init(1, SeqNumCounter0),
read_first_item(DefaultModuleName, FileName, _,
- ModuleName, _, _, Specs, _, !IO),
+ ModuleName, _, _, Specs, _, SeqNumCounter0, _, !IO),
MaybeModuleName = yes(ModuleName),
% XXX _NumErrors
globals.io_get_globals(Globals, !IO),
@@ -666,32 +669,37 @@
list(item)::out, list(error_spec)::out, module_error::out,
io::di, io::uo) is det.
-read_all_items(DefaultModuleName, ModuleName, Items, Specs, Error, !IO) :-
+read_all_items(DefaultModuleName, ModuleName, Items, !:Specs, !:Error, !IO) :-
+ some [!SeqNumCounter] (
+ counter.init(1, !:SeqNumCounter),
+
% Read all the items (the first one is handled specially).
io.input_stream(Stream, !IO),
io.input_stream_name(Stream, SourceFileName0, !IO),
read_first_item(DefaultModuleName, SourceFileName0, SourceFileName,
- ModuleName, RevItems0, MaybeSecondTerm, Specs0, Error0, !IO),
+ ModuleName, RevItems0, MaybeSecondTerm, !:Specs, !:Error,
+ !SeqNumCounter, !IO),
(
MaybeSecondTerm = yes(SecondTerm),
% XXX Should this be SourceFileName instead of SourceFileName0?
read_term_to_item_result(ModuleName, SourceFileName0, SecondTerm,
- MaybeSecondItem),
+ !SeqNumCounter, MaybeSecondItem),
read_items_loop_2(MaybeSecondItem, ModuleName, SourceFileName,
- RevItems0, RevItems1, Specs0, Specs1, Error0, Error1, !IO)
+ RevItems0, RevItems1, !Specs, !Error, !.SeqNumCounter, _, !IO)
;
MaybeSecondTerm = no,
read_items_loop(ModuleName, SourceFileName,
- RevItems0, RevItems1, Specs0, Specs1, Error0, Error1, !IO)
+ RevItems0, RevItems1, !Specs, !Error, !.SeqNumCounter, _, !IO)
),
% Get the end_module declaration (if any), check that it matches
% the initial module declaration (if any), and remove both of them
% from the final item list.
get_end_module(ModuleName, RevItems1, RevItems, EndModule),
- check_end_module(EndModule, Items0, Items, Specs1, Specs, Error1, Error),
- list.reverse(RevItems, Items0).
+ list.reverse(RevItems, Items0),
+ check_end_module(EndModule, Items0, Items, !Specs, !Error)
+ ).
% We need to jump through a few hoops when reading the first item,
% to allow the initial `:- module' declaration to be optional.
@@ -707,32 +715,34 @@
%
:- pred read_first_item(module_name::in, file_name::in, file_name::out,
module_name::out, list(item)::out, maybe(read_term)::out,
- list(error_spec)::out, module_error::out, io::di, io::uo) is det.
+ list(error_spec)::out, module_error::out, counter::in, counter::out,
+ io::di, io::uo) is det.
read_first_item(DefaultModuleName, !SourceFileName, ModuleName,
- Items, MaybeSecondTerm, Specs, Error, !IO) :-
+ Items, MaybeSecondTerm, Specs, Error, !SeqNumCounter, !IO) :-
% Parse the first term, treating it as occurring within the scope
% of the special "root" module (so that any `:- module' declaration
% is taken to be a non-nested module unless explicitly qualified).
parser.read_term_filename(!.SourceFileName, MaybeFirstTerm, !IO),
root_module_name(RootModuleName),
read_term_to_item_result(RootModuleName, !.SourceFileName, MaybeFirstTerm,
- MaybeFirstItem),
+ !SeqNumCounter, MaybeFirstItem),
(
% Apply and then skip `pragma source_file' decls, by calling ourselves
% recursively with the new source file name.
MaybeFirstItem = read_item_ok(FirstItem),
FirstItem = item_pragma(FirstItemPragma),
- FirstItemPragma = item_pragma_info(_,
- pragma_source_file(!:SourceFileName), _)
+ FirstItemPragma = item_pragma_info(_, Pragma, _, _),
+ Pragma = pragma_source_file(!:SourceFileName)
->
- read_first_item(DefaultModuleName, !SourceFileName,
- ModuleName, Items, MaybeSecondTerm, Specs, Error, !IO)
+ read_first_item(DefaultModuleName, !SourceFileName, ModuleName,
+ Items, MaybeSecondTerm, Specs, Error, !SeqNumCounter, !IO)
;
% Check if the first term was a `:- module' decl.
MaybeFirstItem = read_item_ok(FirstItem),
FirstItem = item_module_defn(FirstItemModuleDefn),
- FirstItemModuleDefn = item_module_defn_info(ModuleDefn, FirstContext),
+ FirstItemModuleDefn = item_module_defn_info(ModuleDefn, FirstContext,
+ _FirstItemSeqNum),
ModuleDefn = md_module(StartModuleName)
->
% If so, then check that it matches the expected module name,
@@ -800,7 +810,7 @@
make_module_decl(ModuleName, Context, Item) :-
ModuleDefn = md_module(ModuleName),
- ItemInfo = item_module_defn_info(ModuleDefn, Context),
+ ItemInfo = item_module_defn_info(ModuleDefn, Context, -1),
Item = item_module_defn(ItemInfo).
%-----------------------------------------------------------------------------%
@@ -813,22 +823,25 @@
:- pred read_items_loop(module_name::in, file_name::in,
list(item)::in, list(item)::out,
list(error_spec)::in, list(error_spec)::out,
- module_error::in, module_error::out, io::di, io::uo) is det.
+ module_error::in, module_error::out, counter::in, counter::out,
+ io::di, io::uo) is det.
-read_items_loop(ModuleName, SourceFileName, !Items, !Specs, !Error, !IO) :-
- read_item(ModuleName, SourceFileName, MaybeItem, !IO),
+read_items_loop(ModuleName, SourceFileName, !Items, !Specs, !Error,
+ !SeqNumCounter, !IO) :-
+ read_item(ModuleName, SourceFileName, MaybeItem, !SeqNumCounter, !IO),
read_items_loop_2(MaybeItem, ModuleName, SourceFileName, !Items,
- !Specs, !Error, !IO).
+ !Specs, !Error, !SeqNumCounter, !IO).
%-----------------------------------------------------------------------------%
:- pred read_items_loop_2(read_item_result::in, module_name::in,
file_name::in, list(item)::in, list(item)::out,
list(error_spec)::in, list(error_spec)::out,
- module_error::in, module_error::out, io::di, io::uo) is det.
+ module_error::in, module_error::out, counter::in, counter::out,
+ io::di, io::uo) is det.
read_items_loop_2(MaybeItemOrEOF, !.ModuleName, !.SourceFileName, !Items,
- !Specs, !Error, !IO) :-
+ !Specs, !Error, !SeqNumCounter, !IO) :-
(
MaybeItemOrEOF = read_item_eof
% If the next item was end-of-file, then we're done.
@@ -840,13 +853,13 @@
!:Specs = ItemSpecs ++ !.Specs,
!:Error = some_module_errors,
read_items_loop(!.ModuleName, !.SourceFileName, !Items,
- !Specs, !Error, !IO)
+ !Specs, !Error, !SeqNumCounter, !IO)
;
MaybeItemOrEOF = read_item_ok(Item),
read_items_loop_ok(Item, !ModuleName, !SourceFileName, !Items,
!Specs, !Error, !IO),
read_items_loop(!.ModuleName, !.SourceFileName, !Items,
- !Specs, !Error, !IO)
+ !Specs, !Error, !SeqNumCounter, !IO)
).
:- pred read_items_loop_ok(item::in, module_name::in, module_name::out,
@@ -858,7 +871,7 @@
!Specs, !Error, !IO) :-
(
Item0 = item_nothing(ItemNothing0),
- ItemNothing0 = item_nothing_info(yes(Warning), Context0)
+ ItemNothing0 = item_nothing_info(yes(Warning), Context0, NothingSeqNum)
->
Warning = item_warning(MaybeOption, Msg, Term),
(
@@ -885,7 +898,7 @@
;
Warn = no
),
- ItemNothing = item_nothing_info(no, Context0),
+ ItemNothing = item_nothing_info(no, Context0, NothingSeqNum),
Item = item_nothing(ItemNothing)
;
Item = Item0
@@ -899,14 +912,14 @@
% Then continue looping.
(
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, PragmaType, _),
- PragmaType = pragma_source_file(NewSourceFileName)
+ ItemPragma = item_pragma_info(_, Pragma, _, _),
+ Pragma = pragma_source_file(NewSourceFileName)
->
!:SourceFileName = NewSourceFileName
;
Item = item_module_defn(ItemModuleDefn)
->
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
( ModuleDefn = md_module(NestedModuleName) ->
!:ModuleName = NestedModuleName,
!:Items = [Item | !.Items]
@@ -917,16 +930,16 @@
!:ModuleName = ParentModuleName,
!:Items = [Item | !.Items]
; ModuleDefn = md_import(Modules) ->
- ImportItems = list.map(make_pseudo_import_module_decl(Context),
- Modules),
+ list.map(make_pseudo_import_module_decl(Context, SeqNum),
+ Modules, ImportItems),
!:Items = ImportItems ++ !.Items
; ModuleDefn = md_use(Modules) ->
- UseItems = list.map(make_pseudo_use_module_decl(Context),
- Modules),
+ list.map(make_pseudo_use_module_decl(Context, SeqNum),
+ Modules, UseItems),
!:Items = UseItems ++ !.Items
; ModuleDefn = md_include_module(Modules) ->
- IncludeItems = list.map(make_pseudo_include_module_decl(Context),
- Modules),
+ list.map(make_pseudo_include_module_decl(Context, SeqNum),
+ Modules, IncludeItems),
!:Items = IncludeItems ++ !.Items
;
!:Items = [Item | !.Items]
@@ -945,17 +958,18 @@
% Read_item/1 reads a single item, and if it is a valid term parses it.
%
:- pred read_item(module_name::in, file_name::in, read_item_result::out,
- io::di, io::uo) is det.
+ counter::in, counter::out, io::di, io::uo) is det.
-read_item(ModuleName, SourceFileName, MaybeItem, !IO) :-
+read_item(ModuleName, SourceFileName, MaybeItem, !SeqNumCounter, !IO) :-
parser.read_term_filename(SourceFileName, MaybeTerm, !IO),
- read_term_to_item_result(ModuleName, SourceFileName, MaybeTerm, MaybeItem).
+ read_term_to_item_result(ModuleName, SourceFileName, MaybeTerm,
+ !SeqNumCounter, MaybeItem).
:- pred read_term_to_item_result(module_name::in, string::in, read_term::in,
- read_item_result::out) is det.
+ counter::in, counter::out, read_item_result::out) is det.
read_term_to_item_result(ModuleName, FileName, ReadTermResult,
- ReadItemResult) :-
+ !SeqNumCounter, ReadItemResult) :-
(
ReadTermResult = eof,
ReadItemResult = read_item_eof
@@ -969,7 +983,8 @@
ReadItemResult = read_item_errors([Spec])
;
ReadTermResult = term(VarSet, Term),
- parse_item(ModuleName, VarSet, Term, MaybeItem),
+ counter.allocate(SeqNum, !SeqNumCounter),
+ parse_item(ModuleName, VarSet, Term, SeqNum, MaybeItem),
(
MaybeItem = ok1(Item),
ReadItemResult = read_item_ok(Item)
@@ -979,21 +994,21 @@
)
).
-parse_item(ModuleName, VarSet, Term, Result) :-
+parse_item(ModuleName, VarSet, Term, SeqNum, Result) :-
(
Term = term.functor(term.atom(":-"), [DeclTerm], _DeclContext)
->
- % It's a declaration.
- parse_decl(ModuleName, VarSet, DeclTerm, Result)
+ % Term is a declaration.
+ parse_decl(ModuleName, VarSet, DeclTerm, SeqNum, Result)
;
Term = term.functor(term.atom("-->"), [DCG_H_Term, DCG_B_Term],
DCG_Context)
->
- % It's a DCG clause.
+ % Term is a DCG clause.
parse_dcg_clause(ModuleName, VarSet, DCG_H_Term, DCG_B_Term,
- DCG_Context, Result)
+ DCG_Context, SeqNum, Result)
;
- % It's either a fact or a rule.
+ % Term is a clause; either a fact or a rule.
(
Term = term.functor(term.atom(":-"),
[HeadTermPrime, BodyTermPrime], TermContext)
@@ -1010,14 +1025,14 @@
),
varset.coerce(VarSet, ProgVarSet),
parse_clause(ModuleName, Term, HeadTerm, BodyTerm, ProgVarSet,
- ClauseContext, Result)
+ ClauseContext, SeqNum, Result)
).
:- pred parse_clause(module_name::in, term::in, term::in, term::in,
- prog_varset::in, term.context::in, maybe1(item)::out) is det.
+ prog_varset::in, term.context::in, int::in, maybe1(item)::out) is det.
parse_clause(ModuleName, Term, HeadTerm, BodyTerm0, ProgVarSet0, Context,
- MaybeItem) :-
+ SeqNum, MaybeItem) :-
GoalContextPieces = [],
parse_goal(BodyTerm0, GoalContextPieces, MaybeBodyGoal,
ProgVarSet0, ProgVarSet),
@@ -1037,7 +1052,7 @@
list.map(term.coerce, ArgTerms0 ++ [FuncResultTerm],
ProgArgTerms),
ItemClause = item_clause_info(user, ProgVarSet, pf_function,
- Name, ProgArgTerms, BodyGoal, Context),
+ Name, ProgArgTerms, BodyGoal, Context, SeqNum),
Item = item_clause(ItemClause),
MaybeItem = ok1(Item)
;
@@ -1052,7 +1067,7 @@
MaybeFunctor = ok2(Name, ArgTerms),
list.map(term.coerce, ArgTerms, ProgArgTerms),
ItemClause = item_clause_info(user, ProgVarSet, pf_predicate,
- Name, ProgArgTerms, BodyGoal, Context),
+ Name, ProgArgTerms, BodyGoal, Context, SeqNum),
Item = item_clause(ItemClause),
MaybeItem = ok1(Item)
;
@@ -1084,29 +1099,31 @@
% attributes are used on declarations where they are not allowed.
:- type decl_attrs == assoc_list(decl_attribute, term.context).
-parse_decl(ModuleName, VarSet, Term, Result) :-
- parse_attrs_and_decl(ModuleName, VarSet, Term, [], Result).
+parse_decl(ModuleName, VarSet, Term, SeqNum, MaybeItem) :-
+ parse_attrs_and_decl(ModuleName, VarSet, Term, [], SeqNum, MaybeItem).
- % parse_attrs_and_decl(ModuleName, VarSet, Term, Attributes, Result):
+ % parse_attrs_and_decl(ModuleName, VarSet, Term, Attributes, SeqNum,
+ % MaybeItem):
%
% Succeeds if Term is a declaration and binds Result to a representation
% of that declaration. Attributes is a list of enclosing declaration
% attributes, in the order innermost to outermost.
%
:- pred parse_attrs_and_decl(module_name::in, varset::in, term::in,
- decl_attrs::in, maybe1(item)::out) is det.
+ decl_attrs::in, int::in, maybe1(item)::out) is det.
-parse_attrs_and_decl(ModuleName, VarSet, Term, !.Attributes, MaybeItem) :-
+parse_attrs_and_decl(ModuleName, VarSet, Term, !.Attributes, SeqNum,
+ MaybeItem) :-
( Term = term.functor(term.atom(Functor), Args, Context) ->
(
parse_decl_attribute(Functor, Args, Attribute, SubTerm)
->
!:Attributes = [Attribute - Context | !.Attributes],
parse_attrs_and_decl(ModuleName, VarSet, SubTerm, !.Attributes,
- MaybeItem)
+ SeqNum, MaybeItem)
;
parse_attributed_decl(ModuleName, VarSet, Functor, Args,
- !.Attributes, Context, MaybeItemPrime)
+ !.Attributes, Context, SeqNum, MaybeItemPrime)
->
MaybeItemPrime = MaybeItem
;
@@ -1126,28 +1143,29 @@
).
% parse_attributed_decl(ModuleName, VarSet, Functor, Args, Attributes,
- % Context, Result):
+ % Context, SeqNum, MaybeItem):
%
- % Succeeds if Atom(Args) is a declaration and binds Result to a
+ % If Atom(Args) is a declaration, succeed and bind MaybeItem to a
% representation of that declaration. Attributes is a list of
% enclosing declaration attributes, in the order outermost to innermost.
%
:- pred parse_attributed_decl(module_name::in, varset::in, string::in,
- list(term)::in, decl_attrs::in, prog_context::in, maybe1(item)::out)
- is semidet.
+ list(term)::in, decl_attrs::in, prog_context::in, int::in,
+ maybe1(item)::out) is semidet.
parse_attributed_decl(ModuleName, VarSet, Functor, ArgTerms, Attributes,
- Context, MaybeItem) :-
+ Context, SeqNum, MaybeItem) :-
(
Functor = "type",
ArgTerms = [TypeDefnTerm],
parse_type_defn(ModuleName, VarSet, TypeDefnTerm, Attributes, Context,
- MaybeItem)
+ SeqNum, MaybeItem)
;
Functor = "inst",
ArgTerms = [InstDeclTerm],
- parse_inst_defn(ModuleName, VarSet, InstDeclTerm, Context, Result0),
- check_no_attributes(Result0, Attributes, MaybeItem)
+ parse_inst_defn(ModuleName, VarSet, InstDeclTerm, Context,
+ SeqNum, MaybeItem0),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
Functor = "mode",
ArgTerms = [SubTerm],
@@ -1155,13 +1173,11 @@
% This is the definition of a mode.
parse_condition_suffix(BodyTerm, BeforeCondTerm, Condition),
parse_mode_defn(ModuleName, VarSet, HeadTerm, BeforeCondTerm,
- ModeDefnResult),
- process_maybe1(make_mode_defn(VarSet, Condition, Context),
- ModeDefnResult, MaybeItem)
+ Condition, Context, SeqNum, MaybeItem)
;
% This is the declaration of one mode of a predicate or function.
parse_mode_decl(ModuleName, VarSet, SubTerm, Attributes,
- Context, MaybeItem)
+ Context, SeqNum, MaybeItem)
)
;
(
@@ -1173,7 +1189,7 @@
),
ArgTerms = [DeclTerm],
parse_pred_or_func_decl(PredOrFunc, ModuleName, VarSet, DeclTerm,
- Attributes, Context, MaybeItem)
+ Attributes, Context, SeqNum, MaybeItem)
;
(
Functor = "import_module",
@@ -1187,7 +1203,7 @@
),
ArgTerms = [ModuleSpecTerm],
parse_symlist_decl(parse_module_specifier(VarSet), Maker,
- ModuleSpecTerm, Attributes, Context, MaybeItem)
+ ModuleSpecTerm, Attributes, Context, SeqNum, MaybeItem)
;
(
Functor = "interface",
@@ -1197,7 +1213,7 @@
ModuleDefn = md_implementation
),
ArgTerms = [],
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn),
MaybeItem0 = ok1(Item),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
@@ -1220,7 +1236,7 @@
),
parse_implicitly_qualified_symbol_name_specifier(ModuleName, VarSet,
PredSpecTerm, MaybeSymSpec),
- process_maybe1(make_external(MaybeBackEnd, Context),
+ process_maybe1(make_external(MaybeBackEnd, Context, SeqNum),
MaybeSymSpec, MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
@@ -1231,7 +1247,8 @@
(
MaybeModuleNameSym = ok1(ModuleNameSym),
ModuleDefn = md_module(ModuleNameSym),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn =
+ item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn),
MaybeItem0 = ok1(Item)
;
@@ -1247,7 +1264,8 @@
(
MaybeModuleNameSyms = ok1(ModuleNameSyms),
ModuleDefn = md_include_module(ModuleNameSyms),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn =
+ item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn),
MaybeItem0 = ok1(Item)
;
@@ -1270,7 +1288,8 @@
(
MaybeModuleNameSym = ok1(ModuleNameSym),
ModuleDefn = md_end_module(ModuleNameSym),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn =
+ item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn),
MaybeItem0 = ok1(Item)
;
@@ -1280,7 +1299,8 @@
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
Functor = "pragma",
- parse_pragma(ModuleName, VarSet, ArgTerms, Context, MaybeItem0),
+ parse_pragma(ModuleName, VarSet, ArgTerms, Context, SeqNum,
+ MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
(
@@ -1297,11 +1317,11 @@
PromiseType = promise_type_exclusive_exhaustive
),
parse_promise(ModuleName, PromiseType, VarSet, ArgTerms, Attributes,
- Context, MaybeItem0),
+ Context, SeqNum, MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
Functor = "typeclass",
- parse_typeclass(ModuleName, VarSet, ArgTerms, Context,
+ parse_typeclass(ModuleName, VarSet, ArgTerms, Context, SeqNum,
MaybeItemTypeClass),
(
MaybeItemTypeClass = ok1(ItemTypeClass),
@@ -1313,7 +1333,7 @@
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
Functor = "instance",
- parse_instance(ModuleName, VarSet, ArgTerms, Context,
+ parse_instance(ModuleName, VarSet, ArgTerms, Context, SeqNum,
MaybeItemInstance),
(
MaybeItemInstance = ok1(ItemInstance),
@@ -1329,41 +1349,43 @@
),
ArgTerms = [SubTerm],
parse_initialise_decl(ModuleName, VarSet, SubTerm, Context,
- MaybeItem0),
+ SeqNum, MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
( Functor = "finalise"
; Functor = "finalize"
),
ArgTerms = [SubTerm],
- parse_finalise_decl(ModuleName, VarSet, SubTerm, Context, MaybeItem0),
+ parse_finalise_decl(ModuleName, VarSet, SubTerm, Context, SeqNum,
+ MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
Functor = "mutable",
- parse_mutable_decl(ModuleName, VarSet, ArgTerms, Context, MaybeItem0),
+ parse_mutable_decl(ModuleName, VarSet, ArgTerms, Context, SeqNum,
+ MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
Functor = "version_numbers",
process_version_numbers(ModuleName, VarSet, ArgTerms, Attributes,
- Context, MaybeItem)
+ Context, SeqNum, MaybeItem)
).
:- pred parse_symlist_decl(parser(module_specifier)::parser,
- maker(list(module_specifier), module_defn)::maker,
- term::in, decl_attrs::in, prog_context::in, maybe1(item)::out) is det.
+ maker(list(module_specifier), module_defn)::maker, term::in,
+ decl_attrs::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_symlist_decl(ParserPred, MakeModuleDefnPred, Term, Attributes, Context,
- MaybeItem) :-
+ SeqNum, MaybeItem) :-
parse_list(ParserPred, Term, MaybeModuleSpecs),
- process_maybe1(make_module_defn(MakeModuleDefnPred, Context),
+ process_maybe1(make_module_defn(MakeModuleDefnPred, Context, SeqNum),
MaybeModuleSpecs, MaybeItem0),
check_no_attributes(MaybeItem0, Attributes, MaybeItem).
:- pred process_version_numbers(module_name::in, varset::in, list(term)::in,
- decl_attrs::in, prog_context::in, maybe1(item)::out) is semidet.
+ decl_attrs::in, prog_context::in, int::in, maybe1(item)::out) is semidet.
process_version_numbers(ModuleName, VarSet, ArgTerms, Attributes, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
ArgTerms = [VersionNumberTerm, ModuleNameTerm, VersionNumbersTerm],
parse_module_specifier(VarSet, ModuleNameTerm, MaybeModuleName),
(
@@ -1373,17 +1395,18 @@
(
MaybeModuleName = ok1(ModuleName),
recompilation.version.parse_version_numbers(VersionNumbersTerm,
- Result0),
+ MaybeItem0),
(
- Result0 = ok1(VersionNumbers),
+ MaybeItem0 = ok1(VersionNumbers),
ModuleDefn = md_version_numbers(ModuleName, VersionNumbers),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context,
+ SeqNum),
Item = item_module_defn(ItemModuleDefn),
- Result1 = ok1(Item),
- check_no_attributes(Result1, Attributes, Result)
+ MaybeItem1 = ok1(Item),
+ check_no_attributes(MaybeItem1, Attributes, MaybeItem)
;
- Result0 = error1(Specs),
- Result = error1(Specs)
+ MaybeItem0 = error1(Specs),
+ MaybeItem = error1(Specs)
)
;
% XXX _Spec
@@ -1393,7 +1416,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ModuleNameTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
(
@@ -1403,16 +1426,16 @@
dummy_term_with_context(Context, DummyTerm),
Warning = item_warning(yes(warn_smart_recompilation),
Msg, DummyTerm),
- ItemNothing = item_nothing_info(yes(Warning), Context),
+ ItemNothing = item_nothing_info(yes(Warning), Context, SeqNum),
Item = item_nothing(ItemNothing),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
VersionNumberTerm = term.variable(_, VersionNumberContext),
Pieces = [words("Error: invalid version number in"),
quote(":- version_numbers"), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(VersionNumberContext, [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
).
@@ -1489,20 +1512,13 @@
% Parsing type definitions.
%
-:- type processed_type_body
- ---> processed_type_body(
- sym_name,
- list(type_param),
- type_defn
- ).
-
% parse_type_defn parses the definition of a type.
%
:- pred parse_type_defn(module_name::in, varset::in, term::in, decl_attrs::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
parse_type_defn(ModuleName, VarSet, TypeDefnTerm, Attributes, Context,
- MaybeItem) :-
+ SeqNum, MaybeItem) :-
(
TypeDefnTerm = term.functor(term.atom(Name), ArgTerms, _),
ArgTerms = [HeadTerm, BodyTerm],
@@ -1515,25 +1531,24 @@
(
Name = "--->",
parse_du_type_defn(ModuleName, VarSet,
- HeadTerm, BeforeCondTerm, Attributes, MaybeProcessedTypeBody)
+ HeadTerm, BeforeCondTerm, Attributes,
+ Condition, Context, SeqNum, MaybeItem)
;
Name = "==",
parse_eqv_type_defn(ModuleName, VarSet,
- HeadTerm, BeforeCondTerm, Attributes, MaybeProcessedTypeBody)
+ HeadTerm, BeforeCondTerm, Attributes,
+ Condition, Context, SeqNum, MaybeItem)
;
Name = "where",
parse_solver_type_defn(ModuleName, VarSet,
- HeadTerm, BeforeCondTerm, Attributes, MaybeProcessedTypeBody)
+ HeadTerm, BeforeCondTerm, Attributes,
+ Condition, Context, SeqNum, MaybeItem)
)
;
- parse_abstract_type_defn(ModuleName, VarSet, TypeDefnTerm,
- Attributes, MaybeProcessedTypeBody),
+ parse_abstract_type_defn(ModuleName, VarSet, TypeDefnTerm, Attributes,
+ Condition, Context, SeqNum, MaybeItem),
Condition = cond_true
- ),
- % We should check the condition for errors (don't bother at the moment,
- % since we ignore conditions anyhow :-).
- process_maybe1(make_type_defn(VarSet, Condition, Context),
- MaybeProcessedTypeBody, MaybeItem).
+ ).
%-----------------------------------------------------------------------------%
%
@@ -1543,10 +1558,11 @@
% parse_du_type_defn parses the definition of a discriminated union type.
%
:- pred parse_du_type_defn(module_name::in, varset::in, term::in, term::in,
- decl_attrs::in, maybe1(processed_type_body)::out) is det.
+ decl_attrs::in, condition::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_du_type_defn(ModuleName, VarSet, HeadTerm, BodyTerm, Attributes0,
- MaybeProcessedTypeBody) :-
+ Condition, Context, SeqNum, MaybeItem) :-
get_is_solver_type(IsSolverType, Attributes0, Attributes),
(
IsSolverType = solver_type,
@@ -1554,7 +1570,7 @@
words("cannot have data constructors."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- MaybeProcessedTypeBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
IsSolverType = non_solver_type,
parse_type_defn_head(ModuleName, VarSet, HeadTerm,
@@ -1568,27 +1584,28 @@
% this is a du type, if the unification with WhereResult succeeds
% then _NoSolverTypeDetails is guaranteed to be `no'.
(
- MaybeTypeCtorAndArgs = ok2(Functor, Params),
+ MaybeTypeCtorAndArgs = ok2(Name, Params),
MaybeCtors = ok1(Ctors),
MaybeWhere = ok2(_NoSolverTypeDetails, MaybeUserEqComp)
->
process_du_ctors(Params, VarSet, BodyTerm, Ctors, [], CtorsSpecs),
(
CtorsSpecs = [],
+ varset.coerce(VarSet, TypeVarSet),
TypeDefn = parse_tree_du_type(Ctors, MaybeUserEqComp),
- ProcessedTypeBody = processed_type_body(Functor, Params,
- TypeDefn),
- MaybeProcessedTypeBody0 = ok1(ProcessedTypeBody),
- check_no_attributes(MaybeProcessedTypeBody0, Attributes,
- MaybeProcessedTypeBody)
+ ItemTypeDefn = item_type_defn_info(TypeVarSet, Name, Params,
+ TypeDefn, Condition, Context, SeqNum),
+ Item = item_type_defn(ItemTypeDefn),
+ MaybeItem0 = ok1(Item),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
CtorsSpecs = [_ | _],
- MaybeProcessedTypeBody = error1(CtorsSpecs)
+ MaybeItem = error1(CtorsSpecs)
)
;
Specs = get_any_errors2(MaybeTypeCtorAndArgs) ++
get_any_errors1(MaybeCtors) ++ get_any_errors2(MaybeWhere),
- MaybeProcessedTypeBody = error1(Specs)
+ MaybeItem = error1(Specs)
)
).
@@ -1903,16 +1920,18 @@
% parse_eqv_type_defn parses the definition of an equivalence type.
%
:- pred parse_eqv_type_defn(module_name::in, varset::in, term::in, term::in,
- decl_attrs::in, maybe1(processed_type_body)::out) is det.
+ decl_attrs::in, condition::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_eqv_type_defn(ModuleName, VarSet, HeadTerm, BodyTerm, Attributes,
- MaybeProcessedTypeBody) :-
- parse_type_defn_head(ModuleName, VarSet, HeadTerm, MaybeNameParams),
+ Condition, Context, SeqNum, MaybeItem) :-
+ parse_type_defn_head(ModuleName, VarSet, HeadTerm,
+ MaybeNameAndParams),
(
- MaybeNameParams = error2(Specs),
- MaybeProcessedTypeBody0 = error1(Specs)
+ MaybeNameAndParams = error2(Specs),
+ MaybeItem = error1(Specs)
;
- MaybeNameParams = ok2(Name, Params),
+ MaybeNameAndParams = ok2(Name, Params),
% Check that all the variables in the body occur in the head.
(
term.contains_var(BodyTerm, Var),
@@ -1925,33 +1944,37 @@
words(BodyTermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(BodyTerm), [always(Pieces)])]),
- MaybeProcessedTypeBody0 = error1([Spec])
+ MaybeItem = error1([Spec])
;
% XXX Should pass more correct ContextPieces.
ContextPieces = [],
parse_type(BodyTerm, VarSet, ContextPieces, MaybeType),
(
MaybeType = ok1(Type),
- MaybeProcessedTypeBody0 = ok1(processed_type_body(Name, Params,
- parse_tree_eqv_type(Type)))
+ varset.coerce(VarSet, TypeVarSet),
+ TypeDefn = parse_tree_eqv_type(Type),
+ ItemTypeDefn = item_type_defn_info(TypeVarSet, Name, Params,
+ TypeDefn, Condition, Context, SeqNum),
+ Item = item_type_defn(ItemTypeDefn),
+ MaybeItem0 = ok1(Item),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
MaybeType = error1(Specs),
- MaybeProcessedTypeBody0 = error1(Specs)
+ MaybeItem = error1(Specs)
)
)
- ),
- check_no_attributes(MaybeProcessedTypeBody0, Attributes,
- MaybeProcessedTypeBody).
+ ).
%-----------------------------------------------------------------------------%
% parse_solver_type_defn parses the definition of a solver type.
%
:- pred parse_solver_type_defn(module_name::in, varset::in, term::in, term::in,
- decl_attrs::in, maybe1(processed_type_body)::out) is det.
+ decl_attrs::in, condition::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_solver_type_defn(ModuleName, VarSet, HeadTerm, BodyTerm, Attributes0,
- MaybeProcessedTypeBody) :-
+ Condition, Context, SeqNum, MaybeItem) :-
get_is_solver_type(IsSolverType, Attributes0, Attributes),
(
IsSolverType = non_solver_type,
@@ -1959,36 +1982,36 @@
words("by a `where' block alone."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- MaybeProcessedTypeBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
IsSolverType = solver_type,
MaybeWhere = parse_type_decl_where_term(solver_type, ModuleName,
VarSet, yes(BodyTerm)),
(
MaybeWhere = error2(Specs),
- MaybeProcessedTypeBody = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeWhere = ok2(MaybeSolverTypeDetails, MaybeUserEqComp),
parse_solver_type_base(ModuleName, VarSet, HeadTerm,
- MaybeSolverTypeDetails, MaybeUserEqComp,
- MaybeProcessedTypeBody0),
- check_no_attributes(MaybeProcessedTypeBody0, Attributes,
- MaybeProcessedTypeBody)
+ MaybeSolverTypeDetails, MaybeUserEqComp, Attributes,
+ Condition, Context, SeqNum, MaybeItem)
)
).
:- pred parse_solver_type_base(module_name::in, varset::in, term::in,
maybe(solver_type_details)::in, maybe(unify_compare)::in,
- maybe1(processed_type_body)::out) is det.
+ decl_attrs::in, condition::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_solver_type_base(ModuleName, VarSet, HeadTerm,
- MaybeSolverTypeDetails, MaybeUserEqComp, MaybeProcessedTypeBody) :-
+ MaybeSolverTypeDetails, MaybeUserEqComp, Attributes, Condition,
+ Context, SeqNum, MaybeItem) :-
(
MaybeSolverTypeDetails = yes(SolverTypeDetails),
parse_type_defn_head(ModuleName, VarSet, HeadTerm, MaybeNameParams),
(
MaybeNameParams = error2(Specs),
- MaybeProcessedTypeBody = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeNameParams = ok2(Name, Params),
(
@@ -2003,11 +2026,16 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm),
[always(Pieces)])]),
- MaybeProcessedTypeBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
- MaybeProcessedTypeBody = ok1(processed_type_body(Name, Params,
- parse_tree_solver_type(SolverTypeDetails,
- MaybeUserEqComp)))
+ varset.coerce(VarSet, TypeVarSet),
+ TypeDefn = parse_tree_solver_type(SolverTypeDetails,
+ MaybeUserEqComp),
+ ItemTypeDefn = item_type_defn_info(TypeVarSet, Name, Params,
+ TypeDefn, Condition, Context, SeqNum),
+ Item = item_type_defn(ItemTypeDefn),
+ MaybeItem0 = ok1(Item),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
)
)
;
@@ -2015,7 +2043,7 @@
Pieces = [words("Solver type with no solver_type_details."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- MaybeProcessedTypeBody = error1([Spec])
+ MaybeItem = error1([Spec])
).
%-----------------------------------------------------------------------------%
@@ -2024,22 +2052,26 @@
%
:- pred parse_abstract_type_defn(module_name::in, varset::in, term::in,
- decl_attrs::in, maybe1(processed_type_body)::out) is det.
+ decl_attrs::in, condition::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_abstract_type_defn(ModuleName, VarSet, HeadTerm, Attributes0,
- MaybeProcessedTypeBody) :-
+ Condition, Context, SeqNum, MaybeItem) :-
parse_type_defn_head(ModuleName, VarSet, HeadTerm, MaybeTypeCtorAndArgs),
get_is_solver_type(IsSolverType, Attributes0, Attributes),
(
MaybeTypeCtorAndArgs = error2(Specs),
- MaybeProcessedTypeBody0 = error1(Specs)
+ MaybeItem = error1(Specs)
;
- MaybeTypeCtorAndArgs = ok2(Functor, Params),
- MaybeProcessedTypeBody0 = ok1(processed_type_body(Functor, Params,
- parse_tree_abstract_type(IsSolverType)))
- ),
- check_no_attributes(MaybeProcessedTypeBody0, Attributes,
- MaybeProcessedTypeBody).
+ MaybeTypeCtorAndArgs = ok2(Name, Params),
+ varset.coerce(VarSet, TypeVarSet),
+ TypeDefn = parse_tree_abstract_type(IsSolverType),
+ ItemTypeDefn = item_type_defn_info(TypeVarSet, Name, Params, TypeDefn,
+ Condition, Context, SeqNum),
+ Item = item_type_defn(ItemTypeDefn),
+ MaybeItem0 = ok1(Item),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
+ ).
%-----------------------------------------------------------------------------%
%
@@ -2304,7 +2336,8 @@
(
Term = term.functor(term.atom("mutable"), Args, Context),
varset.init(VarSet),
- parse_mutable_decl(ModuleName, VarSet, Args, Context, MaybeItemPrime)
+ parse_mutable_decl(ModuleName, VarSet, Args, Context, -1,
+ MaybeItemPrime)
->
MaybeItem = MaybeItemPrime
;
@@ -2541,28 +2574,19 @@
% Parsing inst definitions.
%
-:- type processed_inst_body
- ---> processed_inst_body(
- sym_name,
- list(inst_var),
- inst_defn
- ).
-
% Parse a `:- inst <InstDefn>.' declaration.
%
:- pred parse_inst_defn(module_name::in, varset::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_inst_defn(ModuleName, VarSet, Term, Context, MaybeItem) :-
+parse_inst_defn(ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
% XXX Some of the tests here could be factored out.
(
Term = term.functor(term.atom("=="), [HeadTerm, BodyTerm], _)
->
parse_condition_suffix(BodyTerm, BeforeCondTerm, Condition),
parse_inst_defn_base(ModuleName, VarSet, HeadTerm, BeforeCondTerm,
- MaybeProcessedInstBody),
- process_maybe1(make_inst_defn(VarSet, Condition, Context),
- MaybeProcessedInstBody, MaybeItem)
+ Condition, Context, SeqNum, MaybeItem)
;
% XXX This is for `abstract inst' declarations,
% which are not really supported.
@@ -2571,9 +2595,7 @@
->
Condition = cond_true,
parse_abstract_inst_defn(ModuleName, VarSet, HeadTerm,
- MaybeProcessedInstBody),
- process_maybe1(make_inst_defn(VarSet, Condition, Context),
- MaybeProcessedInstBody, MaybeItem)
+ Condition, Context, SeqNum, MaybeItem)
;
Term = term.functor(term.atom("--->"), [HeadTerm, BodyTerm], _)
->
@@ -2581,11 +2603,7 @@
BoundBeforeCondTerm =
term.functor(term.atom("bound"), [BeforeCondTerm], Context),
parse_inst_defn_base(ModuleName, VarSet, HeadTerm, BoundBeforeCondTerm,
- MaybeProcessedInstBody),
- % We should check the condition for errors. We don't bother
- % at the moment, since we ignore conditions anyhow :-)
- process_maybe1(make_inst_defn(VarSet, Condition, Context),
- MaybeProcessedInstBody, MaybeItem)
+ Condition, Context, SeqNum, MaybeItem)
;
Pieces = [words("Error:"), quote("=="), words("expected in"),
quote(":- inst"), words("definition."), nl],
@@ -2595,16 +2613,16 @@
).
:- pred parse_inst_defn_base(module_name::in, varset::in, term::in, term::in,
- maybe1(processed_inst_body)::out) is det.
+ condition::in, prog_context::in, int::in, maybe1(item)::out) is det.
-parse_inst_defn_base(ModuleName, VarSet, HeadTerm, BodyTerm,
- MaybeProcessedInstBody) :-
+parse_inst_defn_base(ModuleName, VarSet, HeadTerm, BodyTerm, Condition,
+ Context, SeqNum, MaybeItem) :-
ContextPieces = [words("In inst definition:")],
parse_implicitly_qualified_term(ModuleName, HeadTerm, BodyTerm,
VarSet, ContextPieces, MaybeNameAndArgs),
(
MaybeNameAndArgs = error2(Specs),
- MaybeProcessedInstBody = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeNameAndArgs = ok2(Name, ArgTerms),
(
@@ -2622,7 +2640,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm),
[always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
% Check that all the variables in the body occur in the head.
term.contains_var(BodyTerm, Var2),
@@ -2633,7 +2651,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(BodyTerm),
[always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
% Check that the inst is a valid user-defined inst, i.e. that it
% does not have the form of one of the builtin insts.
@@ -2649,16 +2667,19 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm),
[always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
% Should improve the error message here.
(
- convert_inst(no_allow_constrained_inst_var, BodyTerm,
- ConvertedBody)
+ convert_inst(no_allow_constrained_inst_var, BodyTerm, Inst)
->
+ varset.coerce(VarSet, InstVarSet),
list.map(term.coerce_var, Args, InstArgs),
- MaybeProcessedInstBody = ok1(processed_inst_body(Name,
- InstArgs, eqv_inst(ConvertedBody)))
+ InstDefn = eqv_inst(Inst),
+ ItemInstDefn = item_inst_defn_info(InstVarSet, Name,
+ InstArgs, InstDefn, Condition, Context, SeqNum),
+ Item = item_inst_defn(ItemInstDefn),
+ MaybeItem = ok1(Item)
;
BodyTermStr = describe_error_term(VarSet, BodyTerm),
Pieces = [words("Error: syntax error in inst body at"),
@@ -2666,7 +2687,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(BodyTerm),
[always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
)
)
;
@@ -2675,21 +2696,21 @@
Pieces = [words("Error: inst parameters must be variables."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
)
).
:- pred parse_abstract_inst_defn(module_name::in, varset::in, term::in,
- maybe1(processed_inst_body)::out) is det.
+ condition::in, prog_context::in, int::in, maybe1(item)::out) is det.
-parse_abstract_inst_defn(ModuleName, VarSet, HeadTerm,
- MaybeProcessedInstBody) :-
+parse_abstract_inst_defn(ModuleName, VarSet, HeadTerm, Condition, Context,
+ SeqNum, MaybeItem) :-
ContextPieces = [words("In inst definition:")],
parse_implicitly_qualified_term(ModuleName, HeadTerm, HeadTerm,
VarSet, ContextPieces, MaybeNameAndArgs),
(
MaybeNameAndArgs = error2(Specs),
- MaybeProcessedInstBody = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeNameAndArgs = ok2(Name, ArgTerms),
(
@@ -2707,11 +2728,15 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm),
[always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
+ varset.coerce(VarSet, InstVarSet),
list.map(term.coerce_var, Args, InstArgs),
- MaybeProcessedInstBody = ok1(processed_inst_body(Name,
- InstArgs, abstract_inst))
+ InstDefn = abstract_inst,
+ ItemInstDefn = item_inst_defn_info(InstVarSet, Name,
+ InstArgs, InstDefn, Condition, Context, SeqNum),
+ Item = item_inst_defn(ItemInstDefn),
+ MaybeItem = ok1(Item)
)
;
% XXX If term_list_to_var_list returned the non-var's term
@@ -2719,7 +2744,7 @@
Pieces = [words("Error: inst parameters must be variables."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- MaybeProcessedInstBody = error1([Spec])
+ MaybeItem = error1([Spec])
)
).
@@ -2736,16 +2761,16 @@
).
:- pred parse_mode_defn(module_name::in, varset::in, term::in, term::in,
- maybe1(processed_mode_body)::out) is det.
+ condition::in, prog_context::in, int::in, maybe1(item)::out) is det.
-parse_mode_defn(ModuleName, VarSet, HeadTerm, BodyTerm,
- MaybeProcessedModeBody) :-
+parse_mode_defn(ModuleName, VarSet, HeadTerm, BodyTerm, Condition, Context,
+ SeqNum, MaybeItem) :-
ContextPieces = [words("In mode definition:")],
parse_implicitly_qualified_term(ModuleName, HeadTerm, HeadTerm,
VarSet, ContextPieces, MaybeModeNameAndArgs),
(
MaybeModeNameAndArgs = error2(Specs),
- MaybeProcessedModeBody = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeModeNameAndArgs = ok2(Name, ArgTerms),
% Check that all the head args are variables.
@@ -2762,7 +2787,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm),
[always(Pieces)])]),
- MaybeProcessedModeBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
% Check that all the variables in the body occur in the head.
term.contains_var(BodyTerm, Var2),
@@ -2775,15 +2800,18 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm),
[always(Pieces)])]),
- MaybeProcessedModeBody = error1([Spec])
+ MaybeItem = error1([Spec])
;
(
convert_mode(no_allow_constrained_inst_var, BodyTerm, Mode)
->
- list.map(term.coerce_var, Args, InstArgs),
- ProcessedModeBody = processed_mode_body(Name, InstArgs,
- eqv_mode(Mode)),
- MaybeProcessedModeBody = ok1(ProcessedModeBody)
+ varset.coerce(VarSet, InstVarSet),
+ list.map(term.coerce_var, Args, ModeArgs),
+ ModeDefn = eqv_mode(Mode),
+ ItemModeDefn = item_mode_defn_info(InstVarSet, Name,
+ ModeArgs, ModeDefn, Condition, Context, SeqNum),
+ Item = item_mode_defn(ItemModeDefn),
+ MaybeItem = ok1(Item)
;
% XXX We should improve the error message here.
Pieces = [words("Error: syntax error"),
@@ -2791,7 +2819,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(BodyTerm),
[always(Pieces)])]),
- MaybeProcessedModeBody = error1([Spec])
+ MaybeItem = error1([Spec])
)
)
;
@@ -2800,7 +2828,7 @@
Pieces = [words("Error: mode parameters must be variables."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- MaybeProcessedModeBody = error1([Spec])
+ MaybeItem = error1([Spec])
)
).
@@ -2812,10 +2840,11 @@
% parse_pred_or_func_decl parses a predicate or function declaration.
%
:- pred parse_pred_or_func_decl(pred_or_func::in, module_name::in, varset::in,
- term::in, decl_attrs::in, prog_context::in, maybe1(item)::out) is det.
+ term::in, decl_attrs::in, prog_context::in, int::in, maybe1(item)::out)
+ is det.
parse_pred_or_func_decl(PredOrFunc, ModuleName, VarSet, Term, Attributes,
- Context, MaybeItem) :-
+ Context, SeqNum, MaybeItem) :-
parse_condition_suffix(Term, BeforeCondTerm, Condition),
parse_determinism_suffix(VarSet, BeforeCondTerm, BeforeDetismTerm,
MaybeMaybeDetism),
@@ -2855,11 +2884,11 @@
WithType = no
->
parse_func_decl_base(ModuleName, VarSet, BaseTerm, Condition,
- MaybeDetism, Attributes, Context, MaybeItem)
+ MaybeDetism, Attributes, Context, SeqNum, MaybeItem)
;
parse_pred_decl_base(PredOrFunc, ModuleName, VarSet, BaseTerm,
Condition, WithType, WithInst, MaybeDetism,
- Attributes, Context, MaybeItem)
+ Attributes, Context, SeqNum, MaybeItem)
)
)
;
@@ -2874,11 +2903,12 @@
%
:- pred parse_pred_decl_base(pred_or_func::in, module_name::in, varset::in,
term::in, condition::in, maybe(mer_type)::in, maybe(mer_inst)::in,
- maybe(determinism)::in, decl_attrs::in, prog_context::in,
+ maybe(determinism)::in, decl_attrs::in, prog_context::in, int::in,
maybe1(item)::out) is det.
parse_pred_decl_base(PredOrFunc, ModuleName, VarSet, PredTypeTerm, Condition,
- WithType, WithInst, MaybeDet, Attributes0, Context, MaybeItem) :-
+ WithType, WithInst, MaybeDet, Attributes0, Context, SeqNum,
+ MaybeItem) :-
get_class_context_and_inst_constraints(ModuleName, VarSet,
Attributes0, Attributes1, MaybeExistClassInstContext),
(
@@ -2930,8 +2960,8 @@
Origin = user,
ItemPredDecl = item_pred_decl_info(Origin,
TVarSet, IVarSet, ExistQVars, PredOrFunc,
- Functor, Args, WithType, WithInst,
- MaybeDet, Condition, Purity, Constraints, Context),
+ Functor, Args, WithType, WithInst, MaybeDet,
+ Condition, Purity, Constraints, Context, SeqNum),
Item = item_pred_decl(ItemPredDecl),
MaybeItem0 = ok1(Item),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
@@ -2974,10 +3004,10 @@
%
:- pred parse_func_decl_base(module_name::in, varset::in, term::in,
condition::in, maybe(determinism)::in, decl_attrs::in, prog_context::in,
- maybe1(item)::out) is det.
+ int::in, maybe1(item)::out) is det.
parse_func_decl_base(ModuleName, VarSet, Term, Condition, MaybeDet,
- Attributes0, Context, MaybeItem) :-
+ Attributes0, Context, SeqNum, MaybeItem) :-
get_class_context_and_inst_constraints(ModuleName, VarSet,
Attributes0, Attributes, MaybeContext),
(
@@ -3039,7 +3069,7 @@
parse_func_decl_base_2(FuncName, Args, ReturnArg,
FuncTerm, Term, VarSet, MaybeDet, Condition,
ExistQVars, Constraints, Attributes,
- Context, MaybeItem)
+ Context, SeqNum, MaybeItem)
;
Specs = get_any_errors1(MaybeArgs) ++
get_any_errors1(MaybeReturnArg),
@@ -3058,11 +3088,11 @@
:- pred parse_func_decl_base_2(sym_name::in, list(type_and_mode)::in,
type_and_mode::in, term::in, term::in, varset::in, maybe(determinism)::in,
condition::in, existq_tvars::in, prog_constraints::in, decl_attrs::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
parse_func_decl_base_2(FuncName, Args, ReturnArg, FuncTerm, Term,
VarSet, MaybeDet, Condition, ExistQVars, Constraints, Attributes0,
- Context, MaybeItem) :-
+ Context, SeqNum, MaybeItem) :-
(
verify_type_and_mode_list(Args)
->
@@ -3115,7 +3145,7 @@
Origin = user,
ItemPredDecl = item_pred_decl_info(Origin, TVarSet, IVarSet,
ExistQVars, pf_function, FuncName, AllArgs, no, no,
- MaybeDet, Condition, Purity, Constraints, Context),
+ MaybeDet, Condition, Purity, Constraints, Context, SeqNum),
Item = item_pred_decl(ItemPredDecl),
MaybeItem0 = ok1(Item),
check_no_attributes(MaybeItem0, Attributes, MaybeItem)
@@ -3181,9 +3211,10 @@
%
:- pred parse_mode_decl(module_name::in, varset::in, term::in,
- decl_attrs::in, prog_context::in, maybe1(item)::out) is det.
+ decl_attrs::in, prog_context::in, int::in, maybe1(item)::out) is det.
-parse_mode_decl(ModuleName, VarSet, Term, Attributes, Context, MaybeItem) :-
+parse_mode_decl(ModuleName, VarSet, Term, Attributes, Context, SeqNum,
+ MaybeItem) :-
parse_condition_suffix(Term, BeforeCondTerm, Condition),
parse_determinism_suffix(VarSet, BeforeCondTerm, BeforeDetismTerm,
MaybeMaybeDetism),
@@ -3206,7 +3237,7 @@
MaybeItem = error1([Spec])
;
parse_mode_decl_base(ModuleName, VarSet, BaseTerm, Condition,
- Attributes, WithInst, MaybeDetism, Context, MaybeItem)
+ Attributes, WithInst, MaybeDetism, Context, SeqNum, MaybeItem)
)
;
Specs = get_any_errors1(MaybeMaybeDetism)
@@ -3216,10 +3247,10 @@
:- pred parse_mode_decl_base(module_name::in, varset::in, term::in,
condition::in, decl_attrs::in, maybe(mer_inst)::in, maybe(determinism)::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
parse_mode_decl_base(ModuleName, VarSet, Term, Condition, Attributes, WithInst,
- MaybeDet, Context, MaybeItem) :-
+ MaybeDet, Context, SeqNum, MaybeItem) :-
(
WithInst = no,
Term = term.functor(term.atom("="),
@@ -3229,32 +3260,48 @@
ContextPieces = [words("In function"), quote(":- mode"),
words("declaration")],
parse_implicitly_qualified_term(ModuleName, FuncTerm, Term,
- VarSet, ContextPieces, R),
- parse_func_mode_decl(R, ModuleName, FuncTerm, ReturnTypeTerm,
- Term, VarSet, MaybeDet, Condition, Attributes, Context, MaybeItem)
+ VarSet, ContextPieces, MaybeFunctorArgs),
+ (
+ MaybeFunctorArgs = error2(Specs),
+ MaybeItem = error1(Specs)
+ ;
+ MaybeFunctorArgs = ok2(Functor, ArgTerms),
+ parse_func_mode_decl(Functor, ArgTerms, ModuleName,
+ FuncTerm, ReturnTypeTerm, Term, VarSet, MaybeDet, Condition,
+ Attributes, Context, SeqNum, MaybeItem)
+ )
;
ContextPieces = [words("In"), quote(":- mode"), words("declaration")],
parse_implicitly_qualified_term(ModuleName, Term, Term,
- VarSet, ContextPieces, R),
- parse_pred_mode_decl(R, ModuleName, Term, VarSet,
- WithInst, MaybeDet, Condition, Attributes, Context, MaybeItem)
+ VarSet, ContextPieces, MaybeFunctorArgs),
+ (
+ MaybeFunctorArgs = error2(Specs),
+ MaybeItem = error1(Specs)
+ ;
+ MaybeFunctorArgs = ok2(Functor, ArgTerms),
+ parse_pred_mode_decl(Functor, ArgTerms, ModuleName, Term,
+ VarSet, WithInst, MaybeDet, Condition,
+ Attributes, Context, SeqNum, MaybeItem)
+ )
).
-:- pred parse_pred_mode_decl(maybe_functor::in, module_name::in, term::in,
- varset::in, maybe(mer_inst)::in, maybe(determinism)::in, condition::in,
- decl_attrs::in, prog_context::in, maybe1(item)::out) is det.
-
-parse_pred_mode_decl(error2(Specs), _, _, _, _, _, _, _, _, error1(Specs)).
-parse_pred_mode_decl(ok2(F, As0), ModuleName, PredModeTerm, VarSet, WithInst,
- MaybeDet, Condition, Attributes0, Context, MaybeItem) :-
- ( convert_mode_list(allow_constrained_inst_var, As0, As1) ->
+:- pred parse_pred_mode_decl(sym_name::in, list(term)::in, module_name::in,
+ term::in, varset::in, maybe(mer_inst)::in, maybe(determinism)::in,
+ condition::in, decl_attrs::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
+
+parse_pred_mode_decl(Functor, ArgTerms, ModuleName, PredModeTerm, VarSet,
+ WithInst, MaybeDet, Condition, Attributes0, Context, SeqNum,
+ MaybeItem) :-
+ ( convert_mode_list(allow_constrained_inst_var, ArgTerms, ArgModes0) ->
get_class_context_and_inst_constraints(ModuleName, VarSet,
Attributes0, Attributes, MaybeConstraints),
(
MaybeConstraints = ok3(_, _, InstConstraints),
- list.map(constrain_inst_vars_in_mode(InstConstraints), As1, As),
+ list.map(constrain_inst_vars_in_mode(InstConstraints),
+ ArgModes0, ArgModes),
varset.coerce(VarSet, ProgVarSet),
- ( inst_var_constraints_are_self_consistent_in_modes(As) ->
+ ( inst_var_constraints_are_self_consistent_in_modes(ArgModes) ->
(
WithInst = no,
PredOrFunc = yes(pf_predicate)
@@ -3265,9 +3312,11 @@
PredOrFunc = no
),
ItemModeDecl = item_mode_decl_info(ProgVarSet, PredOrFunc,
- F, As, WithInst, MaybeDet, Condition, Context),
+ Functor, ArgModes, WithInst, MaybeDet, Condition, Context,
+ SeqNum),
Item = item_mode_decl(ItemModeDecl),
- MaybeItem0 = ok1(Item)
+ MaybeItem0 = ok1(Item),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
PredModeTermStr = describe_error_term(VarSet, PredModeTerm),
Pieces = [words("Error: inconsistent constraints"),
@@ -3277,13 +3326,12 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(PredModeTerm),
[always(Pieces)])]),
- MaybeItem0 = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
MaybeConstraints = error3(Specs),
- MaybeItem0 = error1(Specs)
- ),
- check_no_attributes(MaybeItem0, Attributes, MaybeItem)
+ MaybeItem = error1(Specs)
+ )
;
PredModeTermStr = describe_error_term(VarSet, PredModeTerm),
Pieces = [words("Error: syntax error in mode declaration at"),
@@ -3293,36 +3341,38 @@
MaybeItem = error1([Spec])
).
-:- pred parse_func_mode_decl(maybe_functor::in, module_name::in, term::in,
- term::in, term::in, varset::in, maybe(determinism)::in, condition::in,
- decl_attrs::in, prog_context::in, maybe1(item)::out) is det.
-
-parse_func_mode_decl(error2(Specs), _, _, _, _, _, _, _, _, _, error1(Specs)).
-parse_func_mode_decl(ok2(F, As0), ModuleName, FuncMode, RetMode0, FullTerm,
- VarSet, MaybeDet, Condition, Attributes0, Context, MaybeItem) :-
- (
- convert_mode_list(allow_constrained_inst_var, As0, As1)
- ->
+:- pred parse_func_mode_decl(sym_name::in, list(term)::in, module_name::in,
+ term::in, term::in, term::in, varset::in, maybe(determinism)::in,
+ condition::in, decl_attrs::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
+
+parse_func_mode_decl(Functor, ArgTerms, ModuleName, FuncMode, RetModeTerm,
+ FullTerm, VarSet, MaybeDet, Condition, Attributes0, Context, SeqNum,
+ MaybeItem) :-
+ ( convert_mode_list(allow_constrained_inst_var, ArgTerms, ArgModes0) ->
get_class_context_and_inst_constraints(ModuleName, VarSet,
Attributes0, Attributes, MaybeConstraints),
(
MaybeConstraints = ok3(_, _, InstConstraints),
- list.map(constrain_inst_vars_in_mode(InstConstraints), As1, As),
+ list.map(constrain_inst_vars_in_mode(InstConstraints),
+ ArgModes0, ArgModes),
(
- convert_mode(allow_constrained_inst_var, RetMode0, RetMode1)
+ convert_mode(allow_constrained_inst_var, RetModeTerm, RetMode0)
->
constrain_inst_vars_in_mode(InstConstraints,
- RetMode1, RetMode),
+ RetMode0, RetMode),
varset.coerce(VarSet, InstVarSet),
- ArgModes = As ++ [RetMode],
+ ArgReturnModes = ArgModes ++ [RetMode],
(
- inst_var_constraints_are_self_consistent_in_modes(ArgModes)
+ inst_var_constraints_are_self_consistent_in_modes(
+ ArgReturnModes)
->
ItemModeDecl = item_mode_decl_info(InstVarSet,
- yes(pf_function), F, ArgModes, no, MaybeDet, Condition,
- Context),
+ yes(pf_function), Functor, ArgReturnModes, no,
+ MaybeDet, Condition, Context, SeqNum),
Item = item_mode_decl(ItemModeDecl),
- MaybeItem0 = ok1(Item)
+ MaybeItem0 = ok1(Item),
+ check_no_attributes(MaybeItem0, Attributes, MaybeItem)
;
FullTermStr = describe_error_term(VarSet, FullTerm),
Pieces = [words("Error: inconsistent constraints"),
@@ -3332,21 +3382,20 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(FullTerm),
[always(Pieces)])]),
- MaybeItem0 = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: syntax error in return mode"),
words("of function mode declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
- [simple_msg(get_term_context(RetMode0),
+ [simple_msg(get_term_context(RetModeTerm),
[always(Pieces)])]),
- MaybeItem0 = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
MaybeConstraints = error3(Specs),
- MaybeItem0 = error1(Specs)
- ),
- check_no_attributes(MaybeItem0, Attributes, MaybeItem)
+ MaybeItem = error1(Specs)
+ )
;
% XXX Should say which argument.
FuncModeStr = describe_error_term(VarSet, FuncMode),
@@ -3480,11 +3529,11 @@
%-----------------------------------------------------------------------------%
:- pred parse_promise(module_name::in, promise_type::in, varset::in,
- list(term)::in, decl_attrs::in, prog_context::in, maybe1(item)::out)
- is semidet.
+ list(term)::in, decl_attrs::in, prog_context::in, int::in,
+ maybe1(item)::out) is semidet.
parse_promise(ModuleName, PromiseType, VarSet, [Term], Attributes, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
varset.coerce(VarSet, ProgVarSet0),
ContextPieces = [],
parse_goal(Term, ContextPieces, MaybeGoal0, ProgVarSet0, ProgVarSet),
@@ -3511,24 +3560,24 @@
Goal0 = Goal
),
ItemPromise = item_promise_info(PromiseType, Goal, ProgVarSet,
- UnivVars, Context),
+ UnivVars, Context, SeqNum),
Item = item_promise(ItemPromise),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
MaybeGoal0 = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
).
%-----------------------------------------------------------------------------%
:- pred parse_initialise_decl(module_name::in, varset::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_initialise_decl(_ModuleName, VarSet, Term, Context, Result) :-
+parse_initialise_decl(_ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
parse_symbol_name_specifier(VarSet, Term, MaybeSymNameSpecifier),
(
MaybeSymNameSpecifier = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeSymNameSpecifier = ok1(SymNameSpecifier),
(
@@ -3539,16 +3588,16 @@
words(TermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(Term), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
;
SymNameSpecifier = name_arity(SymName, Arity),
(
( Arity = 0 ; Arity = 2 )
->
ItemInitialise = item_initialise_info(user, SymName, Arity,
- Context),
+ Context, SeqNum),
Item = item_initialise(ItemInitialise),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
TermStr = describe_error_term(VarSet, Term),
Pieces = [words("Error:"), quote("initialise"),
@@ -3557,7 +3606,7 @@
words(TermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(Term), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
)
).
@@ -3565,13 +3614,13 @@
%-----------------------------------------------------------------------------%
:- pred parse_finalise_decl(module_name::in, varset::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_finalise_decl(_ModuleName, VarSet, Term, Context, Result) :-
+parse_finalise_decl(_ModuleName, VarSet, Term, Context, SeqNum, MaybeItem) :-
parse_symbol_name_specifier(VarSet, Term, MaybeSymNameSpecifier),
(
MaybeSymNameSpecifier = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
;
MaybeSymNameSpecifier = ok1(SymNameSpecifier),
(
@@ -3582,16 +3631,16 @@
words(TermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(Term), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
;
SymNameSpecifier = name_arity(SymName, Arity),
(
( Arity = 0 ; Arity = 2 )
->
ItemFinalise = item_finalise_info(user, SymName, Arity,
- Context),
+ Context, SeqNum),
Item = item_finalise(ItemFinalise),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
TermStr = describe_error_term(VarSet, Term),
Pieces = [words("Error:"), quote("finalise"),
@@ -3600,7 +3649,7 @@
words(TermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(Term), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
)
).
@@ -3613,9 +3662,9 @@
%
:- pred parse_mutable_decl(module_name::in, varset::in, list(term)::in,
- prog_context::in, maybe1(item)::out) is semidet.
+ prog_context::in, int::in, maybe1(item)::out) is semidet.
-parse_mutable_decl(_ModuleName, VarSet, Terms, Context, MaybeItem) :-
+parse_mutable_decl(_ModuleName, VarSet, Terms, Context, SeqNum, MaybeItem) :-
Terms = [NameTerm, TypeTerm, ValueTerm, InstTerm | OptMutAttrsTerm],
parse_mutable_name(NameTerm, MaybeName),
parse_mutable_type(VarSet, TypeTerm, MaybeType),
@@ -3644,7 +3693,7 @@
% passes attempting to reuse this variable when fresh variables are
% allocated.
ItemMutable = item_mutable_info(Name, Type, Value, Inst, MutAttrs,
- ProgVarSet, Context),
+ ProgVarSet, Context, SeqNum),
Item = item_mutable(ItemMutable),
MaybeItem = ok1(Item)
;
@@ -4557,70 +4606,43 @@
%-----------------------------------------------------------------------------%
:- pred make_module_defn(maker(list(module_specifier), module_defn)::maker,
- prog_context::in, list(module_specifier)::in, item::out) is det.
+ prog_context::in, int::in, list(module_specifier)::in, item::out) is det.
-make_module_defn(MakeModuleDefnPred, Context, ModuleSpecs, Item) :-
+make_module_defn(MakeModuleDefnPred, Context, SeqNum, ModuleSpecs, Item) :-
call(MakeModuleDefnPred, ModuleSpecs, ModuleDefn),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn).
-:- func make_pseudo_import_module_decl(prog_context, module_specifier) = item.
+:- pred make_pseudo_import_module_decl(prog_context::in, int::in,
+ module_specifier::in, item::out) is det.
-make_pseudo_import_module_decl(Context, ModuleSpecifier) = Item :-
+make_pseudo_import_module_decl(Context, SeqNum, ModuleSpecifier, Item) :-
ModuleDefn = md_import([ModuleSpecifier]),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn).
-:- func make_pseudo_use_module_decl(prog_context, module_specifier) = item.
+:- pred make_pseudo_use_module_decl(prog_context::in, int::in,
+ module_specifier::in, item::out) is det.
-make_pseudo_use_module_decl(Context, ModuleSpecifier) = Item :-
+make_pseudo_use_module_decl(Context, SeqNum, ModuleSpecifier, Item) :-
ModuleDefn = md_use([ModuleSpecifier]),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn).
-:- func make_pseudo_include_module_decl(prog_context, module_name) = item.
+:- pred make_pseudo_include_module_decl(prog_context::in, int::in,
+ module_name::in, item::out) is det.
-make_pseudo_include_module_decl(Context, ModuleSpecifier) = Item :-
+make_pseudo_include_module_decl(Context, SeqNum, ModuleSpecifier, Item) :-
ModuleDefn = md_include_module([ModuleSpecifier]),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn).
-:- pred make_type_defn(varset::in, condition::in, prog_context::in,
- processed_type_body::in, item::out) is det.
-
-make_type_defn(VarSet0, Condition, Context, ProcessedTypeBody, Item) :-
- ProcessedTypeBody = processed_type_body(Name, Args, TypeDefn),
- varset.coerce(VarSet0, VarSet),
- ItemTypeDefn = item_type_defn_info(VarSet, Name, Args, TypeDefn,
- Condition, Context),
- Item = item_type_defn(ItemTypeDefn).
-
-:- pred make_inst_defn(varset::in, condition::in, prog_context::in,
- processed_inst_body::in, item::out) is det.
-
-make_inst_defn(VarSet0, Condition, Context, ProcessedInstBody, Item) :-
- ProcessedInstBody = processed_inst_body(Name, Params, InstDefn),
- varset.coerce(VarSet0, VarSet),
- ItemInstDefn = item_inst_defn_info(VarSet, Name, Params, InstDefn,
- Condition, Context),
- Item = item_inst_defn(ItemInstDefn).
-
-:- pred make_mode_defn(varset::in, condition::in, prog_context::in,
- processed_mode_body::in, item::out) is det.
-
-make_mode_defn(VarSet0, Condition, Context, ProcessedModeBody, Item) :-
- ProcessedModeBody = processed_mode_body(Name, Params, ModeDefn),
- varset.coerce(VarSet0, VarSet),
- ItemModeDefn = item_mode_defn_info(VarSet, Name, Params, ModeDefn,
- Condition, Context),
- Item = item_mode_defn(ItemModeDefn).
-
-:- pred make_external(maybe(backend)::in, prog_context::in,
+:- pred make_external(maybe(backend)::in, prog_context::in, int::in,
sym_name_specifier::in, item::out) is det.
-make_external(MaybeBackend, Context, SymSpec, Item) :-
+make_external(MaybeBackend, Context, SeqNum, SymSpec, Item) :-
ModuleDefn = md_external(MaybeBackend, SymSpec),
- ItemModuleDefn = item_module_defn_info(ModuleDefn, Context),
+ ItemModuleDefn = item_module_defn_info(ModuleDefn, Context, SeqNum),
Item = item_module_defn(ItemModuleDefn).
%-----------------------------------------------------------------------------%
Index: compiler/prog_io_dcg.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_dcg.m,v
retrieving revision 1.44
diff -u -b -r1.44 prog_io_dcg.m
--- compiler/prog_io_dcg.m 16 Jul 2008 03:30:30 -0000 1.44
+++ compiler/prog_io_dcg.m 25 Jul 2008 15:03:54 -0000
@@ -35,7 +35,7 @@
%-----------------------------------------------------------------------------%
:- pred parse_dcg_clause(module_name::in, varset::in, term::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
% parse_dcg_pred_goal(GoalTerm, MaybeGoal, DCGVarInitial, DCGVarFinal,
% !Varset):
@@ -62,7 +62,7 @@
%-----------------------------------------------------------------------------%
parse_dcg_clause(ModuleName, VarSet0, DCG_Head, DCG_Body, DCG_Context,
- Result) :-
+ SeqNum, MaybeItem) :-
varset.coerce(VarSet0, ProgVarSet0),
new_dcg_var(ProgVarSet0, ProgVarSet1, counter.init(0), Counter0,
DCG_0_Var),
@@ -76,10 +76,10 @@
parse_implicitly_qualified_term(ModuleName, DCG_Head, DCG_Body,
VarSet0, HeadContextPieces, HeadResult),
process_dcg_clause(HeadResult, ProgVarSet, DCG_0_Var, DCG_Var, Body,
- DCG_Context, Result)
+ DCG_Context, SeqNum, MaybeItem)
;
MaybeBody = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
).
%-----------------------------------------------------------------------------%
@@ -713,16 +713,17 @@
).
:- pred process_dcg_clause(maybe_functor::in, prog_varset::in, prog_var::in,
- prog_var::in, goal::in, prog_context::in, maybe1(item)::out) is det.
+ prog_var::in, goal::in, prog_context::in, int::in, maybe1(item)::out)
+ is det.
process_dcg_clause(MaybeFunctor, VarSet, Var0, Var, Body, Context,
- MaybeItem) :-
+ SeqNum, MaybeItem) :-
(
MaybeFunctor = ok2(Name, Args0),
list.map(term.coerce, Args0, Args1),
Args = Args1 ++ [variable(Var0, Context), variable(Var, Context)],
ItemClause = item_clause_info(user, VarSet, pf_predicate, Name, Args,
- Body, Context),
+ Body, Context, SeqNum),
Item = item_clause(ItemClause),
MaybeItem = ok1(Item)
;
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.135
diff -u -b -r1.135 prog_io_pragma.m
--- compiler/prog_io_pragma.m 16 Jul 2008 03:30:30 -0000 1.135
+++ compiler/prog_io_pragma.m 26 Jul 2008 03:01:36 -0000
@@ -32,7 +32,7 @@
% necessarily a pragma item.
%
:- pred parse_pragma(module_name::in, varset::in, list(term)::in,
- prog_context::in, maybe1(item)::out) is semidet.
+ prog_context::in, int::in, maybe1(item)::out) is semidet.
% Parse a term that represents a foreign language.
%
@@ -63,26 +63,26 @@
%-----------------------------------------------------------------------------%
-parse_pragma(ModuleName, VarSet, PragmaTerms, Context, Result) :-
+parse_pragma(ModuleName, VarSet, PragmaTerms, Context, SeqNum, MaybeItem) :-
(
PragmaTerms = [SinglePragmaTerm0],
parse_type_decl_where_part_if_present(non_solver_type, ModuleName,
- VarSet, SinglePragmaTerm0, SinglePragmaTerm, WherePartResult),
+ VarSet, SinglePragmaTerm0, SinglePragmaTerm, MaybeWherePart),
SinglePragmaTerm = term.functor(term.atom(PragmaName), PragmaArgs,
_Context),
parse_pragma_type(ModuleName, PragmaName, PragmaArgs, SinglePragmaTerm,
- VarSet, Context, Result0)
+ VarSet, Context, SeqNum, MaybeItem0)
->
(
% The code to process `where' attributes will return an error
% result if solver attributes are given for a non-solver type.
% Because this is a non-solver type, if the unification with
- % WhereResult succeeds then _NoSolverTypeDetails is guaranteed to
- % be `no'.
- WherePartResult = ok2(_NoSolverTypeDetails, MaybeUserEqComp),
+ % MaybeWherePart succeeds then _SolverTypeDetails is guaranteed
+ % to be `no'.
+ MaybeWherePart = ok2(_SolverTypeDetails, MaybeUserEqComp),
(
MaybeUserEqComp = yes(_),
- Result0 = ok1(Item0)
+ MaybeItem0 = ok1(Item0)
->
(
Item0 = item_type_defn(ItemTypeDefn0),
@@ -93,7 +93,7 @@
parse_tree_foreign_type(Type, MaybeUserEqComp,
Assertions),
Item = item_type_defn(ItemTypeDefn),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: unexpected"),
quote("where equality/comparison is"),
@@ -101,14 +101,14 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(SinglePragmaTerm0),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
- Result = Result0
+ MaybeItem = MaybeItem0
)
;
- WherePartResult = error2(Specs),
- Result = error1(Specs)
+ MaybeWherePart = error2(Specs),
+ MaybeItem = error1(Specs)
)
;
fail
@@ -117,63 +117,67 @@
%----------------------------------------------------------------------------%
:- pred parse_pragma_type(module_name::in, string::in, list(term)::in,
- term::in, varset::in, prog_context::in, maybe1(item)::out) is semidet.
+ term::in, varset::in, prog_context::in, int::in, maybe1(item)::out)
+ is semidet.
parse_pragma_type(ModuleName, PragmaName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
(
PragmaName = "source_file",
- parse_pragma_source_file(PragmaTerms, ErrorTerm, Context, Result)
+ parse_pragma_source_file(PragmaTerms, ErrorTerm,
+ Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_type",
parse_pragma_foreign_type(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_decl",
parse_pragma_foreign_decl_pragma(ModuleName, PragmaName,
- PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "c_header_code",
parse_pragma_c_header_code(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_code",
parse_pragma_foreign_code_pragma(ModuleName, PragmaName,
- PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_proc",
parse_pragma_foreign_proc_pragma(ModuleName, PragmaName,
- PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_export_enum",
parse_pragma_foreign_export_enum(PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_enum",
parse_pragma_foreign_enum(PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_export",
parse_pragma_foreign_export(PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "c_code",
parse_pragma_c_code(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "c_import_module",
- parse_pragma_c_import_module(PragmaTerms, ErrorTerm, Context, Result)
+ parse_pragma_c_import_module(PragmaTerms, ErrorTerm,
+ Context, SeqNum, MaybeItem)
;
PragmaName = "foreign_import_module",
parse_pragma_foreign_import_module(PragmaTerms, ErrorTerm,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "import",
parse_pragma_import(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "export",
- parse_pragma_export(PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ parse_pragma_export(PragmaTerms, ErrorTerm, VarSet,
+ Context, SeqNum, MaybeItem)
;
(
PragmaName = "inline",
@@ -217,13 +221,13 @@
Pragma = pragma_mode_check_clauses(Name, Arity))
),
parse_simple_pragma(ModuleName, PragmaName, MakePragma,
- PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "reserve_tag",
MakePragma = (pred(Name::in, Arity::in, Pragma::out) is det :-
Pragma = pragma_reserve_tag(Name, Arity)),
parse_simple_type_pragma(ModuleName, PragmaName, MakePragma,
- PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem)
;
(
PragmaName = "memo",
@@ -240,51 +244,51 @@
EvalMethod = eval_minimal(stack_copy)
),
parse_tabling_pragma(ModuleName, PragmaName, EvalMethod,
- PragmaTerms, ErrorTerm, VarSet, Context, Result)
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "unused_args",
parse_pragma_unused_args(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "type_spec",
parse_pragma_type_spec(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "fact_table",
- parse_pragma_fact_table(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result)
+ parse_pragma_fact_table(ModuleName, PragmaTerms, ErrorTerm, VarSet,
+ Context, SeqNum, MaybeItem)
;
PragmaName = "termination_info",
parse_pragma_termination_info(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result)
+ VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "termination2_info",
parse_pragma_termination2_info(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result)
+ VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "structure_sharing",
parse_pragma_structure_sharing(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result)
+ VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "structure_reuse",
parse_pragma_structure_reuse(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result)
+ VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "exceptions",
parse_pragma_exceptions(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "trailing_info",
parse_pragma_trailing_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result)
+ Context, SeqNum, MaybeItem)
;
PragmaName = "mm_tabling_info",
parse_pragma_mm_tabling_info(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result)
+ VarSet, Context, SeqNum, MaybeItem)
;
PragmaName = "require_feature_set",
parse_pragma_require_feature_set(PragmaTerms, VarSet, ErrorTerm,
- Context, Result)
+ Context, SeqNum, MaybeItem)
).
%----------------------------------------------------------------------------%
@@ -295,15 +299,15 @@
% predicates for related xxxs together.
:- pred parse_pragma_source_file(list(term)::in, term::in, prog_context::in,
- maybe1(item)::out) is det.
+ int::in, maybe1(item)::out) is det.
-parse_pragma_source_file(PragmaTerms, ErrorTerm, Context, Result) :-
+parse_pragma_source_file(PragmaTerms, ErrorTerm, Context, SeqNum, MaybeItem) :-
( PragmaTerms = [SourceFileTerm] ->
( SourceFileTerm = term.functor(term.string(SourceFile), [], _) ->
Pragma = pragma_source_file(SourceFile),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: the argument of a"),
quote(":- pragma source_file"),
@@ -311,21 +315,21 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(SourceFileTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma source_file"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_foreign_type(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_foreign_type(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
(
(
PragmaTerms = [LangTerm, MercuryTypeTerm, ForeignTypeTerm],
@@ -358,9 +362,9 @@
MercuryTypeSymName, MercuryParams,
parse_tree_foreign_type(ForeignType, no,
Assertions),
- cond_true, Context),
+ cond_true, Context, SeqNum),
Item = item_type_defn(ItemTypeDefn),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
MaybeAssertionTerm = yes(ErrorAssertionTerm)
->
@@ -371,7 +375,7 @@
phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorAssertionTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
;
unexpected(this_file,
"parse_pragma_type: unexpected failure of " ++
@@ -379,42 +383,43 @@
)
;
MaybeTypeDefnHead = error2(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
MaybeForeignType = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: invalid foreign language in"),
quote(":- pragma foreign_type"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(LangTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma foreign_type"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_c_header_code(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_c_header_code(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
( PragmaTerms = [term.functor(_, _, Context) | _] ->
LangC = term.functor(term.string("C"), [], Context),
parse_pragma_foreign_decl_pragma(ModuleName, "c_header_code",
- [LangC | PragmaTerms], ErrorTerm, VarSet, Context, Result)
+ [LangC | PragmaTerms], ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem)
;
Pieces = [words("Error: wrong number or unexpected variable in"),
quote(":- pragma c_header_code"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
%----------------------------------------------------------------------------%
@@ -423,10 +428,10 @@
%
:- pred parse_pragma_foreign_export_enum(list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_foreign_export_enum(PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
(
(
PragmaTerms = [LangTerm, MercuryTypeTerm],
@@ -460,20 +465,20 @@
Overrides
),
ItemPragma = item_pragma_info(user, PragmaExportEnum,
- Context),
+ Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
MaybeOverrides = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
MaybeAttributes = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
MaybeType = error2(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: invalid foreign language in"),
@@ -482,27 +487,27 @@
% XXX Get_term_context(LangTerm) would be better.
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma foreign_export_enum"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_export_enum_type(term::in, maybe2(sym_name, arity)::out) is det.
-parse_export_enum_type(TypeTerm, Result) :-
+parse_export_enum_type(TypeTerm, MaybeNameAndArity) :-
( parse_name_and_arity(TypeTerm, Name, Arity) ->
- Result = ok2(Name, Arity)
+ MaybeNameAndArity = ok2(Name, Arity)
;
Pieces = [words("Error: expected name/arity for type in"),
quote(":- pragma foreign_export_enum"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(TypeTerm), [always(Pieces)])]),
- Result = error2([Spec])
+ MaybeNameAndArity = error2([Spec])
).
:- pred maybe_parse_export_enum_overrides(varset::in, maybe(term)::in,
@@ -623,17 +628,17 @@
:- pred parse_export_enum_attr(varset::in, term::in,
maybe1(collected_export_enum_attribute)::out) is det.
-parse_export_enum_attr(VarSet, Term, Result) :-
+parse_export_enum_attr(VarSet, Term, MaybeAttribute) :-
(
Term = functor(atom("prefix"), Args, _),
Args = [ ForeignNameTerm ],
ForeignNameTerm = functor(string(Prefix), [], _)
->
- Result = ok1(ee_attr_prefix(yes(Prefix)))
+ MaybeAttribute = ok1(ee_attr_prefix(yes(Prefix)))
;
Term = functor(atom("uppercase"), [], _)
->
- Result = ok1(ee_attr_upper(uppercase_export_enum))
+ MaybeAttribute = ok1(ee_attr_upper(uppercase_export_enum))
;
TermStr = describe_error_term(VarSet, Term),
Pieces = [words("Error: unrecognised attribute in"),
@@ -641,7 +646,7 @@
words(TermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(Term), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeAttribute = error1([Spec])
).
%----------------------------------------------------------------------------%
@@ -650,9 +655,10 @@
%
:- pred parse_pragma_foreign_enum(list(term)::in, term::in, varset::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_pragma_foreign_enum(PragmaTerms, ErrorTerm, VarSet, Context, Result) :-
+parse_pragma_foreign_enum(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem) :-
( PragmaTerms = [LangTerm, MercuryTypeTerm, ValuesTerm] ->
( parse_foreign_language(LangTerm, ForeignLanguage) ->
parse_export_enum_type(MercuryTypeTerm, MaybeType),
@@ -669,16 +675,16 @@
PragmaForeignImportEnum = pragma_foreign_enum(
ForeignLanguage, TypeName, TypeArity, Values),
ItemPragma = item_pragma_info(user,
- PragmaForeignImportEnum, Context),
+ PragmaForeignImportEnum, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
MaybeValues = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
MaybeType = error2(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: invalid foreign language in"),
@@ -687,14 +693,14 @@
% XXX We should use the context of LangTerm.
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma foreign_export_enum"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
%----------------------------------------------------------------------------%
@@ -703,23 +709,25 @@
%
:- pred parse_pragma_foreign_export(list(term)::in, term::in, varset::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_pragma_foreign_export(PragmaTerms, ErrorTerm, VarSet, Context, Result) :-
+parse_pragma_foreign_export(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem) :-
( PragmaTerms = [LangTerm, PredAndModesTerm, FunctionTerm] ->
( FunctionTerm = term.functor(term.string(Function), [], _) ->
ContextPieces = [words("In"),
quote(":- pragma foreign_export"), words("declaration")],
parse_pred_or_func_and_arg_modes(no, PredAndModesTerm,
- ErrorTerm, VarSet, ContextPieces, PredAndModesResult),
+ ErrorTerm, VarSet, ContextPieces, MaybePredAndModes),
(
- PredAndModesResult = ok2(PredName - PredOrFunc, Modes),
+ MaybePredAndModes = ok2(PredName - PredOrFunc, Modes),
( parse_foreign_language(LangTerm, ForeignLanguage) ->
Pragma = pragma_foreign_export(ForeignLanguage, PredName,
PredOrFunc, Modes, Function),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context,
+ SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: invalid foreign language in"),
quote(":- pragma foreign_export"),
@@ -727,11 +735,11 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(LangTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
- PredAndModesResult = error2(Specs),
- Result = error1(Specs)
+ MaybePredAndModes = error2(Specs),
+ MaybeItem = error1(Specs)
)
;
% XXX Why this wording?
@@ -742,23 +750,23 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(PredAndModesTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma foreign_export"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
%----------------------------------------------------------------------------%
:- pred parse_pragma_c_code(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_c_code(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
% pragma c_code is almost as if we have written foreign_code
% or foreign_proc with the language set to "C".
% There are a few differences (error messages, some deprecated
@@ -770,64 +778,68 @@
->
LangC = term.functor(term.string("C"), [], FirstContext),
parse_pragma_foreign_code_pragma(ModuleName, "c_code",
- [LangC | PragmaTerms], ErrorTerm, VarSet, Context, Result)
+ [LangC | PragmaTerms], ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem)
;
% arity > 1 (same as foreign_proc)
PragmaTerms = [term.functor(_, _, FirstContext) | _]
->
LangC = term.functor(term.string("C"), [], FirstContext),
parse_pragma_foreign_proc_pragma(ModuleName, "c_code",
- [LangC | PragmaTerms], ErrorTerm, VarSet, Context, Result)
+ [LangC | PragmaTerms], ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem)
;
Pieces = [words("Error: wrong number of arguments"),
words("or unexpected variable in"),
quote(":- pragma c_code"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_c_import_module(list(term)::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_pragma_c_import_module(PragmaTerms, ErrorTerm, Context, Result) :-
+parse_pragma_c_import_module(PragmaTerms, ErrorTerm, Context, SeqNum,
+ MaybeItem) :-
(
PragmaTerms = [ImportTerm],
sym_name_and_args(ImportTerm, Import, [])
->
Pragma = pragma_foreign_import_module(lang_c, Import),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: wrong number of arguments"),
words("or invalid module name in"),
quote(":- pragma c_import_module"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_foreign_import_module(list(term)::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_pragma_foreign_import_module(PragmaTerms, ErrorTerm, Context, Result) :-
+parse_pragma_foreign_import_module(PragmaTerms, ErrorTerm, Context, SeqNum,
+ MaybeItem) :-
(
PragmaTerms = [LangTerm, ImportTerm],
sym_name_and_args(ImportTerm, Import, [])
->
( parse_foreign_language(LangTerm, Language) ->
Pragma = pragma_foreign_import_module(Language, Import),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: invalid foreign language in"),
quote(":- pragma foreign_import_module"),
words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(LangTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments"),
@@ -836,14 +848,14 @@
words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_import(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_import(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
% XXX We assume all imports are C.
ForeignLanguage = lang_c,
(
@@ -852,13 +864,14 @@
FlagsContextPieces = [words("In second argument of"),
quote(":- pragma import/3"), words("declaration:")],
parse_pragma_foreign_proc_attributes_term(ForeignLanguage,
- "import", VarSet, FlagsTerm, FlagsContextPieces, FlagsResult)
+ "import", VarSet, FlagsTerm, FlagsContextPieces,
+ MaybeAttributes)
;
PragmaTerms = [PredAndModesTerm, FunctionTerm],
Flags0 = default_attributes(ForeignLanguage),
% Pragma import uses legacy purity behaviour.
set_legacy_purity_behaviour(yes, Flags0, Flags),
- FlagsResult = ok1(Flags)
+ MaybeAttributes = ok1(Flags)
)
->
( FunctionTerm = term.functor(term.string(Function), [], _) ->
@@ -866,23 +879,24 @@
quote(":- pragma import"), words("declaration:")],
parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm,
ErrorTerm, VarSet, PredAndModesContextPieces,
- PredAndArgModesResult),
+ MaybePredAndArgModes),
(
- PredAndArgModesResult = ok2(PredName - PredOrFunc, ArgModes),
+ MaybePredAndArgModes = ok2(PredName - PredOrFunc, ArgModes),
(
- FlagsResult = ok1(Attributes),
+ MaybeAttributes = ok1(Attributes),
Pragma = pragma_import(PredName, PredOrFunc, ArgModes,
Attributes, Function),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context,
+ SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
- FlagsResult = error1(FlagsSpecs),
- Result = error1(FlagsSpecs)
+ MaybeAttributes = error1(FlagsSpecs),
+ MaybeItem = error1(FlagsSpecs)
)
;
- PredAndArgModesResult = error2(Specs),
- Result = error1(Specs)
+ MaybePredAndArgModes = error2(Specs),
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: expected pragma"),
@@ -891,36 +905,37 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(PredAndModesTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma import"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_export(list(term)::in, term::in, varset::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
-parse_pragma_export(PragmaTerms, ErrorTerm, VarSet, Context, Result) :-
+parse_pragma_export(PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem) :-
( PragmaTerms = [PredAndModesTerm, FunctionTerm] ->
( FunctionTerm = term.functor(term.string(Function), [], _) ->
- ContextPieces = [words("In"),
- quote(":- pragma export"), words("declaration:")],
+ ContextPieces = [words("In"), quote(":- pragma export"),
+ words("declaration:")],
parse_pred_or_func_and_arg_modes(no, PredAndModesTerm, ErrorTerm,
- VarSet, ContextPieces, PredAndModesResult),
+ VarSet, ContextPieces, MaybePredAndModes),
(
- PredAndModesResult = ok2(PredName - PredOrFunc, Modes),
+ MaybePredAndModes = ok2(PredName - PredOrFunc, Modes),
Pragma = pragma_foreign_export(lang_c, PredName, PredOrFunc,
Modes, Function),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
- PredAndModesResult = error2(Specs),
- Result = error1(Specs)
+ MaybePredAndModes = error2(Specs),
+ MaybeItem = error1(Specs)
)
;
% XXX Why this wording?
@@ -930,57 +945,56 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(PredAndModesTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma export"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_unused_args(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_unused_args(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
% pragma unused_args should never appear in user programs,
% only in .opt files.
(
- PragmaTerms = [PredOrFuncTerm, PredNameTerm,
- term.functor(term.integer(Arity), [], _),
- term.functor(term.integer(ModeNum), [], _),
- UnusedArgsTerm
- ],
+ PragmaTerms = [PredOrFuncTerm, PredNameTerm, ArityTerm, ModeNumTerm,
+ UnusedArgsTerm],
+ ArityTerm = term.functor(term.integer(Arity), [], _),
+ ModeNumTerm = term.functor(term.integer(ModeNum), [], _),
parse_predicate_or_function(PredOrFuncTerm, PredOrFunc),
ContextPieces = [words("In"), quote(":- pragma unused_args"),
words("declaration:")],
parse_implicitly_qualified_term(ModuleName, PredNameTerm, ErrorTerm,
- VarSet, ContextPieces, PredNameResult),
- PredNameResult = ok2(PredName, []),
- convert_int_list(VarSet, UnusedArgsTerm, UnusedArgsResult),
- UnusedArgsResult = ok1(UnusedArgs)
+ VarSet, ContextPieces, MaybePredName),
+ MaybePredName = ok2(PredName, []),
+ convert_int_list(VarSet, UnusedArgsTerm, MaybeUnusedArgs),
+ MaybeUnusedArgs = ok1(UnusedArgs)
->
Pragma = pragma_unused_args(PredOrFunc, PredName, Arity, ModeNum,
UnusedArgs),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
% XXX Improve this message.
Pieces = [words("Error in"), quote(":- pragma unused_args"),
suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_type_spec(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
-parse_pragma_type_spec(ModuleName, PragmaTerms, ErrorTerm, VarSet0, Context,
- Result) :-
+parse_pragma_type_spec(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
+ SeqNum, MaybeItem) :-
(
(
PragmaTerms = [PredAndModesTerm, TypeSubnTerm],
@@ -997,7 +1011,7 @@
% only if it isn't used.
NameContextPieces = [],
parse_implicitly_qualified_term(ModuleName, SpecNameTerm,
- ErrorTerm, VarSet0, NameContextPieces, NameResult),
+ ErrorTerm, VarSet, NameContextPieces, NameResult),
NameResult = ok2(SpecName, []),
MaybeName = yes(SpecName)
)
@@ -1005,14 +1019,15 @@
ArityOrModesContextPieces = [words("In"), quote(":- pragma type_spec"),
words("declaration:")],
parse_arity_or_modes(ModuleName, PredAndModesTerm, ErrorTerm,
- VarSet0, ArityOrModesContextPieces, ArityOrModesResult),
+ VarSet, ArityOrModesContextPieces, MaybeArityOrModes),
(
- ArityOrModesResult = ok1(arity_or_modes(PredName, Arity,
- MaybePredOrFunc, MaybeModes)),
+ MaybeArityOrModes = ok1(ArityOrModes),
+ ArityOrModes = arity_or_modes(PredName, Arity, MaybePredOrFunc,
+ MaybeModes),
conjunction_to_list(TypeSubnTerm, TypeSubnList),
% The varset is actually a tvarset.
- varset.coerce(VarSet0, TVarSet),
+ varset.coerce(VarSet, TVarSet),
( list.map(convert_type_spec_pair, TypeSubnList, TypeSubn) ->
(
MaybeName = yes(SpecializedName0),
@@ -1026,76 +1041,76 @@
),
Pragma = pragma_type_spec(PredName, SpecializedName, Arity,
MaybePredOrFunc, MaybeModes, TypeSubn, TVarSet, set.init),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: expected type substitution in"),
quote(":- pragma type_spec"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(TypeSubnTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
- ArityOrModesResult = error1(Specs),
- Result = error1(Specs)
+ MaybeArityOrModes = error1(Specs),
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma type_spec"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_fact_table(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_fact_table(ModuleName, PragmaTerms, ErrorTerm,
- VarSet, Context, Result) :-
+ VarSet, Context, SeqNum, MaybeItem) :-
( PragmaTerms = [PredAndArityTerm, FileNameTerm] ->
parse_pred_name_and_arity(ModuleName, "fact_table",
- PredAndArityTerm, ErrorTerm, VarSet, NameArityResult),
+ PredAndArityTerm, ErrorTerm, VarSet, MaybeNameAndArity),
(
- NameArityResult = ok2(PredName, Arity),
+ MaybeNameAndArity = ok2(PredName, Arity),
( FileNameTerm = term.functor(term.string(FileName), [], _) ->
Pragma = pragma_fact_table(PredName, Arity, FileName),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error: expected string"),
words("for fact table filename."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(FileNameTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
- NameArityResult = error2(Specs),
- Result = error1(Specs)
+ MaybeNameAndArity = error2(Specs),
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma fact_table"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_termination_info(module_name::in, list(term)::in,
- term::in, varset::in, prog_context::in, maybe1(item)::out) is det.
+ term::in, varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_termination_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
(
PragmaTerms = [PredAndModesTerm0, ArgSizeTerm, TerminationTerm],
ContextPieces = [words("In"),
quote(":- pragma termination_info"), words("declaration:")],
parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
- ErrorTerm, VarSet, ContextPieces, NameAndModesResult),
- NameAndModesResult = ok2(PredName - PredOrFunc, ModeList),
+ ErrorTerm, VarSet, ContextPieces, MaybeNameAndModes),
+ MaybeNameAndModes = ok2(PredName - PredOrFunc, ModeList),
ArgSizeTerm = term.functor(term.atom(ArgSizeFunctor),
ArgSizeArgTerms, _),
(
@@ -1127,22 +1142,22 @@
->
Pragma = pragma_termination_info(PredOrFunc, PredName, ModeList,
MaybeArgSizeInfo, MaybeTerminationInfo),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Syntax error in"),
quote(":- pragma termination_info"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_termination2_info(module_name::in, list(term)::in,
- term::in, varset::in, prog_context::in, maybe1(item)::out) is det.
+ term::in, varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_termination2_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
(
PragmaTerms = [PredAndModesTerm0, SuccessArgSizeTerm,
FailureArgSizeTerm, TerminationTerm],
@@ -1169,30 +1184,30 @@
->
Pragma = pragma_termination2_info(PredOrFunc, PredName, ModeList,
SuccessArgSizeInfo, FailureArgSizeInfo, MaybeTerminationInfo),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Syntax error in"),
quote(":- pragma termination2_info"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_structure_sharing(module_name::in, list(term)::in,
- term::in, varset::in, prog_context::in, maybe1(item)::out) is det.
+ term::in, varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_structure_sharing(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
(
PragmaTerms = [PredAndModesTerm0, HeadVarsTerm,
HeadVarTypesTerm, SharingInformationTerm],
ModesContextPieces = [words("In"),
quote(":- pragma structure_sharing"), words("declaration:")],
parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
- ErrorTerm, VarSet, ModesContextPieces, NameAndModesResult),
- NameAndModesResult = ok2(PredName - PredOrFunc, ModeList),
+ ErrorTerm, VarSet, ModesContextPieces, MaybeNameAndModes),
+ MaybeNameAndModes = ok2(PredName - PredOrFunc, ModeList),
% Parse the head variables:
HeadVarsTerm = term.functor(term.atom("vars"), ListHVTerm, _),
@@ -1219,30 +1234,30 @@
->
Pragma = pragma_structure_sharing(PredOrFunc, PredName, ModeList,
HeadVars, Types, MaybeSharingAs),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Syntax error in"),
quote(":- pragma structure_sharing"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_structure_reuse(module_name::in, list(term)::in,
- term::in, varset::in, prog_context::in, maybe1(item)::out) is det.
+ term::in, varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_structure_reuse(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
(
PragmaTerms = [PredAndModesTerm0, HeadVarsTerm,
HeadVarTypesTerm, MaybeStructureReuseTerm],
ReuseContextPieces = [words("In"), quote(":- pragma structure_reuse"),
words("declaration:")],
parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
- ErrorTerm, VarSet, ReuseContextPieces, NameAndModesResult),
- NameAndModesResult = ok2(PredName - PredOrFunc, ModeList),
+ ErrorTerm, VarSet, ReuseContextPieces, MaybeNameAndModes),
+ MaybeNameAndModes = ok2(PredName - PredOrFunc, ModeList),
% Parse the head variables:
HeadVarsTerm = term.functor(term.atom("vars"), ListHVTerm, _),
@@ -1258,7 +1273,7 @@
ReuseArgTerms, _),
(
ReuseFunctor = "not_available",
- % XXX Why don't we test ReusegArgTerms?
+ % XXX Why don't we test ReuseArgTerms?
MaybeStructureReuse = no
;
ReuseFunctor = "yes",
@@ -1269,22 +1284,22 @@
->
Pragma = pragma_structure_reuse(PredOrFunc, PredName, ModeList,
HeadVars, Types, MaybeStructureReuse),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Syntax error in"),
quote(":- pragma structure_reuse"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_exceptions(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_exceptions(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
(
PragmaTerms = [PredOrFuncTerm, PredNameTerm, ArityTerm, ModeNumTerm,
ThrowStatusTerm],
@@ -1294,8 +1309,8 @@
ContextPieces = [words("In"), quote(":- pragma exceptions"),
words("declaration:")],
parse_implicitly_qualified_term(ModuleName, PredNameTerm, ErrorTerm,
- VarSet, ContextPieces, PredNameResult),
- PredNameResult = ok2(PredName, []),
+ VarSet, ContextPieces, MaybePredNameAndArgs),
+ MaybePredNameAndArgs = ok2(PredName, []),
ThrowStatusTerm = term.functor(term.atom(ThrowStatusFunctor),
ThrowStatusArgTerms, _),
(
@@ -1323,22 +1338,22 @@
->
Pragma = pragma_exceptions(PredOrFunc, PredName, Arity, ModeNum,
ThrowStatus),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error in"),
quote(":- pragma exceptions"), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_trailing_info(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_trailing_info(ModuleName, PragmaTerms, ErrorTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
(
PragmaTerms = [PredOrFuncTerm, PredNameTerm, ArityTerm, ModeNumTerm,
TrailingStatusTerm],
@@ -1348,8 +1363,8 @@
ContextPieces = [words("In"), quote(":- pragma trailing_info"),
words("declaration:")],
parse_implicitly_qualified_term(ModuleName, PredNameTerm, ErrorTerm,
- VarSet, ContextPieces, PredNameResult),
- PredNameResult = ok2(PredName, []),
+ VarSet, ContextPieces, MaybePredNameAndArgs),
+ MaybePredNameAndArgs = ok2(PredName, []),
TrailingStatusTerm = term.functor(term.atom(TrailingStatusFunctor),
[], _),
(
@@ -1365,22 +1380,22 @@
->
Pragma = pragma_trailing_info(PredOrFunc, PredName, Arity, ModeNum,
TrailingStatus),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error in"), quote(":- pragma trailing_info"),
suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_mm_tabling_info(module_name::in, list(term)::in, term::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_mm_tabling_info(ModuleName, PragmaTerms, ErrorTerm, VarSet,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
(
PragmaTerms = [PredOrFuncTerm, PredNameTerm, ArityTerm, ModeNumTerm,
MM_TablingStatusTerm],
@@ -1390,8 +1405,8 @@
ContextPieces = [words("In"), quote(":- pragma mm_tabling_info"),
words("declaration:")],
parse_implicitly_qualified_term(ModuleName, PredNameTerm, ErrorTerm,
- VarSet, ContextPieces, PredNameResult),
- PredNameResult = ok2(PredName, []),
+ VarSet, ContextPieces, MaybePredNameAndArgs),
+ MaybePredNameAndArgs = ok2(PredName, []),
MM_TablingStatusTerm = term.functor(term.atom(MM_TablingStatusFunctor),
[], _),
(
@@ -1407,22 +1422,22 @@
->
Pragma = pragma_mm_tabling_info(PredOrFunc, PredName, Arity, ModeNum,
MM_TablingStatus),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = [words("Error in"), quote(":- pragma mm_tabling_info"),
suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_require_feature_set(list(term)::in, varset::in, term::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_require_feature_set(PragmaTerms, VarSet, ErrorTerm, Context,
- Result) :-
+ SeqNum, MaybeItem) :-
( PragmaTerms = [FeatureListTerm] ->
UnrecognizedPieces = [words("Error: expected a feature"), nl],
convert_maybe_list("features", yes(VarSet), FeatureListTerm,
@@ -1444,31 +1459,32 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(FeatureListTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
;
(
FeatureList = [],
- ItemNothing = item_nothing_info(no, Context),
+ ItemNothing = item_nothing_info(no, Context, SeqNum),
Item = item_nothing(ItemNothing)
;
FeatureList = [_ | _],
FeatureSet = set.from_list(FeatureList),
Pragma = pragma_require_feature_set(FeatureSet),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context,
+ SeqNum),
Item = item_pragma(ItemPragma)
),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
)
;
MaybeFeatureList = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Syntax error in"),
quote(":- pragma require_feature_set"), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
%----------------------------------------------------------------------------%
@@ -1498,55 +1514,57 @@
:- pred parse_foreign_language_type(term::in, varset::in, foreign_language::in,
maybe1(foreign_language_type)::out) is det.
-parse_foreign_language_type(InputTerm, VarSet, Language, Result) :-
+parse_foreign_language_type(InputTerm, VarSet, Language,
+ MaybeForeignLangType) :-
(
Language = lang_il,
( InputTerm = term.functor(term.string(ILTypeName), [], _) ->
- parse_il_type_name(ILTypeName, InputTerm, VarSet, Result)
+ parse_il_type_name(ILTypeName, InputTerm, VarSet,
+ MaybeForeignLangType)
;
InputTermStr = describe_error_term(VarSet, InputTerm),
Pieces = [words("Error: invalid backend specification"),
quote(InputTermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(InputTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeForeignLangType = error1([Spec])
)
;
Language = lang_c,
( InputTerm = term.functor(term.string(CTypeName), [], _) ->
- Result = ok1(c(c_type(CTypeName)))
+ MaybeForeignLangType = ok1(c(c_type(CTypeName)))
;
InputTermStr = describe_error_term(VarSet, InputTerm),
Pieces = [words("Error: invalid backend specification"),
quote(InputTermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(InputTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeForeignLangType = error1([Spec])
)
;
Language = lang_java,
( InputTerm = term.functor(term.string(JavaTypeName), [], _) ->
- Result = ok1(java(java_type(JavaTypeName)))
+ MaybeForeignLangType = ok1(java(java_type(JavaTypeName)))
;
InputTermStr = describe_error_term(VarSet, InputTerm),
Pieces = [words("Error: invalid backend specification"),
quote(InputTermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(InputTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeForeignLangType = error1([Spec])
)
;
Language = lang_erlang,
( InputTerm = term.functor(term.string(_ErlangTypeName), [], _) ->
% XXX should we check if the type is blank?
- Result = ok1(erlang(erlang_type))
+ MaybeForeignLangType = ok1(erlang(erlang_type))
;
InputTermStr = describe_error_term(VarSet, InputTerm),
Pieces = [words("Error: invalid backend specification"),
quote(InputTermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(InputTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeForeignLangType = error1([Spec])
)
;
Language = lang_csharp,
@@ -1554,7 +1572,7 @@
words("unable to parse backend type."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(InputTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeForeignLangType = error1([Spec])
).
:- pred parse_il_type_name(string::in, term::in, varset::in,
@@ -1673,11 +1691,11 @@
% This predicate parses both c_header_code and foreign_decl pragmas.
%
:- pred parse_pragma_foreign_decl_pragma(module_name::in, string::in,
- list(term)::in, term::in, varset::in, prog_context::in,
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
maybe1(item)::out) is det.
parse_pragma_foreign_decl_pragma(_ModuleName, PragmaName, PragmaTerms,
- ErrorTerm, VarSet, Context, Result) :-
+ ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
InvalidDeclPieces = [words("Error: invalid"),
quote(":- pragma " ++ PragmaName), words("declaration:")],
(
@@ -1693,9 +1711,9 @@
( HeaderTerm = term.functor(term.string(HeaderCode), [], _) ->
Pragma = pragma_foreign_decl(ForeignLanguage, IsLocal,
HeaderCode),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Pieces = InvalidDeclPieces ++
[words("expected string for foreign declaration code."),
@@ -1703,7 +1721,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeaderTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = InvalidDeclPieces ++
@@ -1711,7 +1729,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(LangTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
TermStr = describe_error_term(VarSet, ErrorTerm),
@@ -1719,7 +1737,7 @@
words("declaration:"), words(TermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
% This predicate parses both c_code and foreign_code pragmas.
@@ -1727,11 +1745,11 @@
% is handled in parse_pragma_foreign_proc_pragma below.
%
:- pred parse_pragma_foreign_code_pragma(module_name::in, string::in,
- list(term)::in, term::in, varset::in, prog_context::in,
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
maybe1(item)::out) is det.
parse_pragma_foreign_code_pragma(_ModuleName, PragmaName, PragmaTerms,
- ErrorTerm, _VarSet, Context, Result) :-
+ ErrorTerm, _VarSet, Context, SeqNum, MaybeItem) :-
InvalidDeclPrefix = [words("Error: invalid"),
quote(":- pragma " ++ PragmaName), words("declaration:")],
( PragmaTerms = [LangTerm, CodeTerm] ->
@@ -1763,29 +1781,29 @@
(
Specs = [],
Pragma = pragma_foreign_code(ForeignLanguage, Code),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
Specs = [_ | _],
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
Pieces = InvalidDeclPrefix ++
[words("wrong number of arguments."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
% This predicate parses both c_code and foreign_proc pragmas.
%
:- pred parse_pragma_foreign_proc_pragma(module_name::in, string::in,
- list(term)::in, term::in, varset::in, prog_context::in,
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
maybe1(item)::out) is det.
parse_pragma_foreign_proc_pragma(ModuleName, PragmaName, PragmaTerms,
- ErrorTerm, VarSet, Context, Result) :-
+ ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
InvalidDeclPrefix = [words("Error: invalid"),
quote(":- pragma " ++ PragmaName), words("declaration:")],
(
@@ -1807,12 +1825,14 @@
RestTerms = [PredAndVarsTerm, CodeTerm],
parse_pragma_ordinary_foreign_proc_pragma_old(ModuleName,
PragmaName, VarSet, PredAndVarsTerm, CodeTerm, ErrorTerm,
- ForeignLanguage, InvalidDeclPrefix, Context, RestResult)
+ ForeignLanguage, InvalidDeclPrefix, Context, SeqNum,
+ MaybeRestItem)
;
RestTerms = [PredAndVarsTerm, FlagsTerm, CodeTerm],
parse_pragma_ordinary_foreign_proc_pragma(ModuleName,
PragmaName, VarSet, PredAndVarsTerm, FlagsTerm, CodeTerm,
- ForeignLanguage, InvalidDeclPrefix, Context, RestResult)
+ ForeignLanguage, InvalidDeclPrefix, Context, SeqNum,
+ MaybeRestItem)
;
RestTerms = [PredAndVarsTerm, FlagsTerm, FieldsTerm,
FirstTerm, LaterTerm],
@@ -1823,35 +1843,37 @@
parse_pragma_model_non_foreign_proc_pragma(ModuleName,
PragmaName, VarSet, PredAndVarsTerm, FlagsTerm,
FieldsTerm, FirstTerm, LaterTerm, SharedTerm,
- ForeignLanguage, InvalidDeclPrefix, Context, RestResult)
+ ForeignLanguage, InvalidDeclPrefix, Context, SeqNum,
+ MaybeRestItem)
;
RestTerms = [PredAndVarsTerm, FlagsTerm, FieldsTerm,
FirstTerm, LaterTerm, SharedTerm],
parse_pragma_model_non_foreign_proc_pragma(ModuleName,
PragmaName, VarSet, PredAndVarsTerm, FlagsTerm,
FieldsTerm, FirstTerm, LaterTerm, SharedTerm,
- ForeignLanguage, InvalidDeclPrefix, Context, RestResult)
+ ForeignLanguage, InvalidDeclPrefix, Context, SeqNum,
+ MaybeRestItem)
)
->
(
- RestResult = ok1(Item),
+ MaybeRestItem = ok1(Item),
(
LangSpecs = [],
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
LangSpecs = [_ | _],
- Result = error1(LangSpecs)
+ MaybeItem = error1(LangSpecs)
)
;
- RestResult = error1(RestSpecs),
- Result = error1(LangSpecs ++ RestSpecs)
+ MaybeRestItem = error1(RestSpecs),
+ MaybeItem = error1(LangSpecs ++ RestSpecs)
)
;
Pieces = InvalidDeclPrefix ++
[words("wrong number of arguments."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
PragmaTerms = [],
@@ -1860,16 +1882,17 @@
[words("wrong number of arguments."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_ordinary_foreign_proc_pragma_old(module_name::in,
string::in, varset::in, term::in, term::in, term::in, foreign_language::in,
- list(format_component)::in, prog_context::in, maybe1(item)::out) is det.
+ list(format_component)::in, prog_context::in, int::in, maybe1(item)::out)
+ is det.
parse_pragma_ordinary_foreign_proc_pragma_old(ModuleName, PragmaName, VarSet,
PredAndVarsTerm, CodeTerm, ErrorTerm, ForeignLanguage,
- InvalidDeclPrefix, Context, Result) :-
+ InvalidDeclPrefix, Context, SeqNum, MaybeItem) :-
% XXX We should issue a warning; this syntax is deprecated. We will
% continue to accept this if c_code is used, but not with foreign_code.
( PragmaName = "c_code" ->
@@ -1878,7 +1901,7 @@
( CodeTerm = term.functor(term.string(Code), [], CodeContext) ->
Impl = fc_impl_ordinary(Code, yes(CodeContext)),
parse_pragma_foreign_code(ModuleName, Attributes,
- PredAndVarsTerm, Impl, VarSet, Context, Result)
+ PredAndVarsTerm, Impl, VarSet, Context, SeqNum, MaybeItem)
;
Pieces = InvalidDeclPrefix ++
[words("expecting either"), quote("may_call_mercury"),
@@ -1886,23 +1909,24 @@
words("and a string for foreign code."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(CodeTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
)
;
Pieces = InvalidDeclPrefix ++
[words("does not say whether it can call Mercury."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pragma_ordinary_foreign_proc_pragma(module_name::in, string::in,
varset::in, term::in, term::in, term::in, foreign_language::in,
- list(format_component)::in, prog_context::in, maybe1(item)::out) is det.
+ list(format_component)::in, prog_context::in, int::in, maybe1(item)::out)
+ is det.
parse_pragma_ordinary_foreign_proc_pragma(ModuleName, PragmaName, VarSet,
SecondTerm, ThirdTerm, CodeTerm, ForeignLanguage, InvalidDeclPrefix,
- Context, Result) :-
+ Context, SeqNum, MaybeItem) :-
CodeContext = get_term_context(CodeTerm),
( CodeTerm = term.functor(term.string(CodePrime), [], _) ->
Code = CodePrime,
@@ -1961,20 +1985,21 @@
Specs = [],
Impl = fc_impl_ordinary(Code, yes(CodeContext)),
parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm,
- Impl, VarSet, Context, Result)
+ Impl, VarSet, Context, SeqNum, MaybeItem)
;
Specs = [_ | _],
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
).
:- pred parse_pragma_model_non_foreign_proc_pragma(module_name::in, string::in,
varset::in, term::in, term::in, term::in, term::in, term::in,
term::in, foreign_language::in, list(format_component)::in,
- prog_context::in, maybe1(item)::out) is det.
+ prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_model_non_foreign_proc_pragma(ModuleName, PragmaName, VarSet,
PredAndVarsTerm, FlagsTerm, FieldsTerm, FirstTerm, LaterTerm,
- SharedTerm, ForeignLanguage, InvalidDeclPrefix, Context, Result) :-
+ SharedTerm, ForeignLanguage, InvalidDeclPrefix, Context, SeqNum,
+ MaybeItem) :-
FlagsContextPieces = InvalidDeclPrefix ++
[lower_case_next_if_not_first, words("Invalid third argument:")],
parse_pragma_foreign_proc_attributes_term(ForeignLanguage, PragmaName,
@@ -2081,81 +2106,83 @@
First, yes(FirstContext), Later, yes(LaterContext),
Treatment, Shared, yes(SharedContext)),
parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm,
- Impl, VarSet, Context, Result)
+ Impl, VarSet, Context, SeqNum, MaybeItem)
;
Specs = [_ | _],
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
).
% This parses a pragma that refers to a predicate or function.
%
:- pred parse_simple_pragma(module_name::in, string::in,
pred(sym_name, int, pragma_type)::(pred(in, in, out) is det),
- list(term)::in, term::in, varset::in, prog_context::in, maybe1(item)::out)
- is det.
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_simple_pragma(ModuleName, PragmaName, MakePragma, PragmaTerms, ErrorTerm,
- VarSet, Context, Result) :-
+ VarSet, Context, SeqNum, MaybeItem) :-
parse_simple_pragma_base(ModuleName, PragmaName, "predicate or function",
- MakePragma, PragmaTerms, ErrorTerm, VarSet, Context, Result).
+ MakePragma, PragmaTerms, ErrorTerm, VarSet, Context, SeqNum,
+ MaybeItem).
% This parses a pragma that refers to type.
%
:- pred parse_simple_type_pragma(module_name::in, string::in,
pred(sym_name, int, pragma_type)::(pred(in, in, out) is det),
- list(term)::in, term::in, varset::in, prog_context::in, maybe1(item)::out)
- is det.
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_simple_type_pragma(ModuleName, PragmaName, MakePragma,
- PragmaTerms, ErrorTerm, VarSet, Context, Result) :-
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
parse_simple_pragma_base(ModuleName, PragmaName, "type", MakePragma,
- PragmaTerms, ErrorTerm, VarSet, Context, Result).
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem).
% This parses a pragma that refers to symbol name / arity.
%
:- pred parse_simple_pragma_base(module_name::in, string::in, string::in,
pred(sym_name, int, pragma_type)::(pred(in, in, out) is det),
- list(term)::in, term::in, varset::in, prog_context::in, maybe1(item)::out)
- is det.
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_simple_pragma_base(ModuleName, PragmaName, NameKind, MakePragma,
- PragmaTerms, ErrorTerm, VarSet, Context, Result) :-
+ PragmaTerms, ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
( PragmaTerms = [PredAndArityTerm] ->
parse_simple_name_and_arity(ModuleName, PragmaName, NameKind,
- PredAndArityTerm, PredAndArityTerm, VarSet, NameArityResult),
+ PredAndArityTerm, PredAndArityTerm, VarSet, MaybeNameAndArity),
(
- NameArityResult = ok2(PredName, Arity),
+ MaybeNameAndArity = ok2(PredName, Arity),
MakePragma(PredName, Arity, Pragma),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
- NameArityResult = error2(Specs),
- Result = error1(Specs)
+ MaybeNameAndArity = error2(Specs),
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma " ++ PragmaName), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- pred parse_pred_name_and_arity(module_name::in, string::in, term::in,
term::in, varset::in, maybe2(sym_name, arity)::out) is det.
parse_pred_name_and_arity(ModuleName, PragmaName, NameAndArityTerm, ErrorTerm,
- VarSet, Result) :-
+ VarSet, MaybeNameAndArity) :-
parse_simple_name_and_arity(ModuleName, PragmaName,
- "predicate or function", NameAndArityTerm, ErrorTerm, VarSet, Result).
+ "predicate or function", NameAndArityTerm, ErrorTerm, VarSet,
+ MaybeNameAndArity).
:- pred parse_simple_name_and_arity(module_name::in, string::in, string::in,
term::in, term::in, varset::in, maybe2(sym_name, arity)::out) is det.
parse_simple_name_and_arity(ModuleName, PragmaName, NameKind,
- NameAndArityTerm, ErrorTerm, VarSet, Result) :-
+ NameAndArityTerm, ErrorTerm, VarSet, MaybeNameAndArity) :-
( parse_name_and_arity(ModuleName, NameAndArityTerm, Name, Arity) ->
- Result = ok2(Name, Arity)
+ MaybeNameAndArity = ok2(Name, Arity)
;
NameAndArityTermStr = describe_error_term(VarSet, NameAndArityTerm),
Pieces = [words("Error: expected"), words(NameKind),
@@ -2164,7 +2191,7 @@
suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error2([Spec])
+ MaybeNameAndArity = error2([Spec])
).
%-----------------------------------------------------------------------------%
@@ -2339,7 +2366,8 @@
check_required_attributes(lang_c, Attrs, _CP, _Term) = ok1(Attrs).
check_required_attributes(lang_csharp, Attrs, _CP, _Term) = ok1(Attrs).
-check_required_attributes(lang_il, Attrs, ContextPieces, Term) = Result :-
+check_required_attributes(lang_il, Attrs, ContextPieces, Term) =
+ MaybeAttributes :-
MaxStackAttrs = list.filter_map(
(func(X) = X is semidet :-
X = max_stack_size(_)),
@@ -2351,10 +2379,10 @@
nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(Term), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeAttributes = error1([Spec])
;
MaxStackAttrs = [_ | _],
- Result = ok1(Attrs)
+ MaybeAttributes = ok1(Attrs)
).
check_required_attributes(lang_java, Attrs, _CP, _Term) = ok1(Attrs).
check_required_attributes(lang_erlang, Attrs, _CP, _Term) = ok1(Attrs).
@@ -2587,43 +2615,43 @@
%
:- pred parse_pragma_foreign_code(module_name::in,
pragma_foreign_proc_attributes::in, term::in, pragma_foreign_code_impl::in,
- varset::in, prog_context::in, maybe1(item)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item)::out) is det.
parse_pragma_foreign_code(ModuleName, Flags, PredAndVarsTerm0,
- PragmaImpl, VarSet0, Context, Result) :-
+ PragmaImpl, VarSet, Context, SeqNum, MaybeItem) :-
ContextPieces = [words("In"), quote(":- pragma c_code"),
words("declaration:")],
parse_pred_or_func_and_args_general(yes(ModuleName), PredAndVarsTerm0,
- PredAndVarsTerm0, VarSet0, ContextPieces, PredAndArgsResult),
- (
- PredAndArgsResult = ok2(PredName, VarList0 - MaybeRetTerm),
+ PredAndVarsTerm0, VarSet, ContextPieces, MaybePredAndArgs),
(
+ MaybePredAndArgs = ok2(PredName, VarList0 - MaybeRetTerm),
% Is this a function or a predicate?
- MaybeRetTerm = yes(FuncResultTerm0)
- ->
+ (
+ MaybeRetTerm = yes(FuncResultTerm0),
PredOrFunc = pf_function,
- list.append(VarList0, [FuncResultTerm0], VarList)
+ VarList = VarList0 ++ [FuncResultTerm0]
;
+ MaybeRetTerm = no,
PredOrFunc = pf_predicate,
VarList = VarList0
),
- parse_pragma_c_code_varlist(VarSet0, VarList, VarsResult),
+ parse_pragma_c_code_varlist(VarSet, VarList, MaybePragmaVars),
(
- VarsResult = ok1(PragmaVars),
- varset.coerce(VarSet0, ProgVarSet),
- varset.coerce(VarSet0, InstVarSet),
+ MaybePragmaVars = ok1(PragmaVars),
+ varset.coerce(VarSet, ProgVarSet),
+ varset.coerce(VarSet, InstVarSet),
Pragma = pragma_foreign_proc(Flags, PredName, PredOrFunc,
PragmaVars, ProgVarSet, InstVarSet, PragmaImpl),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
- VarsResult = error1(Specs),
- Result = error1(Specs)
+ MaybePragmaVars = error1(Specs),
+ MaybeItem = error1(Specs)
)
;
- PredAndArgsResult = error2(Specs),
- Result = error1(Specs)
+ MaybePredAndArgs = error2(Specs),
+ MaybeItem = error1(Specs)
).
% Parse the variable list in the pragma c code declaration.
@@ -2633,7 +2661,7 @@
maybe1(list(pragma_var))::out) is det.
parse_pragma_c_code_varlist(_, [], ok1([])).
-parse_pragma_c_code_varlist(VarSet, [HeadTerm | TailTerm], Result):-
+parse_pragma_c_code_varlist(VarSet, [HeadTerm | TailTerm], MaybePragmaVars):-
(
HeadTerm = term.functor(term.atom("::"), [VarTerm, ModeTerm], _),
VarTerm = term.variable(Var, VarContext)
@@ -2642,22 +2670,23 @@
( convert_mode(allow_constrained_inst_var, ModeTerm, Mode0) ->
constrain_inst_vars_in_mode(Mode0, Mode),
term.coerce_var(Var, ProgVar),
- HeadVar = pragma_var(ProgVar, VarName, Mode,
+ HeadPragmaVar = pragma_var(ProgVar, VarName, Mode,
native_if_possible),
- parse_pragma_c_code_varlist(VarSet, TailTerm, TailResult),
+ parse_pragma_c_code_varlist(VarSet, TailTerm,
+ MaybeTailPragmaVars),
(
- TailResult = ok1(TailVars),
- Result = ok1([HeadVar | TailVars])
+ MaybeTailPragmaVars = ok1(TailPragmaVars),
+ MaybePragmaVars = ok1([HeadPragmaVar | TailPragmaVars])
;
- TailResult = error1(_),
- Result = TailResult
+ MaybeTailPragmaVars = error1(_),
+ MaybePragmaVars = MaybeTailPragmaVars
)
;
Pieces = [words("Error: unknown mode in pragma c_code."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ModeTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybePragmaVars = error1([Spec])
)
;
% If the variable wasn't in the varset it must be an
@@ -2666,22 +2695,22 @@
words("anonymous `_' variable in pragma c_code."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(VarContext, [always(Pieces)])]),
- Result = error1([Spec])
+ MaybePragmaVars = error1([Spec])
)
;
Pieces = [words("Error: arguments are not in the form"),
quote("Var :: mode"), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(HeadTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybePragmaVars = error1([Spec])
).
:- pred parse_tabling_pragma(module_name::in, string::in, eval_method::in,
- list(term)::in, term::in, varset::in, prog_context::in, maybe1(item)::out)
- is det.
+ list(term)::in, term::in, varset::in, prog_context::in, int::in,
+ maybe1(item)::out) is det.
parse_tabling_pragma(ModuleName, PragmaName, TablingType, PragmaTerms,
- ErrorTerm, VarSet, Context, Result) :-
+ ErrorTerm, VarSet, Context, SeqNum, MaybeItem) :-
(
(
PragmaTerms = [PredAndModesTerm0],
@@ -2694,17 +2723,18 @@
ContextPieces = [words("In"), quote(":- pragma " ++ PragmaName),
words("declaration:")],
parse_arity_or_modes(ModuleName, PredAndModesTerm0, ErrorTerm,
- VarSet, ContextPieces, ArityModesResult),
+ VarSet, ContextPieces, MaybeArityOrModes),
(
- ArityModesResult = ok1(arity_or_modes(PredName, Arity,
- MaybePredOrFunc, MaybeModes)),
+ MaybeArityOrModes = ok1(ArityOrModes),
+ ArityOrModes = arity_or_modes(PredName, Arity, MaybePredOrFunc,
+ MaybeModes),
(
MaybeAttrs = no,
Pragma = pragma_tabled(TablingType, PredName, Arity,
MaybePredOrFunc, MaybeModes, no),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context, SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
MaybeAttrs = yes(AttrsListTerm),
UnrecognizedPieces =
@@ -2722,28 +2752,29 @@
Pragma = pragma_tabled(TablingType, PredName,
Arity, MaybePredOrFunc, MaybeModes,
yes(Attributes)),
- ItemPragma = item_pragma_info(user, Pragma, Context),
+ ItemPragma = item_pragma_info(user, Pragma, Context,
+ SeqNum),
Item = item_pragma(ItemPragma),
- Result = ok1(Item)
+ MaybeItem = ok1(Item)
;
MaybeAttributes = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
;
MaybeAttributeList = error1(Specs),
- Result = error1(Specs)
+ MaybeItem = error1(Specs)
)
)
;
- ArityModesResult = error1(Specs),
- Result = error1(Specs)
+ MaybeArityOrModes = error1(Specs),
+ MaybeItem = error1(Specs)
)
;
Pieces = [words("Error: wrong number of arguments in"),
quote(":- pragma " ++ PragmaName), words("declaration."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItem = error1([Spec])
).
:- type single_tabling_attribute
@@ -2973,7 +3004,7 @@
list(format_component)::in, maybe1(arity_or_modes)::out) is det.
parse_arity_or_modes(ModuleName, PredAndModesTerm0, ErrorTerm, VarSet,
- ContextPieces, Result) :-
+ ContextPieces, MaybeArityOrModes) :-
(
% Is this a simple pred/arity pragma.
PredAndModesTerm0 = term.functor(term.atom("/"),
@@ -2988,19 +3019,19 @@
ok2(PredName, [])),
ArityTerm = term.functor(term.integer(Arity), [], _)
->
- Result = ok1(arity_or_modes(PredName, Arity, no, no))
+ MaybeArityOrModes = ok1(arity_or_modes(PredName, Arity, no, no))
;
Pieces = ContextPieces ++ [lower_case_next_if_not_first,
words("Error: expected predname/arity."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeArityOrModes = error1([Spec])
)
;
parse_pred_or_func_and_arg_modes(yes(ModuleName), PredAndModesTerm0,
- PredAndModesTerm0, VarSet, ContextPieces, PredAndModesResult),
+ PredAndModesTerm0, VarSet, ContextPieces, MaybePredAndModes),
(
- PredAndModesResult = ok2(PredName - PredOrFunc, Modes),
+ MaybePredAndModes = ok2(PredName - PredOrFunc, Modes),
list.length(Modes, Arity0),
(
PredOrFunc = pf_function,
@@ -3009,11 +3040,12 @@
PredOrFunc = pf_predicate,
Arity = Arity0
),
- Result = ok1(arity_or_modes(PredName, Arity, yes(PredOrFunc),
- yes(Modes)))
+ ArityOrModes = arity_or_modes(PredName, Arity, yes(PredOrFunc),
+ yes(Modes)),
+ MaybeArityOrModes = ok1(ArityOrModes)
;
- PredAndModesResult = error2(Specs),
- Result = error1(Specs)
+ MaybePredAndModes = error2(Specs),
+ MaybeArityOrModes = error1(Specs)
)
).
@@ -3026,11 +3058,11 @@
maybe_pred_or_func_modes::out) is det.
parse_pred_or_func_and_arg_modes(MaybeModuleName, PredAndModesTerm,
- ErrorTerm, VarSet, ContextPieces, Result) :-
+ ErrorTerm, VarSet, ContextPieces, MaybeNameAndModes) :-
parse_pred_or_func_and_args_general(MaybeModuleName, PredAndModesTerm,
- ErrorTerm, VarSet, ContextPieces, PredAndArgsResult),
+ ErrorTerm, VarSet, ContextPieces, MaybePredAndArgs),
(
- PredAndArgsResult = ok2(PredName, ArgModeTerms - MaybeRetModeTerm),
+ MaybePredAndArgs = ok2(PredName, ArgModeTerms - MaybeRetModeTerm),
(
convert_mode_list(allow_constrained_inst_var, ArgModeTerms,
ArgModes0)
@@ -3043,29 +3075,29 @@
->
ArgModes1 = ArgModes0 ++ [RetMode],
list.map(constrain_inst_vars_in_mode, ArgModes1, ArgModes),
- Result = ok2(PredName - pf_function, ArgModes)
+ MaybeNameAndModes = ok2(PredName - pf_function, ArgModes)
;
Pieces = [words("Error in return mode in")] ++
ContextPieces ++ [suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm),
[always(Pieces)])]),
- Result = error2([Spec])
+ MaybeNameAndModes = error2([Spec])
)
;
MaybeRetModeTerm = no,
- Result = ok2(PredName - pf_predicate, ArgModes0)
+ MaybeNameAndModes = ok2(PredName - pf_predicate, ArgModes0)
)
;
Pieces = [words("Error in arguments modes in")] ++
ContextPieces ++ [suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(ErrorTerm), [always(Pieces)])]),
- Result = error2([Spec])
+ MaybeNameAndModes = error2([Spec])
)
;
- PredAndArgsResult = error2(Specs),
- Result = error2(Specs)
+ MaybePredAndArgs = error2(Specs),
+ MaybeNameAndModes = error2(Specs)
).
:- pred convert_bool(term::in, bool::out) is semidet.
@@ -3272,18 +3304,18 @@
:- pred parse_arg_size_constraints(term::in,
maybe1(maybe(list(arg_size_constr)))::out) is semidet.
-parse_arg_size_constraints(ArgSizeTerm, Result) :-
+parse_arg_size_constraints(ArgSizeTerm, MaybeMaybeArgSizeConstraints) :-
(
ArgSizeTerm = term.functor(term.atom("not_set"), [], _),
- Result = ok1(no)
+ MaybeMaybeArgSizeConstraints = ok1(no)
;
ArgSizeTerm = term.functor(term.atom("constraints"),
[Constraints0], _),
UnrecognizedPieces = [words("Error: expected constraint."), nl],
convert_list("arg size constraints", no, Constraints0,
- parse_arg_size_constraint, UnrecognizedPieces, ConstraintsResult),
- ConstraintsResult = ok1(Constraints),
- Result = ok1(yes(Constraints))
+ parse_arg_size_constraint, UnrecognizedPieces, MaybeConstraints),
+ MaybeConstraints = ok1(Constraints),
+ MaybeMaybeArgSizeConstraints = ok1(yes(Constraints))
).
:- pred parse_arg_size_constraint(term::in, arg_size_constr::out) is semidet.
@@ -3328,10 +3360,10 @@
:- pred parse_required_feature(term::in,
maybe1(required_feature)::out) is semidet.
-parse_required_feature(ReqFeatureTerm, Result) :-
+parse_required_feature(ReqFeatureTerm, MaybeReqFeature) :-
ReqFeatureTerm = term.functor(term.atom(Functor), [], _),
string_to_required_feature(Functor, ReqFeature),
- Result = ok1(ReqFeature).
+ MaybeReqFeature = ok1(ReqFeature).
:- pred string_to_required_feature(string::in, required_feature::out)
is semidet.
Index: compiler/prog_io_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_typeclass.m,v
retrieving revision 1.62
diff -u -b -r1.62 prog_io_typeclass.m
--- compiler/prog_io_typeclass.m 16 Jul 2008 03:30:30 -0000 1.62
+++ compiler/prog_io_typeclass.m 26 Jul 2008 08:20:56 -0000
@@ -31,12 +31,12 @@
% Parse a typeclass declaration.
%
:- pred parse_typeclass(module_name::in, varset::in, list(term)::in,
- prog_context::in, maybe1(item_typeclass_info)::out) is semidet.
+ prog_context::in, int::in, maybe1(item_typeclass_info)::out) is semidet.
% Parse an instance declaration.
%
:- pred parse_instance(module_name::in, varset::in, list(term)::in,
- prog_context::in, maybe1(item_instance_info)::out) is semidet.
+ prog_context::in, int::in, maybe1(item_instance_info)::out) is semidet.
% Parse constraints on a pred or func declaration, or on an existentially
% quantified type definition. Currently all such constraints must be
@@ -78,69 +78,77 @@
%-----------------------------------------------------------------------------%
-parse_typeclass(ModuleName, VarSet, TypeClassTerm, Context, Result) :-
+parse_typeclass(ModuleName, VarSet, TypeClassTerm, Context, SeqNum,
+ MaybeItemTypeClass) :-
% XXX We should return an error if we get more than one arg, instead of
% failing.
TypeClassTerm = [Arg],
( Arg = term.functor(term.atom("where"), [Name, Methods], _) ->
parse_non_empty_class(ModuleName, Name, Methods, VarSet, Context,
- Result)
+ SeqNum, MaybeItemTypeClass)
;
- parse_class_head(ModuleName, Arg, VarSet, Context, Result)
+ parse_class_head(ModuleName, Arg, VarSet, Context, SeqNum,
+ MaybeItemTypeClass)
).
:- pred parse_non_empty_class(module_name::in, term::in, term::in, varset::in,
- prog_context::in, maybe1(item_typeclass_info)::out) is det.
+ prog_context::in, int::in, maybe1(item_typeclass_info)::out) is det.
-parse_non_empty_class(ModuleName, Name, Methods, VarSet, Context, Result) :-
+parse_non_empty_class(ModuleName, Name, Methods, VarSet, Context, SeqNum,
+ MaybeItemTypeClass) :-
varset.coerce(VarSet, TVarSet),
- parse_class_methods(ModuleName, Methods, VarSet, MaybeParsedMethods),
+ parse_class_methods(ModuleName, Methods, VarSet,
+ MaybeParsedMethods),
(
MaybeParsedMethods = ok1(MethodList),
- parse_class_head(ModuleName, Name, VarSet, Context,
+ parse_class_head(ModuleName, Name, VarSet, Context, SeqNum,
MaybeParsedNameAndVars),
(
MaybeParsedNameAndVars = error1(Specs),
- Result = error1(Specs)
+ MaybeItemTypeClass = error1(Specs)
;
MaybeParsedNameAndVars = ok1(ParsedNameAndVars),
- Result = ok1((ParsedNameAndVars
+ MaybeItemTypeClass = ok1((ParsedNameAndVars
^ tc_class_methods := class_interface_concrete(MethodList))
^ tc_varset := TVarSet)
)
;
MaybeParsedMethods = error1(Specs),
- Result = error1(Specs)
+ MaybeItemTypeClass = error1(Specs)
).
:- pred parse_class_head(module_name::in, term::in, varset::in,
- prog_context::in, maybe1(item_typeclass_info)::out) is det.
+ prog_context::in, int::in, maybe1(item_typeclass_info)::out) is det.
-parse_class_head(ModuleName, Arg, VarSet, Context, Result) :-
+parse_class_head(ModuleName, Arg, VarSet, Context, SeqNum,
+ MaybeItemTypeClass) :-
( Arg = term.functor(term.atom("<="), [Name, Constraints], _) ->
parse_constrained_class(ModuleName, Name, Constraints, VarSet, Context,
- Result)
+ SeqNum, MaybeItemTypeClass)
;
varset.coerce(VarSet, TVarSet),
- parse_unconstrained_class(ModuleName, Arg, TVarSet, Context, Result)
+ parse_unconstrained_class(ModuleName, Arg, TVarSet, Context,
+ SeqNum, MaybeItemTypeClass)
).
:- pred parse_constrained_class(module_name::in, term::in, term::in,
- varset::in, prog_context::in, maybe1(item_typeclass_info)::out) is det.
+ varset::in, prog_context::in, int::in, maybe1(item_typeclass_info)::out)
+ is det.
parse_constrained_class(ModuleName, Decl, ConstraintsTerm, VarSet, Context,
- Result) :-
+ SeqNum, MaybeItemTypeClass) :-
varset.coerce(VarSet, TVarSet),
parse_superclass_constraints(ModuleName, VarSet, ConstraintsTerm,
MaybeParsedConstraints),
(
MaybeParsedConstraints = ok2(ConstraintList, FunDeps),
- parse_unconstrained_class(ModuleName, Decl, TVarSet, Context, Result0),
+ parse_unconstrained_class(ModuleName, Decl, TVarSet, Context, SeqNum,
+ MaybeItemTypeClass0),
(
- Result0 = error1(_),
- Result = Result0
+ MaybeItemTypeClass0 = error1(_),
+ MaybeItemTypeClass = MaybeItemTypeClass0
;
- Result0 = ok1(ItemTypeClass0),
+ MaybeItemTypeClass0 = ok1(ItemTypeClass0),
% Check for type variables in the constraints which do not
% occur in the type class parameters.
@@ -186,7 +194,7 @@
ItemTypeClass = ((ItemTypeClass0
^ tc_constraints := ConstraintList)
^ tc_fundeps := FunDeps),
- Result = ok1(ItemTypeClass)
+ MaybeItemTypeClass = ok1(ItemTypeClass)
;
NotInParams = [_ | _],
ClassTVarSet = ItemTypeClass0 ^ tc_varset,
@@ -233,12 +241,12 @@
Pieces = Prefix ++ Middle ++ Suffix ++ [nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(Context, [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeItemTypeClass = error1([Spec])
)
)
;
MaybeParsedConstraints = error2(Specs),
- Result = error1(Specs)
+ MaybeItemTypeClass = error1(Specs)
).
:- func tvars_in_fundeps(list(prog_fundep)) = list(tvar).
@@ -294,9 +302,10 @@
).
:- pred parse_unconstrained_class(module_name::in, term::in, tvarset::in,
- prog_context::in, maybe1(item_typeclass_info)::out) is det.
+ prog_context::in, int::in, maybe1(item_typeclass_info)::out) is det.
-parse_unconstrained_class(ModuleName, NameTerm, TVarSet, Context, Result) :-
+parse_unconstrained_class(ModuleName, NameTerm, TVarSet, Context, SeqNum,
+ MaybeTypeClassInfo) :-
ContextPieces = [words("In typeclass declaration:")],
varset.coerce(TVarSet, VarSet),
parse_implicitly_qualified_term(ModuleName, NameTerm, NameTerm,
@@ -311,19 +320,20 @@
->
% XXX Would this be a better context?
% Context = get_term_context(NameTerm),
- Result = ok1(item_typeclass_info([], [], ClassName, Vars,
- class_interface_abstract, TVarSet, Context))
+ TypeClassInfo = item_typeclass_info([], [], ClassName, Vars,
+ class_interface_abstract, TVarSet, Context, SeqNum),
+ MaybeTypeClassInfo = ok1(TypeClassInfo)
;
Pieces = [words("Error: expected distinct variables"),
words("as class parameters."), nl],
% XXX Would Context be better than get_term_context(NameTerm)?
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(NameTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeTypeClassInfo = error1([Spec])
)
;
MaybeClassName = error2(Specs),
- Result = error1(Specs)
+ MaybeTypeClassInfo = error1(Specs)
).
:- pred parse_class_methods(module_name::in, term::in, varset::in,
@@ -337,7 +347,7 @@
list.map(
(pred(MethodTerm::in, Method::out) is det :-
% Turn the term into an item.
- parse_decl(ModuleName, VarSet, MethodTerm, Item),
+ parse_decl(ModuleName, VarSet, MethodTerm, -1, Item),
% Turn the item into a class_method.
item_to_class_method(Item, MethodTerm, Method)
), MethodList, Interface),
@@ -356,13 +366,15 @@
item_to_class_method(ok1(Item), Term, Result) :-
( Item = item_pred_decl(ItemPredDecl) ->
ItemPredDecl = item_pred_decl_info(_Origin, A, B, C, D, E, F, G, H, I,
- J, K, L, Context),
+ J, K, L, Context, _SeqNum),
ClassMethod = method_pred_or_func(A, B, C, D, E, F, G, H, I,
J, K, L, Context),
Result = ok1(ClassMethod)
; Item = item_mode_decl(ItemModeDecl) ->
- ItemModeDecl = item_mode_decl_info(A, B, C, D, E, F, G, Context),
- ClassMethod = method_pred_or_func_mode(A, B, C, D, E, F, G, Context),
+ ItemModeDecl = item_mode_decl_info(A, B, C, D, E, F, G,
+ Context, _SeqNum),
+ ClassMethod = method_pred_or_func_mode(A, B, C, D, E, F, G,
+ Context),
Result = ok1(ClassMethod)
;
Pieces = [words("Error: only pred, func and mode declarations"),
@@ -616,56 +628,60 @@
%-----------------------------------------------------------------------------%
-parse_instance(ModuleName, VarSet, TypeClassTerm, Context, Result) :-
+parse_instance(ModuleName, VarSet, TypeClassTerm, Context, SeqNum, Result) :-
% XXX We should return an error if we get more than one arg,
% instead of failing.
TypeClassTerm = [Arg],
varset.coerce(VarSet, TVarSet),
( Arg = term.functor(term.atom("where"), [Name, Methods], _) ->
parse_non_empty_instance(ModuleName, Name, Methods, VarSet, TVarSet,
- Context, Result)
+ Context, SeqNum, Result)
;
- parse_instance_name(ModuleName, Arg, TVarSet, Context, Result)
+ parse_instance_name(ModuleName, Arg, TVarSet, Context, SeqNum, Result)
).
:- pred parse_instance_name(module_name::in, term::in, tvarset::in,
- prog_context::in, maybe1(item_instance_info)::out) is det.
+ prog_context::in, int::in, maybe1(item_instance_info)::out) is det.
-parse_instance_name(ModuleName, Arg, TVarSet, Context, Result) :-
+parse_instance_name(ModuleName, Arg, TVarSet, Context, SeqNum,
+ MaybeItemInstance) :-
( Arg = term.functor(term.atom("<="), [Name, Constraints], _) ->
parse_derived_instance(ModuleName, Name, Constraints, TVarSet, Context,
- Result)
+ SeqNum, MaybeItemInstance)
;
- parse_underived_instance(ModuleName, Arg, TVarSet, Context, Result)
+ parse_underived_instance(ModuleName, Arg, TVarSet, Context,
+ SeqNum, MaybeItemInstance)
).
:- pred parse_derived_instance(module_name::in, term::in, term::in,
- tvarset::in, prog_context::in, maybe1(item_instance_info)::out) is det.
+ tvarset::in, prog_context::in, int::in, maybe1(item_instance_info)::out)
+ is det.
parse_derived_instance(ModuleName, Decl, Constraints, TVarSet, Context,
- Result) :-
+ SeqNum, MaybeItemInstance) :-
varset.coerce(TVarSet, VarSet),
parse_instance_constraints(ModuleName, VarSet, Constraints,
MaybeParsedConstraints),
(
MaybeParsedConstraints = ok1(ConstraintList),
- parse_underived_instance(ModuleName, Decl, TVarSet, Context, Result0),
+ parse_underived_instance(ModuleName, Decl, TVarSet, Context, SeqNum,
+ MaybeItemInstance0),
(
- Result0 = error1(_),
- Result = Result0
+ MaybeItemInstance0 = error1(_),
+ MaybeItemInstance = MaybeItemInstance0
;
- Result0 = ok1(ItemInstance0),
+ MaybeItemInstance0 = ok1(ItemInstance0),
ItemInstance0 = item_instance_info(_ConstraintList0, Name, Types,
- Body, InstanceVarSet, ModName, InstanceContext),
+ Body, InstanceVarSet, ModName, InstanceContext, ItemSeqNum),
% XXX Should we keep InstanceContext, or should we replace it
% with Context? Or will they always be the same?
ItemInstance = item_instance_info(ConstraintList, Name, Types,
- Body, InstanceVarSet, ModName, InstanceContext),
- Result = ok1(ItemInstance)
+ Body, InstanceVarSet, ModName, InstanceContext, ItemSeqNum),
+ MaybeItemInstance = ok1(ItemInstance)
)
;
MaybeParsedConstraints = error1(Specs),
- Result = error1(Specs)
+ MaybeItemInstance = error1(Specs)
).
:- pred parse_instance_constraints(module_name::in, varset::in, term::in,
@@ -678,9 +694,10 @@
Result).
:- pred parse_underived_instance(module_name::in, term::in, tvarset::in,
- prog_context::in, maybe1(item_instance_info)::out) is det.
+ prog_context::in, int::in, maybe1(item_instance_info)::out) is det.
-parse_underived_instance(ModuleName, NameTerm, TVarSet, Context, Result) :-
+parse_underived_instance(ModuleName, NameTerm, TVarSet, Context, SeqNum,
+ MaybeItemInstance) :-
% We don't give a default module name here since the instance declaration
% could well be for a typeclass defined in another module.
NameContextPieces = [words("In instance declaration:")],
@@ -691,50 +708,51 @@
MaybeClassName = ok2(ClassName, TermTypes),
% XXX Give better TypesContextPieces.
TypesContextPieces = [],
- parse_types(TermTypes, VarSet, TypesContextPieces, TypesResult),
+ parse_types(TermTypes, VarSet, TypesContextPieces, MaybeTypes),
(
- TypesResult = ok1(Types),
+ MaybeTypes = ok1(Types),
ItemInstance = item_instance_info([], ClassName, Types,
- instance_body_abstract, TVarSet, ModuleName, Context),
- Result = ok1(ItemInstance)
+ instance_body_abstract, TVarSet, ModuleName, Context, SeqNum),
+ MaybeItemInstance = ok1(ItemInstance)
;
- TypesResult = error1(Specs),
- Result = error1(Specs)
+ MaybeTypes = error1(Specs),
+ MaybeItemInstance = error1(Specs)
)
;
MaybeClassName = error2(Specs),
- Result = error1(Specs)
+ MaybeItemInstance = error1(Specs)
).
:- pred parse_non_empty_instance(module_name::in, term::in, term::in,
- varset::in, tvarset::in, prog_context::in,
+ varset::in, tvarset::in, prog_context::in, int::in,
maybe1(item_instance_info)::out) is det.
parse_non_empty_instance(ModuleName, Name, Methods, VarSet, TVarSet, Context,
- Result) :-
+ SeqNum, MaybeItemInstance) :-
parse_instance_methods(ModuleName, Methods, VarSet, MaybeParsedMethods),
(
MaybeParsedMethods = ok1(MethodList),
- parse_instance_name(ModuleName, Name, TVarSet, Context,
- MaybeParsedNameAndTypes),
+ parse_instance_name(ModuleName, Name, TVarSet, Context, SeqNum,
+ MaybeItemInstance0),
(
- MaybeParsedNameAndTypes = error1(Specs),
- Result = error1(Specs)
+ MaybeItemInstance0 = error1(Specs),
+ MaybeItemInstance = error1(Specs)
;
- MaybeParsedNameAndTypes = ok1(ParsedNameAndTypes),
+ MaybeItemInstance0 = ok1(ItemInstance0),
% XXX Should we keep InstanceContext, or should we replace it
% with Context? Or will they always be the same?
- ParsedNameAndTypes = item_instance_info(Constraints, NameString,
- Types, _, _, ModName, InstanceContext),
+ ItemInstance0 = item_instance_info(Constraints, NameString,
+ Types, _, _, ModName, InstanceContext, ItemSeqNum),
ItemInstance = item_instance_info(Constraints, NameString,
Types, instance_body_concrete(MethodList), TVarSet, ModName,
- InstanceContext),
- Result0 = ok1(ItemInstance),
- check_tvars_in_instance_constraint(Result0, Name, Result)
+ InstanceContext, ItemSeqNum),
+ MaybeItemInstance1 = ok1(ItemInstance),
+ check_tvars_in_instance_constraint(MaybeItemInstance1, Name,
+ MaybeItemInstance)
)
;
MaybeParsedMethods = error1(Specs),
- Result = error1(Specs)
+ MaybeItemInstance = error1(Specs)
).
:- pred check_tvars_in_instance_constraint(maybe1(item_instance_info)::in,
@@ -744,7 +762,7 @@
check_tvars_in_instance_constraint(ok1(ItemInstance), InstanceTerm, Result) :-
% XXX
ItemInstance = item_instance_info(Constraints, _Name, Types, _Methods,
- TVarSet, _ModName, _Context),
+ TVarSet, _ModName, _Context, _SeqNum),
% Check that all of the type variables in the constraints on the instance
% declaration also occur in the type class argument types in the instance
% declaration.
@@ -793,23 +811,29 @@
:- pred term_to_instance_method(module_name::in, varset::in, term::in,
maybe1(instance_method)::out) is det.
-term_to_instance_method(_ModuleName, VarSet, MethodTerm, Result) :-
+term_to_instance_method(_ModuleName, VarSet, MethodTerm,
+ MaybeInstanceMethod) :-
(
MethodTerm = term.functor(term.atom("is"),
- [ClassMethodTerm, InstanceMethod], TermContext)
+ [ClassMethodTerm, InstanceMethodTerm], TermContext)
->
+ % Note that the codes for 'pred(...)' and 'func(...)' are very similar.
+ % Unfortunately, factoring out the common code would not really
+ % simplify things.
(
- ClassMethodTerm = term.functor(term.atom("pred"),
- [term.functor(term.atom("/"), [ClassMethod, Arity], _)], _)
+ ClassMethodTerm = term.functor(term.atom("pred"), [SlashTerm], _),
+ SlashTerm = term.functor(term.atom("/"),
+ [PredNameTerm, ArityTerm], _)
->
(
- sym_name_and_args(ClassMethod, ClassMethodName, []),
- Arity = term.functor(term.integer(ArityInt), [], _),
- sym_name_and_args(InstanceMethod, InstanceMethodName, [])
+ sym_name_and_args(PredNameTerm, PredName, []),
+ ArityTerm = term.functor(term.integer(ArityInt), [], _),
+ sym_name_and_args(InstanceMethodTerm, InstanceMethodName, [])
->
- Result = ok1(instance_method(pf_predicate, ClassMethodName,
+ InstanceMethod = instance_method(pf_predicate, PredName,
instance_proc_def_name(InstanceMethodName), ArityInt,
- TermContext))
+ TermContext),
+ MaybeInstanceMethod = ok1(InstanceMethod)
;
MethodTermStr = describe_error_term(VarSet, MethodTerm),
Pieces = [words("Error: expected"),
@@ -819,20 +843,22 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(MethodTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeInstanceMethod = error1([Spec])
)
;
- ClassMethodTerm = term.functor(term.atom("func"),
- [term.functor(term.atom("/"), [ClassMethod, Arity], _)], _)
+ ClassMethodTerm = term.functor(term.atom("func"), [SlashTerm], _),
+ SlashTerm = term.functor(term.atom("/"),
+ [FuncNameTerm, ArityTerm], _)
->
(
- sym_name_and_args(ClassMethod, ClassMethodName, []),
- Arity = term.functor(term.integer(ArityInt), [], _),
- sym_name_and_args(InstanceMethod, InstanceMethodName, [])
+ sym_name_and_args(FuncNameTerm, FuncName, []),
+ ArityTerm = term.functor(term.integer(ArityInt), [], _),
+ sym_name_and_args(InstanceMethodTerm, InstanceMethodName, [])
->
- Result = ok1(instance_method(pf_function, ClassMethodName,
+ InstanceMethod = instance_method(pf_function, FuncName,
instance_proc_def_name(InstanceMethodName), ArityInt,
- TermContext))
+ TermContext),
+ MaybeInstanceMethod = ok1(InstanceMethod)
;
MethodTermStr = describe_error_term(VarSet, MethodTerm),
Pieces = [words("Error: expected"),
@@ -842,7 +868,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(MethodTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeInstanceMethod = error1([Spec])
)
;
MethodTermStr = describe_error_term(VarSet, MethodTerm),
@@ -854,7 +880,7 @@
words("not"), words(MethodTermStr), suffix("."), nl],
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(MethodTerm), [always(Pieces)])]),
- Result = error1([Spec])
+ MaybeInstanceMethod = error1([Spec])
)
;
% For the clauses in an instance declaration, the default module name
@@ -867,20 +893,20 @@
% we will pick that up later, in check_typeclass.m.)
DefaultModuleName = unqualified(""),
- parse_item(DefaultModuleName, VarSet, MethodTerm, Result0),
+ parse_item(DefaultModuleName, VarSet, MethodTerm, -1, MaybeItem0),
(
- Result0 = error1(Specs),
- Result = error1(Specs)
+ MaybeItem0 = error1(Specs),
+ MaybeInstanceMethod = error1(Specs)
;
- Result0 = ok1(Item),
+ MaybeItem0 = ok1(Item),
( Item = item_clause(ItemClause) ->
ItemClause = item_clause_info(_Origin, _VarNames, PredOrFunc,
- ClassMethodName, HeadArgs, _ClauseBody, Context),
+ ClassMethodName, HeadArgs, _ClauseBody, Context, _SeqNum),
adjust_func_arity(PredOrFunc, ArityInt, list.length(HeadArgs)),
InstanceMethod = instance_method(PredOrFunc, ClassMethodName,
instance_proc_def_clauses([ItemClause]), ArityInt,
Context),
- Result = ok1(InstanceMethod)
+ MaybeInstanceMethod = ok1(InstanceMethod)
;
MethodTermStr = describe_error_term(VarSet, MethodTerm),
Pieces = [words("Error: expected clause or"),
@@ -892,7 +918,7 @@
Spec = error_spec(severity_error, phase_term_to_parse_tree,
[simple_msg(get_term_context(MethodTerm),
[always(Pieces)])]),
- Result = error1([Spec])
+ MaybeInstanceMethod = error1([Spec])
)
)
).
Index: compiler/prog_item.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_item.m,v
retrieving revision 1.35
diff -u -b -r1.35 prog_item.m
--- compiler/prog_item.m 21 Jul 2008 03:10:13 -0000 1.35
+++ compiler/prog_item.m 28 Jul 2008 03:49:16 -0000
@@ -39,7 +39,16 @@
%-----------------------------------------------------------------------------%
%
-% This is how programs (and parse errors) are represented
+% This is how programs (and parse errors) are represented.
+%
+% The sequence number fields in the item-kind-specific types are intended to
+% allow the recreation of the original item sequence after we have processed
+% it into more complex data structures. Negative sequence numbers represent
+% items that were not in the original read-in sequence, but which were added
+% by the compiler. It is possible for two items to have the same sequence
+% number if one original item (e.g. one that imports two or more modules)
+% is later split apart (e.g. into several items that each import only one
+% module).
%
:- type compilation_unit
@@ -103,7 +112,8 @@
:- type item_module_defn_info
---> item_module_defn_info(
module_defn_module_defn :: module_defn,
- module_defn_context :: prog_context
+ module_defn_context :: prog_context,
+ module_defn_seq_num :: int
).
:- type item_clause_info
@@ -114,7 +124,8 @@
cl_predname :: sym_name,
cl_head_args :: list(prog_term),
cl_body :: goal,
- cl_context :: prog_context
+ cl_context :: prog_context,
+ cl_seq_num :: int
).
:- type item_type_defn_info
@@ -127,7 +138,8 @@
td_ctor_args :: list(type_param),
td_ctor_defn :: type_defn,
td_cond :: condition,
- td_context :: prog_context
+ td_context :: prog_context,
+ td_seq_num :: int
).
:- type item_inst_defn_info
@@ -139,7 +151,8 @@
id_inst_args :: list(inst_var),
id_inst_defn :: inst_defn,
id_cond :: condition,
- id_context :: prog_context
+ id_context :: prog_context,
+ id_seq_num :: int
).
:- type item_mode_defn_info
@@ -151,7 +164,8 @@
md_mode_args :: list(inst_var),
md_mode_defn :: mode_defn,
md_cond :: condition,
- md_context :: prog_context
+ md_context :: prog_context,
+ md_seq_num :: int
).
:- type item_pred_decl_info
@@ -176,7 +190,8 @@
pf_cond :: condition,
pf_purity :: purity,
pf_class_context :: prog_constraints,
- pf_context :: prog_context
+ pf_context :: prog_context,
+ pf_seq_num :: int
).
:- type item_mode_decl_info
@@ -193,14 +208,16 @@
pfm_maybe_with_inst :: maybe(mer_inst),
pfm_maybe_detism :: maybe(determinism),
pfm_cond :: condition,
- pfm_context :: prog_context
+ pfm_context :: prog_context,
+ pfm_seq_num :: int
).
:- type item_pragma_info
---> item_pragma_info(
pragma_origin :: item_origin,
pragma_type :: pragma_type,
- pragma_context :: prog_context
+ pragma_context :: prog_context,
+ pragma_seq_num :: int
).
:- type item_promise_info
@@ -209,7 +226,8 @@
prom_clause :: goal,
prom_varset :: prog_varset,
prom_univ_quant_vars :: prog_vars,
- prom_context :: prog_context
+ prom_context :: prog_context,
+ prom_seq_num :: int
).
:- type item_typeclass_info
@@ -220,7 +238,8 @@
tc_class_params :: list(tvar),
tc_class_methods :: class_interface,
tc_varset :: tvarset,
- tc_context :: prog_context
+ tc_context :: prog_context,
+ tc_seq_num :: int
).
:- type item_instance_info
@@ -231,7 +250,8 @@
ci_method_instances :: instance_body,
ci_varset :: tvarset,
ci_module_containing_instance :: module_name,
- ci_context :: prog_context
+ ci_context :: prog_context,
+ ci_seq_num :: int
).
:- type item_initialise_info
@@ -240,7 +260,8 @@
init_origin :: item_origin,
init_name :: sym_name,
init_arity :: arity,
- init_context :: prog_context
+ init_context :: prog_context,
+ init_seq_num :: int
).
:- type item_finalise_info
@@ -249,7 +270,8 @@
final_origin :: item_origin,
final_name :: sym_name,
final_arity :: arity,
- final_context :: prog_context
+ final_context :: prog_context,
+ final_seq_num :: int
).
:- type item_mutable_info
@@ -261,7 +283,8 @@
mut_inst :: mer_inst,
mut_attrs :: mutable_var_attributes,
mut_varset :: prog_varset,
- mut_context :: prog_context
+ mut_context :: prog_context,
+ mut_seq_num :: int
).
:- type item_nothing_info
@@ -271,7 +294,8 @@
% XXX Instead of maybe(item_warning), this should be
% maybe(error_spec).
nothing_maybe_warning :: maybe(item_warning),
- nothing_context :: prog_context
+ nothing_context :: prog_context,
+ nothing_seq_num :: int
).
:- func get_item_context(item) = prog_context.
@@ -1025,7 +1049,7 @@
get_item_foreign_code(Globals, Item, !Info) :-
( Item = item_pragma(ItemPragma) ->
- ItemPragma = item_pragma_info(_, Pragma, Context),
+ ItemPragma = item_pragma_info(_, Pragma, Context, _),
do_get_item_foreign_code(Globals, Pragma, Context, !Info)
; Item = item_mutable(_) ->
% Mutables introduce foreign_procs, but mutable declarations
Index: compiler/prog_mutable.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_mutable.m,v
retrieving revision 1.25
diff -u -b -r1.25 prog_mutable.m
--- compiler/prog_mutable.m 21 Jul 2008 03:10:13 -0000 1.25
+++ compiler/prog_mutable.m 26 Jul 2008 03:07:27 -0000
@@ -441,12 +441,14 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
UnsafeGetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet,
ExistQVars, pf_predicate,
mutable_unsafe_get_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, out_mode(Inst))],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_semipure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_semipure, Constraints, Context, -1),
UnsafeGetPredDeclItem = item_pred_decl(UnsafeGetPredDecl).
unsafe_set_pred_decl(ModuleName, Name, Type, Inst, Context)
@@ -456,12 +458,14 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
UnsafeSetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet,
ExistQVars, pf_predicate,
mutable_unsafe_set_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, in_mode(Inst))],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_impure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_impure, Constraints, Context, -1),
UnsafeSetPredDeclItem = item_pred_decl(UnsafeSetPredDecl).
lock_pred_decl(ModuleName, Name, Context) = LockPredDeclItem :-
@@ -470,11 +474,12 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
LockPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
- pf_predicate, mutable_lock_pred_sym_name(ModuleName, Name),
- [],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_impure, Constraints, Context),
+ pf_predicate, mutable_lock_pred_sym_name(ModuleName, Name), [],
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_impure, Constraints, Context, -1),
LockPredDeclItem = item_pred_decl(LockPredDecl).
unlock_pred_decl(ModuleName, Name, Context) = UnlockPredDeclItem :-
@@ -483,11 +488,12 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
UnlockPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
- pf_predicate, mutable_unlock_pred_sym_name(ModuleName, Name),
- [],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_impure, Constraints, Context),
+ pf_predicate, mutable_unlock_pred_sym_name(ModuleName, Name), [],
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_impure, Constraints, Context, -1),
UnlockPredDeclItem = item_pred_decl(UnlockPredDecl).
%-----------------------------------------------------------------------------%
@@ -498,11 +504,13 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
GetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_get_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, out_mode(Inst))],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_semipure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_semipure, Constraints, Context, -1),
GetPredDeclItem = item_pred_decl(GetPredDecl).
std_set_pred_decl(ModuleName, Name, Type, Inst, Context) = SetPredDeclItem :-
@@ -511,11 +519,13 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
SetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_set_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, in_mode(Inst))],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_impure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_impure, Constraints, Context, -1),
SetPredDeclItem = item_pred_decl(SetPredDecl).
constant_get_pred_decl(ModuleName, Name, Type, Inst, Context)
@@ -525,11 +535,13 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
GetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_get_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, out_mode(Inst))],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_pure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_pure, Constraints, Context, -1),
GetPredDeclItem = item_pred_decl(GetPredDecl).
constant_set_pred_decl(ModuleName, Name, Type, Inst, Context)
@@ -539,11 +551,13 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
SetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_secret_set_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, in_mode(Inst))],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_impure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_impure, Constraints, Context, -1),
SetPredDeclItem = item_pred_decl(SetPredDecl).
io_get_pred_decl(ModuleName, Name, Type, Inst, Context) = GetPredDeclItem :-
@@ -552,13 +566,15 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
GetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_get_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, out_mode(Inst)),
type_and_mode(io_state_type, di_mode),
type_and_mode(io_state_type, uo_mode)],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_pure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_pure, Constraints, Context, -1),
GetPredDeclItem = item_pred_decl(GetPredDecl).
io_set_pred_decl(ModuleName, Name, Type, Inst, Context) = SetPredDeclItem :-
@@ -567,13 +583,15 @@
ExistQVars = [],
Constraints = constraints([], []),
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
SetPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_set_pred_sym_name(ModuleName, Name),
[type_and_mode(Type, in_mode(Inst)),
type_and_mode(io_state_type, di_mode),
type_and_mode(io_state_type, uo_mode)],
- no /* with_type */, no /* with_inst */, yes(detism_det),
- cond_true /* condition */, purity_pure, Constraints, Context),
+ WithType, WithInst, yes(detism_det),
+ cond_true, purity_pure, Constraints, Context, -1),
SetPredDeclItem = item_pred_decl(SetPredDecl).
mutable_init_pred_decl(ModuleName, Name, Context) = InitPredDeclItem :-
@@ -582,14 +600,14 @@
ExistQVars = [],
Constraints = constraints([], []),
ArgDecls = [],
+ Condition = cond_true,
WithType = no,
WithInst = no,
- Condition = cond_true,
Origin = compiler(mutable_decl),
InitPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet, ExistQVars,
pf_predicate, mutable_init_pred_sym_name(ModuleName, Name), ArgDecls,
WithType, WithInst, yes(detism_det), Condition,
- purity_impure, Constraints, Context),
+ purity_impure, Constraints, Context, -1),
InitPredDeclItem = item_pred_decl(InitPredDecl).
mutable_pre_init_pred_decl(ModuleName, Name, Context) = PreInitPredDeclItem :-
@@ -598,15 +616,15 @@
ExistQVars = [],
Constraints = constraints([], []),
ArgDecls = [],
- WithType = no,
- WithInst = no,
Condition = cond_true,
Origin = compiler(mutable_decl),
+ WithType = no,
+ WithInst = no,
PreInitPredDecl = item_pred_decl_info(Origin, VarSet, InstVarSet,
ExistQVars, pf_predicate,
mutable_pre_init_pred_sym_name(ModuleName, Name),
ArgDecls, WithType, WithInst, yes(detism_det), Condition,
- purity_impure, Constraints, Context),
+ purity_impure, Constraints, Context, -1),
PreInitPredDeclItem = item_pred_decl(PreInitPredDecl).
%-----------------------------------------------------------------------------%
Index: compiler/recompilation.check.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.check.m,v
retrieving revision 1.44
diff -u -b -r1.44 recompilation.check.m
--- compiler/recompilation.check.m 21 Jul 2008 03:10:13 -0000 1.44
+++ compiler/recompilation.check.m 26 Jul 2008 03:13:06 -0000
@@ -699,10 +699,12 @@
MaybeUsedItemsTerm = yes(UsedItemsTerm),
Items = [InterfaceItem, VersionNumberItem | OtherItems],
InterfaceItem = item_module_defn(InterfaceItemModuleDefn),
- InterfaceItemModuleDefn = item_module_defn_info(md_interface, _),
+ InterfaceItemModuleDefn =
+ item_module_defn_info(md_interface, _, _),
VersionNumberItem = item_module_defn(VersionNumberItemModuleDefn),
VersionNumberItemModuleDefn =
- item_module_defn_info(md_version_numbers(_, VersionNumbers), _)
+ item_module_defn_info(md_version_numbers(_, VersionNumbers),
+ _, _)
->
check_module_used_items(ImportedModuleName, NeedQualifier,
RecordedTimestamp, UsedItemsTerm, VersionNumbers,
@@ -866,7 +868,7 @@
unexpected(this_file, "check_for_ambiguities: clause")
;
Item = item_type_defn(ItemTypeDefn),
- ItemTypeDefn = item_type_defn_info(_, Name, Params, Body, _, _),
+ ItemTypeDefn = item_type_defn_info(_, Name, Params, Body, _, _, _),
Arity = list.length(Params),
check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp,
VersionNumbers, type_abstract_item, Name, Arity, NeedsCheck,
@@ -880,18 +882,18 @@
)
;
Item = item_inst_defn(ItemInstDefn),
- ItemInstDefn = item_inst_defn_info(_, Name, Params, _, _, _),
+ ItemInstDefn = item_inst_defn_info(_, Name, Params, _, _, _, _),
check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp,
VersionNumbers, inst_item, Name, list.length(Params), _, !Info)
;
Item = item_mode_defn(ItemModeDefn),
- ItemModeDefn = item_mode_defn_info(_, Name, Params, _, _, _),
+ ItemModeDefn = item_mode_defn_info(_, Name, Params, _, _, _, _),
check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp,
VersionNumbers, mode_item, Name, list.length(Params), _, !Info)
;
Item = item_typeclass(ItemTypeClass),
ItemTypeClass = item_typeclass_info(_, _, Name, Params, Interface,
- _, _),
+ _, _, _),
check_for_simple_item_ambiguity(NeedQualifier, OldTimestamp,
VersionNumbers, typeclass_item, Name, list.length(Params),
NeedsCheck, !Info),
@@ -907,7 +909,7 @@
;
Item = item_pred_decl(ItemPredDecl),
ItemPredDecl = item_pred_decl_info(_, _, _, _, PredOrFunc, Name, Args,
- WithType, _, _, _, _, _, _),
+ WithType, _, _, _, _, _, _, _),
check_for_pred_or_func_item_ambiguity(no, NeedQualifier, OldTimestamp,
VersionNumbers, PredOrFunc, Name, Args, WithType, !Info)
;
@@ -1140,24 +1142,26 @@
type_ctor::in, type_defn::in,
recompilation_check_info::in, recompilation_check_info::out) is det.
-check_type_defn_ambiguity_with_functor(_, _, parse_tree_abstract_type(_),
- !Info).
-check_type_defn_ambiguity_with_functor(_, _, parse_tree_eqv_type(_), !Info).
-check_type_defn_ambiguity_with_functor(NeedQualifier, TypeCtor,
- parse_tree_du_type(Ctors, _), !Info) :-
+check_type_defn_ambiguity_with_functor(NeedQualifier, TypeCtor, TypeDefn,
+ !Info) :-
+ (
+ ( TypeDefn = parse_tree_abstract_type(_)
+ ; TypeDefn = parse_tree_eqv_type(_)
+ ; TypeDefn = parse_tree_foreign_type(_, _, _)
+ ; TypeDefn = parse_tree_solver_type(_, _)
+ )
+ ;
+ TypeDefn = parse_tree_du_type(Ctors, _),
list.foldl(check_functor_ambiguities(NeedQualifier, TypeCtor), Ctors,
- !Info).
-check_type_defn_ambiguity_with_functor(_, _, parse_tree_foreign_type(_, _, _),
- !Info).
-check_type_defn_ambiguity_with_functor(_, _, parse_tree_solver_type(_, _),
- !Info).
+ !Info)
+ ).
:- pred check_functor_ambiguities(need_qualifier::in, type_ctor::in,
constructor::in,
recompilation_check_info::in, recompilation_check_info::out) is det.
-check_functor_ambiguities(NeedQualifier, TypeCtor, ctor(_, _, Name, Args, _),
- !Info) :-
+check_functor_ambiguities(NeedQualifier, TypeCtor, Ctor, !Info) :-
+ Ctor = ctor(_, _, Name, Args, _),
TypeCtorItem = type_ctor_to_item_name(TypeCtor),
ResolvedCtor = resolved_functor_constructor(TypeCtorItem),
Arity = list.length(Args),
Index: compiler/recompilation.version.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/recompilation.version.m,v
retrieving revision 1.64
diff -u -b -r1.64 recompilation.version.m
--- compiler/recompilation.version.m 16 Jul 2008 03:30:31 -0000 1.64
+++ compiler/recompilation.version.m 26 Jul 2008 03:29:59 -0000
@@ -71,10 +71,10 @@
MaybeOldItems = yes(OldItems0),
OldItems0 = [FirstItem, VersionNumberItem | OldItems],
FirstItem = item_module_defn(FirstItemModuleDefn),
- FirstItemModuleDefn = item_module_defn_info(md_interface, _),
+ FirstItemModuleDefn = item_module_defn_info(md_interface, _, _),
VersionNumberItem = item_module_defn(VersionNumberItemModuleDefn),
VersionNumberItemModuleDefn = item_module_defn_info(
- md_version_numbers(_, OldVersionNumbers), _)
+ md_version_numbers(_, OldVersionNumbers), _, _)
->
OldVersionNumbers = version_numbers(OldItemVersionNumbers,
OldInstanceVersionNumbers),
@@ -271,19 +271,19 @@
gather_items_2(Item, !Section, !Info) :-
(
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(md_interface, _)
+ ItemModuleDefn = item_module_defn_info(md_interface, _, _)
->
!:Section = section_interface
;
Item = item_module_defn(ItemModuleDefn),
- ItemModuleDefn = item_module_defn_info(md_implementation, _)
+ ItemModuleDefn = item_module_defn_info(md_implementation, _, _)
->
!:Section = section_implementation
;
Item = item_type_defn(ItemTypeDefn)
->
ItemTypeDefn = item_type_defn_info(VarSet, Name, Args, Body, Cond,
- Context),
+ Context, SeqNum),
(
Body = parse_tree_abstract_type(_),
NameItem = Item,
@@ -294,7 +294,8 @@
;
Body = parse_tree_du_type(_, _),
NameItemTypeDefn = item_type_defn_info(VarSet, Name, Args,
- parse_tree_abstract_type(non_solver_type), Cond, Context),
+ parse_tree_abstract_type(non_solver_type), Cond, Context,
+ SeqNum),
NameItem = item_type_defn(NameItemTypeDefn),
BodyItem = Item
;
@@ -321,7 +322,8 @@
;
Item = item_instance(ItemInstance)
->
- ItemInstance = item_instance_info(_, ClassName, ClassArgs, _, _, _, _),
+ ItemInstance =
+ item_instance_info(_, ClassName, ClassArgs, _, _, _, _, _),
Instances0 = !.Info ^ instances,
ClassArity = list.length(ClassArgs),
ClassItemName = item_name(ClassName, ClassArity),
@@ -342,7 +344,7 @@
% pred_or_func and arity, so this will work.
Item = item_mode_decl(ItemModeDecl),
ItemModeDecl = item_mode_decl_info(_, MaybePredOrFunc, SymName, Modes,
- WithInst, _, _, _),
+ WithInst, _, _, _, _),
MaybePredOrFunc = no,
WithInst = yes(_)
->
@@ -362,7 +364,7 @@
!:Info = !.Info ^ gathered_items := GatheredItems
;
Item = item_pragma(ItemPragma),
- ItemPragma = item_pragma_info(_, PragmaType, _),
+ ItemPragma = item_pragma_info(_, PragmaType, _, _),
is_pred_pragma(PragmaType, yes(PredOrFuncId))
->
PragmaItems = !.Info ^ pragma_items,
@@ -410,7 +412,8 @@
Item = item_pred_decl(ItemPredDecl),
ItemPredDecl = item_pred_decl_info(Origin, TVarSet, InstVarSet,
ExistQVars, PredOrFunc, PredName, TypesAndModes,
- WithType, WithInst, Det, Cond, Purity, ClassContext, Context),
+ WithType, WithInst, Det, Cond, Purity, ClassContext,
+ Context, SeqNum),
split_types_and_modes(TypesAndModes, Types, MaybeModes),
MaybeModes = yes(Modes),
( Modes = [_ | _]
@@ -422,7 +425,7 @@
PredItemPredDecl = item_pred_decl_info(Origin, TVarSet,
EmptyInstVarSet, ExistQVars, PredOrFunc, PredName,
TypesWithoutModes, WithType, no, no, Cond, Purity, ClassContext,
- Context),
+ Context, SeqNum),
PredItem = item_pred_decl(PredItemPredDecl),
(
WithInst = yes(_),
@@ -434,8 +437,8 @@
WithInst = no,
MaybePredOrFunc = yes(PredOrFunc)
),
- ModeItemModeDecl = item_mode_decl_info(InstVarSet,
- MaybePredOrFunc, PredName, Modes, WithInst, Det, Cond, Context),
+ ModeItemModeDecl = item_mode_decl_info(InstVarSet, MaybePredOrFunc,
+ PredName, Modes, WithInst, Det, Cond, Context, SeqNum),
ModeItem = item_mode_decl(ModeItemModeDecl),
MatchingItems = [Section - PredItem, Section - ModeItem
| MatchingItems0]
@@ -522,26 +525,26 @@
MaybeItemId = no
;
Item = item_type_defn(ItemTypeDefn),
- ItemTypeDefn = item_type_defn_info(_, Name, Params, _, _, _),
+ ItemTypeDefn = item_type_defn_info(_, Name, Params, _, _, _, _),
list.length(Params, Arity),
ItemId = item_id(type_abstract_item, item_name(Name, Arity)),
MaybeItemId = yes(ItemId)
;
Item = item_inst_defn(ItemInstDefn),
- ItemInstDefn = item_inst_defn_info(_, Name, Params, _, _, _),
+ ItemInstDefn = item_inst_defn_info(_, Name, Params, _, _, _, _),
list.length(Params, Arity),
ItemId = item_id(inst_item, item_name(Name, Arity)),
MaybeItemId = yes(ItemId)
;
Item = item_mode_defn(ItemModeDefn),
- ItemModeDefn = item_mode_defn_info(_, Name, Params, _, _, _),
+ ItemModeDefn = item_mode_defn_info(_, Name, Params, _, _, _, _),
list.length(Params, Arity),
ItemId = item_id(mode_item, item_name(Name, Arity)),
MaybeItemId = yes(ItemId)
;
Item = item_pred_decl(ItemPredDecl),
ItemPredDecl = item_pred_decl_info(_, _, _, _, PredOrFunc, SymName,
- TypesAndModes, WithType, _, _, _, _, _, _),
+ TypesAndModes, WithType, _, _, _, _, _, _, _),
% For predicates or functions defined using `with_type` annotations
% the arity here won't be correct, but equiv_type.m will record
% the dependency on the version number with the `incorrect' arity,
@@ -559,7 +562,7 @@
;
Item = item_mode_decl(ItemModeDecl),
ItemModeDecl = item_mode_decl_info(_, MaybePredOrFunc, SymName, Modes,
- _, _, _, _),
+ _, _, _, _, _),
(
MaybePredOrFunc = yes(PredOrFunc),
adjust_func_arity(PredOrFunc, Arity, list.length(Modes)),
@@ -581,7 +584,7 @@
;
Item = item_typeclass(ItemTypeClass),
ItemTypeClass = item_typeclass_info(_, _, ClassName, ClassVars,
- _, _, _),
+ _, _, _, _),
list.length(ClassVars, ClassArity),
ItemId = item_id(typeclass_item, item_name(ClassName, ClassArity)),
MaybeItemId = yes(ItemId)
@@ -697,10 +700,10 @@
item_is_unchanged(Item1, Item2) = Unchanged :-
(
Item1 = item_module_defn(ItemModuleDefn1),
- ItemModuleDefn1 = item_module_defn_info(ModuleDefn, _),
+ ItemModuleDefn1 = item_module_defn_info(ModuleDefn, _, _),
(
Item2 = item_module_defn(ItemModuleDefn2),
- ItemModuleDefn2 = item_module_defn_info(ModuleDefn, _)
+ ItemModuleDefn2 = item_module_defn_info(ModuleDefn, _, _)
->
Unchanged = yes
;
@@ -708,13 +711,14 @@
)
;
Item1 = item_clause(ItemClause1),
- ItemClause1 = item_clause_info(_, _, PorF, SymName, Args, Goal, _),
+ ItemClause1 = item_clause_info(_, _, PorF, SymName, Args, Goal, _, _),
% XXX Need to compare the goals properly in clauses and assertions.
% That's not necessary at the moment because smart recompilation
% doesn't work with inter-module optimization yet.
(
Item2 = item_clause(ItemClause2),
- ItemClause2 = item_clause_info(_, _, PorF, SymName, Args, Goal, _)
+ ItemClause2 =
+ item_clause_info(_, _, PorF, SymName, Args, Goal, _, _)
->
Unchanged = yes
;
@@ -722,10 +726,11 @@
)
;
Item1 = item_type_defn(ItemTypeDefn1),
- ItemTypeDefn1 = item_type_defn_info(_, Name, Args, Defn, Cond, _),
+ ItemTypeDefn1 = item_type_defn_info(_, Name, Args, Defn, Cond, _, _),
(
Item2 = item_type_defn(ItemTypeDefn2),
- ItemTypeDefn2 = item_type_defn_info(_, Name, Args, Defn, Cond, _)
+ ItemTypeDefn2 =
+ item_type_defn_info(_, Name, Args, Defn, Cond, _, _)
->
Unchanged = yes
;
@@ -733,10 +738,11 @@
)
;
Item1 = item_inst_defn(ItemInstDefn1),
- ItemInstDefn1 = item_inst_defn_info(_, Name, Args, Defn, Cond, _),
+ ItemInstDefn1 = item_inst_defn_info(_, Name, Args, Defn, Cond, _, _),
(
Item2 = item_inst_defn(ItemInstDefn2),
- ItemInstDefn2 = item_inst_defn_info(_, Name, Args, Defn, Cond, _)
+ ItemInstDefn2 =
+ item_inst_defn_info(_, Name, Args, Defn, Cond, _, _)
->
Unchanged = yes
;
@@ -744,10 +750,11 @@
)
;
Item1 = item_mode_defn(ItemModeDefn1),
- ItemModeDefn1 = item_mode_defn_info(_, Name, Args, Defn, Cond, _),
+ ItemModeDefn1 = item_mode_defn_info(_, Name, Args, Defn, Cond, _, _),
(
Item2 = item_mode_defn(ItemModeDefn2),
- ItemModeDefn2 = item_mode_defn_info(_, Name, Args, Defn, Cond, _)
+ ItemModeDefn2 =
+ item_mode_defn_info(_, Name, Args, Defn, Cond, _, _)
->
Unchanged = yes
;
@@ -757,12 +764,12 @@
Item1 = item_pred_decl(ItemPredDecl1),
ItemPredDecl1 = item_pred_decl_info(_, TVarSet1, _, ExistQVars1,
PredOrFunc, Name, TypesAndModes1, WithType1, _,
- Det1, Cond, Purity, Constraints1, _),
+ Det1, Cond, Purity, Constraints1, _, _),
(
Item2 = item_pred_decl(ItemPredDecl2),
ItemPredDecl2 = item_pred_decl_info(_, TVarSet2, _, ExistQVars2,
PredOrFunc, Name, TypesAndModes2, WithType2,
- _, Det2, Cond, Purity, Constraints2, _),
+ _, Det2, Cond, Purity, Constraints2, _, _),
% For predicates, ignore the determinism -- the modes and
% determinism should have been split into a separate
@@ -791,11 +798,11 @@
;
Item1 = item_mode_decl(ItemModeDecl1),
ItemModeDecl1 = item_mode_decl_info(InstVarSet1, PredOrFunc, Name,
- Modes1, WithInst1, Det, Cond, _),
+ Modes1, WithInst1, Det, Cond, _, _),
(
Item2 = item_mode_decl(ItemModeDecl2),
ItemModeDecl2 = item_mode_decl_info(InstVarSet2, PredOrFunc,
- Name, Modes2, WithInst2, Det, Cond, _),
+ Name, Modes2, WithInst2, Det, Cond, _, _),
pred_or_func_mode_is_unchanged(InstVarSet1, Modes1, WithInst1,
InstVarSet2, Modes2, WithInst2)
->
@@ -805,14 +812,14 @@
)
;
Item1 = item_pragma(ItemPragma1),
- ItemPragma1 = item_pragma_info(_, PragmaType1, _),
+ ItemPragma1 = item_pragma_info(_, PragmaType1, _, _),
% We do need to compare the variable names in `:- pragma type_spec'
% declarations because the names of the variables are used
% to find the corresponding variables in the predicate or
% function type declaration.
(
Item2 = item_pragma(ItemPragma2),
- ItemPragma2 = item_pragma_info(_, PragmaType2, _)
+ ItemPragma2 = item_pragma_info(_, PragmaType2, _, _)
->
(
PragmaType1 = pragma_type_spec(Name, SpecName, Arity,
@@ -846,11 +853,11 @@
;
Item1 = item_promise(ItemPromiseInfo1),
ItemPromiseInfo1 = item_promise_info(PromiseType, Goal, _,
- UnivVars, _),
+ UnivVars, _, _),
(
Item2 = item_promise(ItemPromiseInfo2),
ItemPromiseInfo2 = item_promise_info(PromiseType, Goal, _,
- UnivVars, _)
+ UnivVars, _, _)
->
Unchanged = yes
;
@@ -858,10 +865,10 @@
)
;
Item1 = item_initialise(ItemInitialise1),
- ItemInitialise1 = item_initialise_info(A, B, C, _),
+ ItemInitialise1 = item_initialise_info(A, B, C, _, _),
(
Item2 = item_initialise(ItemInitialise2),
- ItemInitialise2 = item_initialise_info(A, B, C, _)
+ ItemInitialise2 = item_initialise_info(A, B, C, _, _)
->
Unchanged = yes
;
@@ -869,10 +876,10 @@
)
;
Item1 = item_finalise(ItemFinalise1),
- ItemFinalise1 = item_finalise_info(A, B, C, _),
+ ItemFinalise1 = item_finalise_info(A, B, C, _, _),
(
Item2 = item_finalise(ItemFinalise2),
- ItemFinalise2 = item_finalise_info(A, B, C, _)
+ ItemFinalise2 = item_finalise_info(A, B, C, _, _)
->
Unchanged = yes
;
@@ -880,10 +887,10 @@
)
;
Item1 = item_mutable(ItemMutable1),
- ItemMutable1 = item_mutable_info(A, B, C, D, E, F, _),
+ ItemMutable1 = item_mutable_info(A, B, C, D, E, F, _, _),
(
Item2 = item_mutable(ItemMutable2),
- ItemMutable2 = item_mutable_info(A, B, C, D, E, F, _)
+ ItemMutable2 = item_mutable_info(A, B, C, D, E, F, _, _)
->
Unchanged = yes
;
@@ -892,11 +899,11 @@
;
Item1 = item_typeclass(ItemTypeClass1),
ItemTypeClass1 = item_typeclass_info(Constraints, FunDeps, Name,
- Vars, Interface1, _, _),
+ Vars, Interface1, _, _, _),
(
Item2 = item_typeclass(ItemTypeClass2),
ItemTypeClass2 = item_typeclass_info(Constraints, FunDeps, Name,
- Vars, Interface2, _, _),
+ Vars, Interface2, _, _, _),
class_interface_is_unchanged(Interface1, Interface2)
->
Unchanged = yes
@@ -906,11 +913,11 @@
;
Item1 = item_instance(ItemInstance1),
ItemInstance1 = item_instance_info(Constraints, Name, Types, Body,
- _, Module, _),
+ _, Module, _, _),
(
Item2 = item_instance(ItemInstance2),
ItemInstance2 = item_instance_info(Constraints, Name, Types, Body,
- _, Module, _)
+ _, Module, _, _)
->
Unchanged = yes
;
@@ -918,10 +925,10 @@
)
;
Item1 = item_nothing(ItemNothing1),
- ItemNothing1 = item_nothing_info(A, _),
+ ItemNothing1 = item_nothing_info(A, _, _),
(
Item2 = item_nothing(ItemNothing2),
- ItemNothing2 = item_nothing_info(A, _)
+ ItemNothing2 = item_nothing_info(A, _, _)
->
Unchanged = yes
;
@@ -954,8 +961,8 @@
(
TypeAndMode0 = type_only(Type)
;
- % This should have been split out into a
- % separate mode declaration by gather_items.
+ % This should have been split out into a separate
+ % mode declaration by gather_items.
TypeAndMode0 = type_and_mode(_, _),
unexpected(this_file,
"pred_or_func_type_matches: type_and_mode")
Index: compiler/state_var.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/state_var.m,v
retrieving revision 1.26
diff -u -b -r1.26 state_var.m
--- compiler/state_var.m 27 Feb 2008 07:23:15 -0000 1.26
+++ compiler/state_var.m 15 Jul 2008 14:24:29 -0000
@@ -1188,10 +1188,10 @@
expand_item_bsvs(ItemClause0) = ItemClause :-
ItemClause0 = item_clause_info(Origin, VarSet, PredOrFunc, SymName,
- Args0, Body, Context),
+ Args0, Body, Context, SeqNum),
Args = expand_bang_state_var_args(Args0),
ItemClause = item_clause_info(Origin, VarSet, PredOrFunc, SymName,
- Args, Body, Context).
+ Args, Body, Context, SeqNum).
%-----------------------------------------------------------------------------%
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/base64
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/fixed
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_allegro
cvs diff: Diffing extras/graphics/mercury_allegro/examples
cvs diff: Diffing extras/graphics/mercury_allegro/samples
cvs diff: Diffing extras/graphics/mercury_allegro/samples/demo
cvs diff: Diffing extras/graphics/mercury_allegro/samples/mandel
cvs diff: Diffing extras/graphics/mercury_allegro/samples/pendulum2
cvs diff: Diffing extras/graphics/mercury_allegro/samples/speed
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/log4m
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/mopenssl
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/net
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/posix/samples
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/standalone_c
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/solver_types
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
cvs diff: Diffing ssdb
cvs diff: Diffing tests
cvs diff: Diffing tests/analysis
cvs diff: Diffing tests/analysis/ctgc
cvs diff: Diffing tests/analysis/excp
cvs diff: Diffing tests/analysis/ext
cvs diff: Diffing tests/analysis/sharing
cvs diff: Diffing tests/analysis/table
cvs diff: Diffing tests/analysis/trail
cvs diff: Diffing tests/analysis/unused_args
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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