mirror of
https://github.com/ganelson/inform.git
synced 2024-07-01 06:24:58 +03:00
75 lines
3.1 KiB
OpenEdge ABL
75 lines
3.1 KiB
OpenEdge ABL
[InterVersion::] The Inter Version.
|
|
|
|
The semantic version number for the current definition of Inter bytecode.
|
|
|
|
@ We can expect the details of the Inter language to change. Such changes
|
|
could easily render text or binary files of Inter code useless; so we will
|
|
want to use semantic versioning to compare the language as we understand it
|
|
(the "current version") with the language as it was understood by whoever
|
|
wrote the Inter file we are loading (the "file version").
|
|
|
|
If we consider the version as having the traditional form |major.minor.patch|,
|
|
the |major| version should change on any of the following:
|
|
|
|
(a) Removal of an Inter construct, or any renumbering of |*_IST| constants.
|
|
(b) Change of bytecode representation of an instruction.
|
|
(c) Change of the binary file format in //Inter in Binary Files//. Note that
|
|
changing some of the defined constants in this module could have the same effect,
|
|
since these constants are used as distinguishing values in binary Inter files.
|
|
(d) Change of the textual file format in //Inter in Text Files// and elsewhere
|
|
in the |CONSTRUCT_READ_MTID| methods for the constructs.
|
|
(e) Removal of one of the standard annotations, or any renumbering of existing
|
|
ones. See //Annotations//.
|
|
(f) Removal of one of the standard primitives, or any renumbering of existing
|
|
ones. See //building: Inter Primitives//.
|
|
|
|
This may result in ungainly, high |major| version numbers: so be it. However,
|
|
the following need only mean a bump of the |minor| version --
|
|
|
|
(a) Addition of a new Inter construct, provided the existing ones are not
|
|
renumbered.
|
|
(b) Addition of a new Inter annotation, provided the existing ones are not
|
|
renumbered.
|
|
(c) Addition of a new Inter primitive, provided the existing ones are not
|
|
renumbered.
|
|
|
|
The |patch| version number should always remain 0 -- this is not a version for
|
|
the implementation of anything, just for the specification itself, so in some
|
|
sense it cannot be bug-fixed, only changed.
|
|
|
|
Modifiers of the |+| and |-| sort are also best avoided here, so we will deal only
|
|
with SVNs in the traditional |x.y.z| format.
|
|
|
|
=
|
|
semantic_version_number InterVersion::current(void) {
|
|
semantic_version_number V = VersionNumbers::from_text(I"1.0.0");
|
|
if (VersionNumbers::is_null(V)) internal_error("malformed version number");
|
|
return V;
|
|
}
|
|
|
|
int InterVersion::check_readable(semantic_version_number file_version) {
|
|
return VersionNumberRanges::in_range(
|
|
InterVersion::current(),
|
|
VersionNumberRanges::compatibility_range(file_version));
|
|
}
|
|
|
|
@ When Inter is stored in binary format, the version number is stored in three
|
|
consecutive unsigned integers in the file header: see //Inter in Binary Files//.
|
|
|
|
=
|
|
void InterVersion::to_three_words(unsigned int *w1, unsigned int *w2, unsigned int *w3) {
|
|
semantic_version_number V = InterVersion::current();
|
|
*w1 = (unsigned int) V.version_numbers[0];
|
|
*w2 = (unsigned int) V.version_numbers[1];
|
|
*w3 = (unsigned int) V.version_numbers[2];
|
|
}
|
|
|
|
semantic_version_number InterVersion::from_three_words(unsigned int w1, unsigned int w2,
|
|
unsigned int w3) {
|
|
TEMPORARY_TEXT(textual)
|
|
WRITE_TO(textual, "%d.%d.%d", w1, w2, w3);
|
|
semantic_version_number V = VersionNumbers::from_text(textual);
|
|
DISCARD_TEXT(textual)
|
|
return V;
|
|
}
|