modus
Menu
On this page

The module agenda

A module of commands that imports the module calendar.

Each export calls days_in_month of calendar through an import slot: one indirect call. The loader puts calendar in the same process, or the module that a replacement gives in its place: the file of this module does not change, so its hash does not change. The module also runs as a process that waits: two processes that import calendar at two places share one copy of its code.

What it is for. It is the importer of the test of the replacement of an import. The process imports loads it with calendar, then with calendar_fixed in place of calendar, and compares: year_days(2000) is 365 with the fault and 366 with the correction, from the same file of agenda.

Example, in the console:

load("agenda")
year_days(2000)                         365: calendar forgets the rule of the 400 years
replace("calendar", "calendar_fixed")
unload("agenda")
load("agenda")
year_days(2000)                         366

The design:.

See: Module contract: Replacement of an import

agenda module with an entry

Hash
a73c004b419cdaa68616f12e53fe70d4f5a222e728dcefa4a83a02e7f94a08c6
Size
16384 bytes
Exports
3
Imports
1
Imported by
0
License
MIT

A module of commands that imports the module calendar

FactValue
KindModules with no entry
Sourcesrc/modules/demonstrations/agenda
Boot imageyes: in the boot image, 16384 bytes in this build
Build settingsnone: the defaults of the source
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

agenda calendar

Exports

ExportWhat it does
year_days(year: Integer) -> Integergives the count of days of a year: the sum of the days of its months, from the module calendar
month_days(month: Integer, year: Integer) -> Integergives the count of days of one month of a year, from the module calendar
calls(count: Integer) -> Integercalls days_in_month a count of times and gives the sum of the results: a measure of a call through an import slot
entry()runs agenda as a process: it waits with no end

year_days

year_days(year: ) -> 

year_days gives the count of days of a year: the sum of the days of its months, from the module calendar.

It makes 12 calls through the import slot, one for each month, so its answer is the answer of the module that the loader put in that import slot: 365 for the year 2000 with calendar, 366 with calendar_fixed. It never fails.

Parameters
  • year:
Result
Source
src/modules/demonstrations/agenda/agenda.odin:31

month_days

month_days(month: , year: ) -> 

month_days gives the count of days of one month of a year, from the module calendar.

  • month: 1 to 12. Another month makes calendar stop the process on a bounds check: after load that process is the caller itself.
  • year: any year.
Parameters
  • month:
  • year:
Result
Source
src/modules/demonstrations/agenda/agenda.odin:44

calls

calls(count: ) -> 

calls calls days_in_month a count of times and gives the sum of the results: a measure of a call through an import slot.

The months and the years change with each call (the years 2000 to 2006), so the compiler cannot keep one answer. The process imports times it to compare an import slot that holds calendar with an import slot that holds its replacement. A count of 0 or less gives 0.

Parameters
  • count:
Result
Source
src/modules/demonstrations/agenda/agenda.odin:52

entry

entry()

entry runs agenda as a process: it waits with no end. A process that runs agenda maps the code of calendar that another process of the same starter maps.

The process imports starts two such processes from the boot image and reads their page tables: the code pages of calendar are one copy in the two. The process does nothing else and never stops by itself.

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/demonstrations/agenda/agenda.odin:64

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.