mirror of
https://github.com/ganelson/inform.git
synced 2024-06-30 22:14:58 +03:00
Clarification of pointer-value kinds support code
This commit is contained in:
parent
19ab732223
commit
832678bff7
|
@ -134,8 +134,7 @@ regular users: it would be quite slow to read in.
|
|||
<span class="plain-syntax"> </span><span class="identifier-syntax">inter_architecture</span><span class="plain-syntax"> *</span><span class="identifier-syntax">A</span><span class="plain-syntax"> = </span><a href="1-pm.html#SP4" class="function-link"><span class="function-syntax">PipelineModule::get_architecture</span></a><span class="plain-syntax">();</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">A</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">Errors::fatal</span><span class="plain-syntax">(</span><span class="string-syntax">"no -architecture given"</span><span class="plain-syntax">);</span>
|
||||
<span class="plain-syntax"> </span><span class="identifier-syntax">filename</span><span class="plain-syntax"> *</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Architectures::canonical_binary</span><span class="plain-syntax">(</span><span class="identifier-syntax">req</span><span class="plain-syntax">-></span><span class="element-syntax">location</span><span class="plain-syntax">, </span><span class="identifier-syntax">A</span><span class="plain-syntax">);</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TextFiles::exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
|
||||
<span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"no arch file for requirement"</span><span class="plain-syntax">);</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">TextFiles::exists</span><span class="plain-syntax">(</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">BinaryInter::test_file</span><span class="plain-syntax">(</span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">)) </span><span class="identifier-syntax">BinaryInter::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">);</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">TextualInter::read</span><span class="plain-syntax">(</span><span class="identifier-syntax">sidecar</span><span class="plain-syntax">, </span><span class="identifier-syntax">arch_file</span><span class="plain-syntax">);</span>
|
||||
</pre>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
100.0% in inform7 run
|
||||
67.3% in compilation to Inter
|
||||
45.7% in //Sequence::undertake_queued_tasks//
|
||||
46.1% in //Sequence::undertake_queued_tasks//
|
||||
4.2% in //MajorNodes::pre_pass//
|
||||
3.4% in //MajorNodes::pass_1//
|
||||
1.9% in //ImperativeDefinitions::assess_all//
|
||||
|
@ -13,17 +13,17 @@
|
|||
0.3% in //Sequence::undertake_queued_tasks//
|
||||
0.3% in //Sequence::undertake_queued_tasks//
|
||||
0.3% in //World::stage_V//
|
||||
5.4% not specifically accounted for
|
||||
5.0% not specifically accounted for
|
||||
28.0% in running Inter pipeline
|
||||
9.2% in step 14/15: generate inform6 -> auto.inf
|
||||
6.9% in step 5/15: load-binary-kits
|
||||
5.7% in step 6/15: make-synoptic-module
|
||||
6.1% in step 6/15: make-synoptic-module
|
||||
1.9% in step 9/15: make-identifiers-unique
|
||||
0.3% in step 11/15: eliminate-redundant-labels
|
||||
0.3% in step 12/15: eliminate-redundant-operations
|
||||
0.3% in step 4/15: compile-splats
|
||||
0.3% in step 7/15: shorten-wiring
|
||||
0.3% in step 8/15: detect-indirect-calls
|
||||
2.3% not specifically accounted for
|
||||
1.9% not specifically accounted for
|
||||
3.8% in supervisor
|
||||
0.8% not specifically accounted for
|
||||
|
|
|
@ -814,8 +814,11 @@ Section 1 - Enumerations
|
|||
To decide which number is number of (S - description of values)
|
||||
(documented at ph_numberof):
|
||||
(- {-primitive-definition:number-of} -).
|
||||
To decide what number is the numerical value of (X - enumerated value): (- {X} -).
|
||||
To decide what number is the sequence number of (X - enumerated value of kind K):
|
||||
To decide what number is the numerical value of (X - enumerated value)
|
||||
(documented at ph_numericalvalue):
|
||||
(- {X} -).
|
||||
To decide what number is the sequence number of (X - enumerated value of kind K)
|
||||
(documented at ph_sequencenumber):
|
||||
(- {-indexing-routine:K}({X}) -).
|
||||
To decide which K is (name of kind of enumerated value K) after (X - K)
|
||||
(documented at ph_enumafter):
|
||||
|
|
|
@ -387,18 +387,18 @@ InternalFileReadChar(F, N) reads the data at position N in file F.
|
|||
[ InternalFileIO_Line txt file_id file_id pos tsize c;
|
||||
TEXT_TY_Transmute(txt);
|
||||
TEXT_TY_Empty(txt);
|
||||
tsize = BlkValueLBCapacity(txt);
|
||||
tsize = PVFieldCapacity(txt);
|
||||
while (true) {
|
||||
c = InternalFileReadChar(file_id, -1);
|
||||
if (c == 10) { BlkValueWrite(txt, pos, 0); rtrue; }
|
||||
if (c == 10) { WritePVField(txt, pos, 0); rtrue; }
|
||||
if (c == -1) break;
|
||||
if (pos+1 >= tsize) {
|
||||
if (BlkValueSetLBCapacity(txt, 2*pos) == false) rfalse;
|
||||
tsize = BlkValueLBCapacity(txt);
|
||||
if (SetPVFieldCapacity(txt, 2*pos) == false) rfalse;
|
||||
tsize = PVFieldCapacity(txt);
|
||||
}
|
||||
BlkValueWrite(txt, pos++, c);
|
||||
WritePVField(txt, pos++, c);
|
||||
}
|
||||
BlkValueWrite(txt, pos, 0);
|
||||
WritePVField(txt, pos, 0);
|
||||
if (pos > 0) rtrue;
|
||||
rfalse;
|
||||
];
|
||||
|
|
|
@ -316,6 +316,36 @@ read it from the given long block directly. |BlkValueWrite| is similar.
|
|||
print_ret "*** BlkValueWrite: writing to index out of range: ", pos, " in ", to, " ***";
|
||||
];
|
||||
|
||||
[ BlkValueWriteLB long_block pos val
|
||||
chunk_size_in_bytes header_size_in_bytes flags entry_size_in_bytes seek_byte_position;
|
||||
if (long_block == 0) rfalse;
|
||||
flags = long_block->BLK_HEADER_FLAGS;
|
||||
entry_size_in_bytes = 1;
|
||||
if (flags & BLK_FLAG_16_BIT) entry_size_in_bytes = 2;
|
||||
else if (flags & BLK_FLAG_WORD) entry_size_in_bytes = WORDSIZE;
|
||||
|
||||
if (flags & BLK_FLAG_MULTIPLE) header_size_in_bytes = BLK_DATA_MULTI_OFFSET;
|
||||
else header_size_in_bytes = BLK_DATA_OFFSET;
|
||||
|
||||
seek_byte_position = pos*entry_size_in_bytes;
|
||||
for (:long_block~=NULL:long_block=long_block-->BLK_NEXT) {
|
||||
chunk_size_in_bytes = FlexSize(long_block) - header_size_in_bytes;
|
||||
if ((seek_byte_position >= 0) && (seek_byte_position<chunk_size_in_bytes)) {
|
||||
long_block = long_block + header_size_in_bytes + seek_byte_position;
|
||||
switch(entry_size_in_bytes) {
|
||||
1: long_block->0 = val;
|
||||
2: #Iftrue WORDSIZE == 2; long_block-->0 = val;
|
||||
#ifnot; long_block->0 = (val/256)%256; long_block->1 = val%256;
|
||||
#endif;
|
||||
4: long_block-->0 = val;
|
||||
}
|
||||
return;
|
||||
}
|
||||
seek_byte_position = seek_byte_position - chunk_size_in_bytes;
|
||||
}
|
||||
print_ret "*** BlkValueWriteLB: writing to index out of range: ", pos, " in ", long_block, " ***";
|
||||
];
|
||||
|
||||
@h First Zero Entry.
|
||||
This returns the entry index of the first zero entry in the long block's array,
|
||||
or -1 if it has no zeros.
|
||||
|
@ -581,6 +611,17 @@ we get its address from by adding the data offset to the block address.
|
|||
return short_block;
|
||||
];
|
||||
|
||||
@h Long Block Allocation.
|
||||
|
||||
=
|
||||
[ BlkValueCreateLB extent weak_id;
|
||||
return FlexAllocate(extent*WORDSIZE, weak_id, BLK_FLAG_WORD);
|
||||
];
|
||||
|
||||
[ BlkValueCreateMultipleLB extent weak_id;
|
||||
return FlexAllocate(extent*WORDSIZE, weak_id, BLK_FLAG_MULTIPLE + BLK_FLAG_WORD);
|
||||
];
|
||||
|
||||
@h Block Values On Stack.
|
||||
As noted above, it's wasteful to keep allocating short blocks using Flex.
|
||||
For the short blocks of block values in local variables, we store them on
|
||||
|
@ -922,7 +963,7 @@ produce the same hash value.
|
|||
|
||||
=
|
||||
[ GetHashValue kind value;
|
||||
if (KOVIsBlockValue(kind)) return BlkValueHash(value);
|
||||
if (ConformsTo_POINTER_VALUE_TY(kind)) return BlkValueHash(value);
|
||||
return value;
|
||||
];
|
||||
|
||||
|
@ -1044,3 +1085,42 @@ in memory between builds invalidating this required output.
|
|||
v = v & $F;
|
||||
if (v < 10) print v; else print (char) 'A' + v - 10;
|
||||
];
|
||||
|
||||
@h The Pointer Value API.
|
||||
This sits on top of the BlkValue API, but whereas the latter can be used for
|
||||
many potential purposes, the PV functions are strictly for dealing with
|
||||
values of kinds conforming to POINTER_VALUE_TY.
|
||||
|
||||
=
|
||||
Constant ConformsTo_POINTER_VALUE_TY = KOVIsBlockValue;
|
||||
|
||||
Constant DestroyPV = BlkValueFree;
|
||||
Constant CreatePV = BlkValueCreate;
|
||||
Constant CopyPV = BlkValueCopy;
|
||||
Constant CastPV = BlkValueCast;
|
||||
Constant ComparePV = BlkValueCompare;
|
||||
Constant WeakKindOfPV = BlkValueWeakKind;
|
||||
Constant WritePVToFile = BlkValueWriteToFile;
|
||||
Constant PVFromFile = BlkValueReadFromFile;
|
||||
|
||||
Constant PVField = BlkValueRead;
|
||||
Constant WritePVField = BlkValueWrite;
|
||||
Constant CreatePVLongBlock = BlkValueCreateLB;
|
||||
Constant CreatePVLongBlockMultiple = BlkValueCreateMultipleLB;
|
||||
Constant InitialisePVLongBlockField = BlkValueWriteLB;
|
||||
|
||||
Constant CreatePVShortBlockOfSize1 = BlkValueCreateSB1;
|
||||
Constant CreatePVShortBlockOfSize2 = BlkValueCreateSB2;
|
||||
Constant CopyPVShortBlockOfSize1 = BlkValueCopySB1;
|
||||
Constant CopyPVShortBlockOfSize2 = BlkValueCopySB2;
|
||||
|
||||
Constant PVFieldCapacity = BlkValueLBCapacity;
|
||||
Constant SetPVFieldCapacity = BlkValueSetLBCapacity;
|
||||
|
||||
[ WritePVFieldsFromByteArray to_bv from_array no_entries_to_copy;
|
||||
BlkValueMassCopyFromArray(to_bv, from_array, 1, no_entries_to_copy);
|
||||
];
|
||||
|
||||
[ WritePVFieldsFromWordArray to_bv from_array no_entries_to_copy;
|
||||
BlkValueMassCopyFromArray(to_bv, from_array, 4, no_entries_to_copy);
|
||||
];
|
||||
|
|
|
@ -27,7 +27,7 @@ routines.
|
|||
MAKEMUTABLE_KOVS: return 1;
|
||||
COPYKIND_KOVS: return COMBINATION_TY_CopyKind(arg1, arg2);
|
||||
COPYQUICK_KOVS: rtrue;
|
||||
COPYSB_KOVS: BlkValueCopySB1(arg1, arg2);
|
||||
COPYSB_KOVS: CopyPVShortBlockOfSize1(arg1, arg2);
|
||||
KINDDATA_KOVS: return COMBINATION_TY_KindData(arg1);
|
||||
EXTENT_KOVS: return -1;
|
||||
COPY_KOVS: COMBINATION_TY_Copy(arg1, arg2, arg3);
|
||||
|
@ -52,16 +52,15 @@ Thus, a triple $(x, y, z)$ uses 4 words.
|
|||
=
|
||||
[ COMBINATION_TY_Create kind sb long_block N i bk v;
|
||||
N = KindBaseArity(kind);
|
||||
long_block = FlexAllocate(
|
||||
(COMBINATION_ITEM_BASE+N)*WORDSIZE, COMBINATION_TY, BLK_FLAG_WORD);
|
||||
BlkValueWrite(long_block, COMBINATION_KIND_F, kind, true);
|
||||
long_block = CreatePVLongBlock(COMBINATION_ITEM_BASE+N, COMBINATION_TY);
|
||||
InitialisePVLongBlockField(long_block, COMBINATION_KIND_F, kind);
|
||||
for (i=0: i<N: i++) {
|
||||
bk = KindBaseTerm(kind, i);
|
||||
if (KOVIsBlockValue(bk)) v = BlkValueCreate(bk);
|
||||
if (ConformsTo_POINTER_VALUE_TY(bk)) v = CreatePV(bk);
|
||||
else v = DefaultValueOfKOV(bk);
|
||||
BlkValueWrite(long_block, COMBINATION_ITEM_BASE+i, v, true);
|
||||
InitialisePVLongBlockField(long_block, COMBINATION_ITEM_BASE+i, v);
|
||||
}
|
||||
return BlkValueCreateSB1(sb, long_block);
|
||||
return CreatePVShortBlockOfSize1(sb, long_block);
|
||||
];
|
||||
|
||||
@h Destruction.
|
||||
|
@ -70,12 +69,12 @@ the comb itself can be freed.
|
|||
|
||||
=
|
||||
[ COMBINATION_TY_Destroy comb kind no_items i bk;
|
||||
kind = BlkValueRead(comb, COMBINATION_KIND_F);
|
||||
kind = PVField(comb, COMBINATION_KIND_F);
|
||||
no_items = KindBaseArity(kind);
|
||||
for (i=0: i<no_items: i++) {
|
||||
bk = KindBaseTerm(kind, i);
|
||||
if (KOVIsBlockValue(bk))
|
||||
BlkValueFree(BlkValueRead(comb, i+COMBINATION_ITEM_BASE));
|
||||
if (ConformsTo_POINTER_VALUE_TY(bk))
|
||||
DestroyPV(PVField(comb, i+COMBINATION_ITEM_BASE));
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -85,27 +84,27 @@ than bitwise copied as pointers.
|
|||
|
||||
=
|
||||
[ COMBINATION_TY_CopyKind to from;
|
||||
BlkValueWrite(to, COMBINATION_KIND_F, BlkValueRead(from, COMBINATION_KIND_F));
|
||||
WritePVField(to, COMBINATION_KIND_F, PVField(from, COMBINATION_KIND_F));
|
||||
];
|
||||
|
||||
[ COMBINATION_TY_CopySB to from;
|
||||
BlkValueCopySB1(to, from);
|
||||
CopyPVShortBlockOfSize1(to, from);
|
||||
];
|
||||
|
||||
[ COMBINATION_TY_KindData comb;
|
||||
return BlkValueRead(comb, COMBINATION_KIND_F);
|
||||
return PVField(comb, COMBINATION_KIND_F);
|
||||
];
|
||||
|
||||
[ COMBINATION_TY_Copy to_comb from_comb precopied_comb_kov no_items i nv kind bk;
|
||||
! kind = BlkValueRead(to_comb, COMBINATION_KIND_F);
|
||||
! kind = PVField(to_comb, COMBINATION_KIND_F);
|
||||
no_items = KindBaseArity(precopied_comb_kov);
|
||||
BlkValueWrite(to_comb, COMBINATION_KIND_F, precopied_comb_kov);
|
||||
WritePVField(to_comb, COMBINATION_KIND_F, precopied_comb_kov);
|
||||
for (i=0: i<no_items: i++) {
|
||||
bk = KindBaseTerm(kind, i);
|
||||
if (KOVIsBlockValue(bk)) {
|
||||
nv = BlkValueCreate(bk);
|
||||
BlkValueCopy(nv, BlkValueRead(from_comb, i+COMBINATION_ITEM_BASE));
|
||||
BlkValueWrite(to_comb, i+COMBINATION_ITEM_BASE, nv);
|
||||
if (ConformsTo_POINTER_VALUE_TY(bk)) {
|
||||
nv = CreatePV(bk);
|
||||
CopyPV(nv, PVField(from_comb, i+COMBINATION_ITEM_BASE));
|
||||
WritePVField(to_comb, i+COMBINATION_ITEM_BASE, nv);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -116,18 +115,18 @@ same kind.
|
|||
|
||||
=
|
||||
[ COMBINATION_TY_Compare left_comb right_comb delta no_items i cf kind bk;
|
||||
kind = BlkValueRead(left_comb, COMBINATION_KIND_F);
|
||||
kind = PVField(left_comb, COMBINATION_KIND_F);
|
||||
no_items = KindBaseArity(kind);
|
||||
for (i=0: i<no_items: i++) {
|
||||
bk = KindBaseTerm(kind, i);
|
||||
cf = KOVComparisonFunction(bk);
|
||||
if (cf == 0 or UnsignedCompare) {
|
||||
delta = BlkValueRead(left_comb, i+COMBINATION_ITEM_BASE) -
|
||||
BlkValueRead(right_comb, i+COMBINATION_ITEM_BASE);
|
||||
delta = PVField(left_comb, i+COMBINATION_ITEM_BASE) -
|
||||
PVField(right_comb, i+COMBINATION_ITEM_BASE);
|
||||
if (delta) return delta;
|
||||
} else {
|
||||
delta = cf(BlkValueRead(left_comb, i+COMBINATION_ITEM_BASE),
|
||||
BlkValueRead(right_comb, i+COMBINATION_ITEM_BASE));
|
||||
delta = cf(PVField(left_comb, i+COMBINATION_ITEM_BASE),
|
||||
PVField(right_comb, i+COMBINATION_ITEM_BASE));
|
||||
if (delta) return delta;
|
||||
}
|
||||
}
|
||||
|
@ -144,11 +143,11 @@ same kind.
|
|||
=
|
||||
[ COMBINATION_TY_Hash comb kind rv no_items i bk;
|
||||
rv = 0;
|
||||
kind = BlkValueRead(comb, COMBINATION_KIND_F);
|
||||
kind = PVField(comb, COMBINATION_KIND_F);
|
||||
no_items = KindBaseArity(kind);
|
||||
for (i=0: i<no_items: i++) {
|
||||
bk = KindBaseTerm(kind, i);
|
||||
rv = rv * 33 + GetHashValue(bk, BlkValueRead(comb, i+COMBINATION_ITEM_BASE));
|
||||
rv = rv * 33 + GetHashValue(bk, PVField(comb, i+COMBINATION_ITEM_BASE));
|
||||
}
|
||||
return rv;
|
||||
];
|
||||
|
@ -157,14 +156,14 @@ same kind.
|
|||
|
||||
=
|
||||
[ COMBINATION_TY_Say comb format no_items v i kind bk;
|
||||
if ((comb==0) || (BlkValueWeakKind(comb) ~= COMBINATION_TY)) return;
|
||||
kind = BlkValueRead(comb, COMBINATION_KIND_F);
|
||||
if (WeakKindOfPV(comb) ~= COMBINATION_TY) return;
|
||||
kind = PVField(comb, COMBINATION_KIND_F);
|
||||
no_items = KindBaseArity(kind);
|
||||
print "(";
|
||||
for (i=0: i<no_items: i++) {
|
||||
if (i>0) print ", ";
|
||||
bk = KindBaseTerm(kind, i);
|
||||
v = BlkValueRead(comb, i+COMBINATION_ITEM_BASE);
|
||||
v = PVField(comb, i+COMBINATION_ITEM_BASE);
|
||||
if (bk == LIST_OF_TY) LIST_OF_TY_Say(v, 1);
|
||||
else PrintKindValuePair(bk, v);
|
||||
}
|
||||
|
|
|
@ -27,14 +27,14 @@ routines.
|
|||
MAKEMUTABLE_KOVS: return 1;
|
||||
COPYKIND_KOVS: return LIST_OF_TY_CopyKind(arg1, arg2);
|
||||
COPYQUICK_KOVS: return LIST_OF_TY_QuickCopy(arg1, arg2);
|
||||
COPYSB_KOVS: BlkValueCopySB1(arg1, arg2);
|
||||
COPYSB_KOVS: CopyPVShortBlockOfSize1(arg1, arg2);
|
||||
KINDDATA_KOVS: return LIST_OF_TY_KindData(arg1, arg2);
|
||||
EXTENT_KOVS: return BlkValueRead(arg1, LIST_LENGTH_F) + LIST_ITEM_BASE;
|
||||
EXTENT_KOVS: return PVField(arg1, LIST_LENGTH_F) + LIST_ITEM_BASE;
|
||||
COPY_KOVS: LIST_OF_TY_Copy(arg1, arg2, arg3);
|
||||
COMPARE_KOVS: return LIST_OF_TY_Compare(arg1, arg2);
|
||||
HASH_KOVS: return LIST_OF_TY_Hash(arg1);
|
||||
DEBUG_KOVS: print " = {", (LIST_OF_TY_Say) arg1, "} of kind ",
|
||||
BlkValueRead(arg1, LIST_ITEM_KOV_F);
|
||||
PVField(arg1, LIST_ITEM_KOV_F);
|
||||
}
|
||||
! We choose not to respond to: CAST_KOVS, READ_FILE_KOVS, WRITE_FILE_KOVS
|
||||
rfalse;
|
||||
|
@ -47,13 +47,12 @@ are taken care of: 4 words are consumed by the header, then 2 more by the
|
|||
list metadata entries below.
|
||||
|
||||
=
|
||||
[ LIST_OF_TY_Create skov sb list;
|
||||
[ LIST_OF_TY_Create skov short_block long_block;
|
||||
skov = KindBaseTerm(skov, 0);
|
||||
list = FlexAllocate(27*WORDSIZE, LIST_OF_TY, BLK_FLAG_MULTIPLE + BLK_FLAG_WORD);
|
||||
BlkValueWrite(list, LIST_ITEM_KOV_F, skov, true);
|
||||
BlkValueWrite(list, LIST_LENGTH_F, 0, true);
|
||||
sb = BlkValueCreateSB1(sb, list);
|
||||
return sb;
|
||||
long_block = CreatePVLongBlockMultiple(27, LIST_OF_TY);
|
||||
InitialisePVLongBlockField(long_block, LIST_ITEM_KOV_F, skov);
|
||||
InitialisePVLongBlockField(long_block, LIST_LENGTH_F, 0);
|
||||
return CreatePVShortBlockOfSize1(short_block, long_block);
|
||||
];
|
||||
|
||||
@h Destruction.
|
||||
|
@ -62,10 +61,11 @@ the list itself can be freed.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Destroy list no_items i k;
|
||||
k = BlkValueRead(list, LIST_ITEM_KOV_F);
|
||||
if (KOVIsBlockValue(k)) {
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
for (i=0: i<no_items: i++) BlkValueFree(BlkValueRead(list, i+LIST_ITEM_BASE));
|
||||
k = PVField(list, LIST_ITEM_KOV_F);
|
||||
if (ConformsTo_POINTER_VALUE_TY(k)) {
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
for (i=0: i<no_items: i++)
|
||||
DestroyPV(PVField(list, i+LIST_ITEM_BASE));
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -82,34 +82,34 @@ things.)
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_CopyKind to from;
|
||||
BlkValueWrite(to, LIST_ITEM_KOV_F, BlkValueRead(from, LIST_ITEM_KOV_F));
|
||||
WritePVField(to, LIST_ITEM_KOV_F, PVField(from, LIST_ITEM_KOV_F));
|
||||
];
|
||||
|
||||
[ LIST_OF_TY_QuickCopy to from;
|
||||
if (BlkValueRead(to, LIST_ITEM_KOV_F) ~= BlkValueRead(from, LIST_ITEM_KOV_F))
|
||||
if (PVField(to, LIST_ITEM_KOV_F) ~= PVField(from, LIST_ITEM_KOV_F))
|
||||
rfalse;
|
||||
rtrue;
|
||||
];
|
||||
|
||||
[ LIST_OF_TY_KindData list dummy;
|
||||
return BlkValueRead(list, LIST_ITEM_KOV_F);
|
||||
return PVField(list, LIST_ITEM_KOV_F);
|
||||
];
|
||||
|
||||
[ LIST_OF_TY_Copy lto lfrom precopied_list_kov no_items i nv bk val splk;
|
||||
no_items = BlkValueRead(lfrom, LIST_LENGTH_F);
|
||||
bk = BlkValueRead(lfrom, LIST_ITEM_KOV_F);
|
||||
no_items = PVField(lfrom, LIST_LENGTH_F);
|
||||
bk = PVField(lfrom, LIST_ITEM_KOV_F);
|
||||
if (precopied_list_kov ~= 0 or UNKNOWN_TY)
|
||||
BlkValueWrite(lto, LIST_ITEM_KOV_F, precopied_list_kov);
|
||||
else BlkValueWrite(lto, LIST_ITEM_KOV_F, bk);
|
||||
if (KOVIsBlockValue(bk)) {
|
||||
WritePVField(lto, LIST_ITEM_KOV_F, precopied_list_kov);
|
||||
else WritePVField(lto, LIST_ITEM_KOV_F, bk);
|
||||
if (ConformsTo_POINTER_VALUE_TY(bk)) {
|
||||
for (i=0: i<no_items: i++) {
|
||||
val = BlkValueRead(lfrom, i+LIST_ITEM_BASE);
|
||||
val = PVField(lfrom, i+LIST_ITEM_BASE);
|
||||
if (precopied_list_kov ~= 0 or UNKNOWN_TY)
|
||||
nv = BlkValueCreate(precopied_list_kov);
|
||||
nv = CreatePV(precopied_list_kov);
|
||||
else
|
||||
nv = BlkValueCreate(bk);
|
||||
BlkValueCopy(nv, val);
|
||||
BlkValueWrite(lto, i+LIST_ITEM_BASE, nv);
|
||||
nv = CreatePV(bk);
|
||||
CopyPV(nv, val);
|
||||
WritePVField(lto, i+LIST_ITEM_BASE, nv);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -125,23 +125,23 @@ lists of equal size in lexicographic order.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Compare listleft listright delta no_items i cf;
|
||||
delta = BlkValueRead(listleft, LIST_LENGTH_F) - BlkValueRead(listright, LIST_LENGTH_F);
|
||||
delta = PVField(listleft, LIST_LENGTH_F) - PVField(listright, LIST_LENGTH_F);
|
||||
if (delta) return delta;
|
||||
no_items = BlkValueRead(listleft, LIST_LENGTH_F);
|
||||
no_items = PVField(listleft, LIST_LENGTH_F);
|
||||
if (no_items == 0) return 0;
|
||||
delta = BlkValueRead(listleft, LIST_ITEM_KOV_F) - BlkValueRead(listright, LIST_ITEM_KOV_F);
|
||||
delta = PVField(listleft, LIST_ITEM_KOV_F) - PVField(listright, LIST_ITEM_KOV_F);
|
||||
if (delta) return delta;
|
||||
cf = LIST_OF_TY_ComparisonFn(listleft);
|
||||
if (cf == 0 or UnsignedCompare) {
|
||||
for (i=0: i<no_items: i++) {
|
||||
delta = BlkValueRead(listleft, i+LIST_ITEM_BASE) -
|
||||
BlkValueRead(listright, i+LIST_ITEM_BASE);
|
||||
delta = PVField(listleft, i+LIST_ITEM_BASE) -
|
||||
PVField(listright, i+LIST_ITEM_BASE);
|
||||
if (delta) return delta;
|
||||
}
|
||||
} else {
|
||||
for (i=0: i<no_items: i++) {
|
||||
delta = cf(BlkValueRead(listleft, i+LIST_ITEM_BASE),
|
||||
BlkValueRead(listright, i+LIST_ITEM_BASE));
|
||||
delta = cf(PVField(listleft, i+LIST_ITEM_BASE),
|
||||
PVField(listright, i+LIST_ITEM_BASE));
|
||||
if (delta) return delta;
|
||||
}
|
||||
}
|
||||
|
@ -149,8 +149,8 @@ lists of equal size in lexicographic order.
|
|||
];
|
||||
|
||||
[ LIST_OF_TY_ComparisonFn list;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
return KOVComparisonFunction(BlkValueRead(list, LIST_ITEM_KOV_F));
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
return KOVComparisonFunction(PVField(list, LIST_ITEM_KOV_F));
|
||||
];
|
||||
|
||||
[ LIST_OF_TY_Distinguish txb1 txb2;
|
||||
|
@ -163,10 +163,10 @@ lists of equal size in lexicographic order.
|
|||
=
|
||||
[ LIST_OF_TY_Hash list len kov rv i;
|
||||
rv = 0;
|
||||
len = BlkValueRead(list, LIST_LENGTH_F);
|
||||
kov = BlkValueRead(list, LIST_ITEM_KOV_F);
|
||||
len = PVField(list, LIST_LENGTH_F);
|
||||
kov = PVField(list, LIST_ITEM_KOV_F);
|
||||
for (i=0: i<len: i++)
|
||||
rv = rv * 33 + GetHashValue(kov, BlkValueRead(list, i+LIST_ITEM_BASE));
|
||||
rv = rv * 33 + GetHashValue(kov, PVField(list, i+LIST_ITEM_BASE));
|
||||
return rv;
|
||||
];
|
||||
|
||||
|
@ -181,12 +181,12 @@ use the "listing contents of..." activity in any circumstances.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Say list format no_items v i bk;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
bk = KindAtomic(BlkValueRead(list, LIST_ITEM_KOV_F));
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
bk = KindAtomic(PVField(list, LIST_ITEM_KOV_F));
|
||||
if (format == 1) print "{";
|
||||
for (i=0:i<no_items:i++) {
|
||||
v = BlkValueRead(list, i+LIST_ITEM_BASE);
|
||||
v = PVField(list, i+LIST_ITEM_BASE);
|
||||
switch (format) {
|
||||
2: print (the) v;
|
||||
3: print (a) v;
|
||||
|
@ -225,21 +225,21 @@ then to transcribe them.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Desc list desc kov obj no_items ex len i;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return false;
|
||||
ex = BlkValueLBCapacity(list);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return false;
|
||||
ex = PVFieldCapacity(list);
|
||||
len = desc(-3);
|
||||
if (len+LIST_ITEM_BASE > ex) {
|
||||
if (BlkValueSetLBCapacity(list, len+LIST_ITEM_BASE) == false)
|
||||
if (SetPVFieldCapacity(list, len+LIST_ITEM_BASE) == false)
|
||||
return 0;
|
||||
}
|
||||
if (kov) BlkValueWrite(list, LIST_ITEM_KOV_F, kov);
|
||||
else BlkValueWrite(list, LIST_ITEM_KOV_F, OBJECT_TY);
|
||||
BlkValueWrite(list, LIST_LENGTH_F, len);
|
||||
if (kov) WritePVField(list, LIST_ITEM_KOV_F, kov);
|
||||
else WritePVField(list, LIST_ITEM_KOV_F, OBJECT_TY);
|
||||
WritePVField(list, LIST_LENGTH_F, len);
|
||||
obj = 0;
|
||||
for (i=0: i<len: i++) {
|
||||
obj = desc(-2, obj, i);
|
||||
! print "i = ", i, " and obj = ", obj, "^";
|
||||
BlkValueWrite(list, i+LIST_ITEM_BASE, obj);
|
||||
WritePVField(list, i+LIST_ITEM_BASE, obj);
|
||||
}
|
||||
return list;
|
||||
];
|
||||
|
@ -252,15 +252,15 @@ performed. In other words, one copy of "Alert" is equal to another.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_FindItem list v i no_items cf;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) rfalse;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) rfalse;
|
||||
cf = LIST_OF_TY_ComparisonFn(list);
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if (cf == 0 or UnsignedCompare) {
|
||||
for (i=0: i<no_items: i++)
|
||||
if (v == BlkValueRead(list, i+LIST_ITEM_BASE)) rtrue;
|
||||
if (v == PVField(list, i+LIST_ITEM_BASE)) rtrue;
|
||||
} else {
|
||||
for (i=0: i<no_items: i++)
|
||||
if (cf(v, BlkValueRead(list, i+LIST_ITEM_BASE)) == 0) rtrue;
|
||||
if (cf(v, PVField(list, i+LIST_ITEM_BASE)) == 0) rtrue;
|
||||
}
|
||||
rfalse;
|
||||
];
|
||||
|
@ -282,11 +282,11 @@ where $N$ is the number of items in the list at present.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_InsertItem list v posnflag posn nodups i no_items ex nv contents_kind;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return false;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return false;
|
||||
if (nodups && (LIST_OF_TY_FindItem(list, v))) return list;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items); ! Forces the list to be mutable
|
||||
contents_kind = BlkValueRead(list, LIST_ITEM_KOV_F);
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
WritePVField(list, LIST_LENGTH_F, no_items); ! Forces the list to be mutable
|
||||
contents_kind = PVField(list, LIST_ITEM_KOV_F);
|
||||
if ((posnflag) && ((posn<1) || (posn > no_items+1))) {
|
||||
IssueRTP("AccessedNonExistentListItem",
|
||||
"Attempt to use list item which does not exist.", BasicInformKitRTPs);
|
||||
|
@ -295,26 +295,26 @@ where $N$ is the number of items in the list at present.
|
|||
print ", which has entries in the range 1 to ", no_items, " ***^";
|
||||
rfalse;
|
||||
}
|
||||
ex = BlkValueLBCapacity(list);
|
||||
ex = PVFieldCapacity(list);
|
||||
if (no_items+LIST_ITEM_BASE+1 > ex) {
|
||||
if (BlkValueSetLBCapacity(list, ex+16) == false) return 0;
|
||||
if (SetPVFieldCapacity(list, ex+16) == false) return 0;
|
||||
}
|
||||
if (KOVIsBlockValue(contents_kind)) {
|
||||
nv = BlkValueCreate(contents_kind);
|
||||
BlkValueCopy(nv, v);
|
||||
if (ConformsTo_POINTER_VALUE_TY(contents_kind)) {
|
||||
nv = CreatePV(contents_kind);
|
||||
CopyPV(nv, v);
|
||||
v = nv;
|
||||
}
|
||||
if (posnflag) {
|
||||
posn--;
|
||||
for (i=no_items:i>posn:i--) {
|
||||
BlkValueWrite(list, i+LIST_ITEM_BASE,
|
||||
BlkValueRead(list, i-1+LIST_ITEM_BASE));
|
||||
WritePVField(list, i+LIST_ITEM_BASE,
|
||||
PVField(list, i-1+LIST_ITEM_BASE));
|
||||
}
|
||||
BlkValueWrite(list, posn+LIST_ITEM_BASE, v);
|
||||
WritePVField(list, posn+LIST_ITEM_BASE, v);
|
||||
} else {
|
||||
BlkValueWrite(list, no_items+LIST_ITEM_BASE, v);
|
||||
WritePVField(list, no_items+LIST_ITEM_BASE, v);
|
||||
}
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items+1);
|
||||
WritePVField(list, LIST_LENGTH_F, no_items+1);
|
||||
return list;
|
||||
];
|
||||
|
||||
|
@ -327,10 +327,10 @@ value |v| to insert, the specification is the same as for
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_AppendList list more posnflag posn nodups v i j no_items msize ex nv;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return false;
|
||||
if ((more==0) || (BlkValueWeakKind(more) ~= LIST_OF_TY)) return list;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items); ! Forces the list to be mutable
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return false;
|
||||
if (WeakKindOfPV(more) ~= LIST_OF_TY) return list;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
WritePVField(list, LIST_LENGTH_F, no_items); ! Forces the list to be mutable
|
||||
if ((posnflag) && ((posn<1) || (posn > no_items+1))) {
|
||||
IssueRTP("AccessedNonExistentListItem",
|
||||
"Attempt to use list item which does not exist.", BasicInformKitRTPs);
|
||||
|
@ -339,43 +339,43 @@ value |v| to insert, the specification is the same as for
|
|||
print ", which has entries in the range 1 to ", no_items, " ***^";
|
||||
rfalse;
|
||||
}
|
||||
msize = BlkValueRead(more, LIST_LENGTH_F);
|
||||
ex = BlkValueLBCapacity(list);
|
||||
msize = PVField(more, LIST_LENGTH_F);
|
||||
ex = PVFieldCapacity(list);
|
||||
if (no_items+msize+LIST_ITEM_BASE > ex) {
|
||||
if (BlkValueSetLBCapacity(list, no_items+msize+LIST_ITEM_BASE+8) == false)
|
||||
if (SetPVFieldCapacity(list, no_items+msize+LIST_ITEM_BASE+8) == false)
|
||||
return 0;
|
||||
}
|
||||
if (posnflag) {
|
||||
posn--;
|
||||
for (i=no_items+msize:i>=posn+msize:i--) {
|
||||
BlkValueWrite(list, i+LIST_ITEM_BASE,
|
||||
BlkValueRead(list, i-msize+LIST_ITEM_BASE));
|
||||
WritePVField(list, i+LIST_ITEM_BASE,
|
||||
PVField(list, i-msize+LIST_ITEM_BASE));
|
||||
}
|
||||
! BlkValueWrite(list, posn, v);
|
||||
! WritePVField(list, posn, v);
|
||||
for (j=0: j<msize: j++) {
|
||||
v = BlkValueRead(more, j+LIST_ITEM_BASE);
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F))) {
|
||||
nv = BlkValueCreate(BlkValueRead(list, LIST_ITEM_KOV_F));
|
||||
BlkValueCopy(nv, v);
|
||||
v = PVField(more, j+LIST_ITEM_BASE);
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F))) {
|
||||
nv = CreatePV(PVField(list, LIST_ITEM_KOV_F));
|
||||
CopyPV(nv, v);
|
||||
v = nv;
|
||||
}
|
||||
BlkValueWrite(list, posn+j+LIST_ITEM_BASE, v);
|
||||
WritePVField(list, posn+j+LIST_ITEM_BASE, v);
|
||||
}
|
||||
} else {
|
||||
for (i=0, j=0: i<msize: i++) {
|
||||
v = BlkValueRead(more, i+LIST_ITEM_BASE);
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F))) {
|
||||
nv = BlkValueCreate(BlkValueRead(list, LIST_ITEM_KOV_F));
|
||||
BlkValueCopy(nv, v);
|
||||
v = PVField(more, i+LIST_ITEM_BASE);
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F))) {
|
||||
nv = CreatePV(PVField(list, LIST_ITEM_KOV_F));
|
||||
CopyPV(nv, v);
|
||||
v = nv;
|
||||
}
|
||||
if ((nodups == 0) || (LIST_OF_TY_FindItem(list, v) == false)) {
|
||||
BlkValueWrite(list, no_items+j+LIST_ITEM_BASE, v);
|
||||
WritePVField(list, no_items+j+LIST_ITEM_BASE, v);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items+j);
|
||||
WritePVField(list, LIST_LENGTH_F, no_items+j);
|
||||
return list;
|
||||
];
|
||||
|
||||
|
@ -385,28 +385,28 @@ optional flag |forgive| is set, then we make no complaint if no value of
|
|||
|v| was present in the first place: otherwise, we issue a run-time problem.
|
||||
|
||||
Note that if the list contains block-values then the value must be properly
|
||||
destroyed with |BlkValueFree| before being overwritten as the items shuffle down.
|
||||
destroyed with |DestroyPV| before being overwritten as the items shuffle down.
|
||||
|
||||
=
|
||||
[ LIST_OF_TY_RemoveValue list v forgive i j no_items odsize f cf delendum;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) rfalse;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) rfalse;
|
||||
cf = LIST_OF_TY_ComparisonFn(list);
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F); odsize = no_items;
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items); ! Forces the list to be mutable
|
||||
no_items = PVField(list, LIST_LENGTH_F); odsize = no_items;
|
||||
WritePVField(list, LIST_LENGTH_F, no_items); ! Forces the list to be mutable
|
||||
for (i=0: i<no_items: i++) {
|
||||
delendum = BlkValueRead(list, i+LIST_ITEM_BASE);
|
||||
delendum = PVField(list, i+LIST_ITEM_BASE);
|
||||
if (cf == 0 or UnsignedCompare)
|
||||
f = (v == delendum);
|
||||
else
|
||||
f = (cf(v, delendum) == 0);
|
||||
if (f) {
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F)))
|
||||
BlkValueFree(delendum);
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F)))
|
||||
DestroyPV(delendum);
|
||||
for (j=i+1: j<no_items: j++)
|
||||
BlkValueWrite(list, j-1+LIST_ITEM_BASE,
|
||||
BlkValueRead(list, j+LIST_ITEM_BASE));
|
||||
WritePVField(list, j-1+LIST_ITEM_BASE,
|
||||
PVField(list, j+LIST_ITEM_BASE));
|
||||
no_items--; i--;
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items);
|
||||
WritePVField(list, LIST_LENGTH_F, no_items);
|
||||
}
|
||||
}
|
||||
if (odsize ~= no_items) rfalse;
|
||||
|
@ -414,7 +414,7 @@ destroyed with |BlkValueFree| before being overwritten as the items shuffle down
|
|||
IssueRTP("AccessedNonExistentListItem",
|
||||
"Attempt to use list item which does not exist.", BasicInformKitRTPs);
|
||||
print "*** Couldn't remove: the value ";
|
||||
PrintKindValuePair(BlkValueRead(list, LIST_ITEM_KOV_F), v);
|
||||
PrintKindValuePair(PVField(list, LIST_ITEM_KOV_F), v);
|
||||
print " was not present in the list ";
|
||||
LIST_OF_TY_Say(list, true);
|
||||
print " ***^";
|
||||
|
@ -432,8 +432,8 @@ as the list shuffles down to fill the void.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_RemoveItemRange list from to forgive i d no_items;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) rfalse;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) rfalse;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if ((from > to) || (from <= 0) || (to > no_items)) {
|
||||
if (forgive) {
|
||||
if (from <= 0) from = 1;
|
||||
|
@ -450,13 +450,13 @@ as the list shuffles down to fill the void.
|
|||
}
|
||||
to--; from--;
|
||||
d = to-from+1;
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F)))
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F)))
|
||||
for (i=0: i<d: i++)
|
||||
BlkValueFree(BlkValueRead(list, from+i+LIST_ITEM_BASE));
|
||||
DestroyPV(PVField(list, from+i+LIST_ITEM_BASE));
|
||||
for (i=from: i<no_items-d: i++)
|
||||
BlkValueWrite(list, i+LIST_ITEM_BASE,
|
||||
BlkValueRead(list, i+d+LIST_ITEM_BASE));
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items-d);
|
||||
WritePVField(list, i+LIST_ITEM_BASE,
|
||||
PVField(list, i+d+LIST_ITEM_BASE));
|
||||
WritePVField(list, LIST_LENGTH_F, no_items-d);
|
||||
return list;
|
||||
];
|
||||
|
||||
|
@ -474,26 +474,26 @@ happened in this situation to be unhelpful.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Remove_List list rlist i j k v w no_items odsize rsize cf f;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) rfalse;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F); odsize = no_items;
|
||||
rsize = BlkValueRead(rlist, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) rfalse;
|
||||
no_items = PVField(list, LIST_LENGTH_F); odsize = no_items;
|
||||
rsize = PVField(rlist, LIST_LENGTH_F);
|
||||
cf = LIST_OF_TY_ComparisonFn(list);
|
||||
for (i=0: i<no_items: i++) {
|
||||
v = BlkValueRead(list, i+LIST_ITEM_BASE);
|
||||
v = PVField(list, i+LIST_ITEM_BASE);
|
||||
for (k=0: k<rsize: k++) {
|
||||
w = BlkValueRead(rlist, k+LIST_ITEM_BASE);
|
||||
w = PVField(rlist, k+LIST_ITEM_BASE);
|
||||
if (cf == 0 or UnsignedCompare)
|
||||
f = (v == w);
|
||||
else
|
||||
f = (cf(v, w) == 0);
|
||||
if (f) {
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F)))
|
||||
BlkValueFree(v);
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F)))
|
||||
DestroyPV(v);
|
||||
for (j=i+1: j<no_items: j++)
|
||||
BlkValueWrite(list, j+LIST_ITEM_BASE-1,
|
||||
BlkValueRead(list, j+LIST_ITEM_BASE));
|
||||
WritePVField(list, j+LIST_ITEM_BASE-1,
|
||||
PVField(list, j+LIST_ITEM_BASE));
|
||||
no_items--; i--;
|
||||
BlkValueWrite(list, LIST_LENGTH_F, no_items);
|
||||
WritePVField(list, LIST_LENGTH_F, no_items);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -505,13 +505,13 @@ happened in this situation to be unhelpful.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_GetLength list;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
return BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
return PVField(list, LIST_LENGTH_F);
|
||||
];
|
||||
|
||||
[ LIST_OF_TY_Empty list;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) rfalse;
|
||||
if (BlkValueRead(list, LIST_LENGTH_F) == 0) rtrue;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) rfalse;
|
||||
if (PVField(list, LIST_LENGTH_F) == 0) rtrue;
|
||||
rfalse;
|
||||
];
|
||||
|
||||
|
@ -533,38 +533,38 @@ if |truncation_end| is 1, or from the start if it is $-1$.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_SetLength list newsize this_way_only truncation_end no_items ex i dv;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
if (newsize < 0) return IssueRTP("ResizedListToNegativeSize",
|
||||
"Attempt to resize list to negative size.", BasicInformKitRTPs);
|
||||
BlkMakeMutable(list);
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if (no_items < newsize) {
|
||||
if (this_way_only == -1) return list;
|
||||
ex = BlkValueLBCapacity(list);
|
||||
ex = PVFieldCapacity(list);
|
||||
if (newsize+LIST_ITEM_BASE > ex) {
|
||||
if (BlkValueSetLBCapacity(list, newsize+LIST_ITEM_BASE) == false)
|
||||
if (SetPVFieldCapacity(list, newsize+LIST_ITEM_BASE) == false)
|
||||
return 0;
|
||||
}
|
||||
dv = DefaultValueOfKOV(BlkValueRead(list, LIST_ITEM_KOV_F));
|
||||
dv = DefaultValueOfKOV(PVField(list, LIST_ITEM_KOV_F));
|
||||
for (i=no_items: i<newsize: i++)
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i, dv);
|
||||
BlkValueWrite(list, LIST_LENGTH_F, newsize);
|
||||
WritePVField(list, LIST_ITEM_BASE+i, dv);
|
||||
WritePVField(list, LIST_LENGTH_F, newsize);
|
||||
}
|
||||
if (no_items > newsize) {
|
||||
if (this_way_only == 1) return list;
|
||||
if (truncation_end == -1) {
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F)))
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F)))
|
||||
for (i=0: i<no_items-newsize: i++)
|
||||
BlkValueFree(BlkValueRead(list, LIST_ITEM_BASE+i));
|
||||
DestroyPV(PVField(list, LIST_ITEM_BASE+i));
|
||||
for (i=0: i<newsize: i++)
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i,
|
||||
BlkValueRead(list, LIST_ITEM_BASE+no_items-newsize+i));
|
||||
WritePVField(list, LIST_ITEM_BASE+i,
|
||||
PVField(list, LIST_ITEM_BASE+no_items-newsize+i));
|
||||
} else {
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F)))
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F)))
|
||||
for (i=newsize: i<no_items: i++)
|
||||
BlkValueFree(BlkValueRead(list, LIST_ITEM_BASE+i));
|
||||
DestroyPV(PVField(list, LIST_ITEM_BASE+i));
|
||||
}
|
||||
BlkValueWrite(list, LIST_LENGTH_F, newsize);
|
||||
WritePVField(list, LIST_LENGTH_F, newsize);
|
||||
}
|
||||
return list;
|
||||
];
|
||||
|
@ -573,8 +573,8 @@ if |truncation_end| is 1, or from the start if it is $-1$.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_GetItem list i forgive no_items;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return false;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return false;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if ((i<=0) || (i>no_items)) {
|
||||
if (forgive) return false;
|
||||
IssueRTP("AccessedNonExistentListItem",
|
||||
|
@ -588,7 +588,7 @@ if |truncation_end| is 1, or from the start if it is $-1$.
|
|||
if (no_items >= 1) i = 1;
|
||||
else return false;
|
||||
}
|
||||
return BlkValueRead(list, LIST_ITEM_BASE+i-1);
|
||||
return PVField(list, LIST_ITEM_BASE+i-1);
|
||||
];
|
||||
|
||||
@h Write Item.
|
||||
|
@ -598,8 +598,8 @@ to convert an rvalue such as |LIST_OF_TY_GetItem(L, 4)| is to prefix
|
|||
|
||||
=
|
||||
[ WriteLIST_OF_TY_GetItem list i val no_items;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return false;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return false;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if ((i<=0) || (i>no_items)) {
|
||||
IssueRTP("AccessedNonExistentListItem",
|
||||
"Attempt to use list item which does not exist.", BasicInformKitRTPs);
|
||||
|
@ -610,7 +610,7 @@ to convert an rvalue such as |LIST_OF_TY_GetItem(L, 4)| is to prefix
|
|||
default: print " has entries numbered from 1 to ", no_items, " ***^";
|
||||
}
|
||||
} else {
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i-1, val);
|
||||
WritePVField(list, LIST_ITEM_BASE+i-1, val);
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -621,15 +621,15 @@ used instead.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_PutItem list i v no_items nv;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return false;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (KOVIsBlockValue(BlkValueRead(list, LIST_ITEM_KOV_F))) {
|
||||
nv = BlkValueCreate(BlkValueRead(list, LIST_ITEM_KOV_F));
|
||||
BlkValueCopy(nv, v);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return false;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if (ConformsTo_POINTER_VALUE_TY(PVField(list, LIST_ITEM_KOV_F))) {
|
||||
nv = CreatePV(PVField(list, LIST_ITEM_KOV_F));
|
||||
CopyPV(nv, v);
|
||||
v = nv;
|
||||
}
|
||||
if ((i<=0) || (i>no_items)) return false;
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i-1, v);
|
||||
WritePVField(list, LIST_ITEM_BASE+i-1, v);
|
||||
];
|
||||
|
||||
@h Reversing.
|
||||
|
@ -640,14 +640,14 @@ block-values and simply move them around like any other data.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Reverse list no_items i v;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if (no_items < 2) return list;
|
||||
for (i=0:i*2<no_items:i++) {
|
||||
v = BlkValueRead(list, LIST_ITEM_BASE+i);
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i,
|
||||
BlkValueRead(list, LIST_ITEM_BASE+no_items-1-i));
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+no_items-1-i, v);
|
||||
v = PVField(list, LIST_ITEM_BASE+i);
|
||||
WritePVField(list, LIST_ITEM_BASE+i,
|
||||
PVField(list, LIST_ITEM_BASE+no_items-1-i));
|
||||
WritePVField(list, LIST_ITEM_BASE+no_items-1-i, v);
|
||||
}
|
||||
return list;
|
||||
];
|
||||
|
@ -658,21 +658,21 @@ end of the list, "backwards" means towards the start.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Rotate list backwards no_items i v;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if (no_items < 2) return list;
|
||||
if (backwards) {
|
||||
v = BlkValueRead(list, LIST_ITEM_BASE);
|
||||
v = PVField(list, LIST_ITEM_BASE);
|
||||
for (i=0:i<no_items-1:i++)
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i,
|
||||
BlkValueRead(list, LIST_ITEM_BASE+i+1));
|
||||
BlkValueWrite(list, no_items-1+LIST_ITEM_BASE, v);
|
||||
WritePVField(list, LIST_ITEM_BASE+i,
|
||||
PVField(list, LIST_ITEM_BASE+i+1));
|
||||
WritePVField(list, no_items-1+LIST_ITEM_BASE, v);
|
||||
} else {
|
||||
v = BlkValueRead(list, no_items-1+LIST_ITEM_BASE);
|
||||
v = PVField(list, no_items-1+LIST_ITEM_BASE);
|
||||
for (i=no_items-1:i>0:i--)
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i,
|
||||
BlkValueRead(list, LIST_ITEM_BASE+i-1));
|
||||
BlkValueWrite(list, LIST_ITEM_BASE, v);
|
||||
WritePVField(list, LIST_ITEM_BASE+i,
|
||||
PVField(list, LIST_ITEM_BASE+i-1));
|
||||
WritePVField(list, LIST_ITEM_BASE, v);
|
||||
}
|
||||
return list;
|
||||
];
|
||||
|
@ -701,14 +701,14 @@ Global LIST_OF_TY_Sort_cf;
|
|||
|
||||
[ LIST_OF_TY_Sort list dir prop prop_is_bv cf i j no_items v;
|
||||
BlkMakeMutable(list);
|
||||
no_items = BlkValueRead(list, LIST_LENGTH_F);
|
||||
no_items = PVField(list, LIST_LENGTH_F);
|
||||
if (dir == SORT_LIST_RANDOM) {
|
||||
if (no_items < 2) return;
|
||||
for (i=1:i<no_items:i++) {
|
||||
j = random(i+1) - 1;
|
||||
v = BlkValueRead(list, LIST_ITEM_BASE+i);
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i, BlkValueRead(list, LIST_ITEM_BASE+j));
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+j, v);
|
||||
v = PVField(list, LIST_ITEM_BASE+i);
|
||||
WritePVField(list, LIST_ITEM_BASE+i, PVField(list, LIST_ITEM_BASE+j));
|
||||
WritePVField(list, LIST_ITEM_BASE+j, v);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -718,7 +718,7 @@ Global LIST_OF_TY_Sort_cf;
|
|||
}
|
||||
else if (prop) {
|
||||
if (prop_is_bv) {
|
||||
LIST_OF_TY_Sort_cf = BlkValueCompare;
|
||||
LIST_OF_TY_Sort_cf = ComparePV;
|
||||
}
|
||||
else {
|
||||
LIST_OF_TY_Sort_cf = 0;
|
||||
|
@ -732,15 +732,15 @@ Global LIST_OF_TY_Sort_cf;
|
|||
|
||||
[ ListSwapEntries list i j v;
|
||||
if (i==j) return;
|
||||
v = BlkValueRead(list, LIST_ITEM_BASE+i-1);
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+i-1, BlkValueRead(list, LIST_ITEM_BASE+j-1));
|
||||
BlkValueWrite(list, LIST_ITEM_BASE+j-1, v);
|
||||
v = PVField(list, LIST_ITEM_BASE+i-1);
|
||||
WritePVField(list, LIST_ITEM_BASE+i-1, PVField(list, LIST_ITEM_BASE+j-1));
|
||||
WritePVField(list, LIST_ITEM_BASE+j-1, v);
|
||||
];
|
||||
|
||||
[ ListCompareEntries list col i j d;
|
||||
if (i==j) return 0;
|
||||
i = BlkValueRead(list, LIST_ITEM_BASE+i-1);
|
||||
j = BlkValueRead(list, LIST_ITEM_BASE+j-1);
|
||||
i = PVField(list, LIST_ITEM_BASE+i-1);
|
||||
j = PVField(list, LIST_ITEM_BASE+j-1);
|
||||
if (I7S_Col) {
|
||||
if (i provides I7S_Col) i=i.I7S_Col; else i=0;
|
||||
if (j provides I7S_Col) j=j.I7S_Col; else j=0;
|
||||
|
|
|
@ -201,7 +201,7 @@ Global match0_idx2; ! for plain text match, index of final character match
|
|||
print "Subexp ", offset-->RE_PAR1,
|
||||
" = [", offset-->RE_DATA1, ",", offset-->RE_DATA2, "] = ";
|
||||
for (i=offset-->RE_DATA1:i<offset-->RE_DATA2:i++)
|
||||
print (char) BlkValueRead(txt, i);
|
||||
print (char) PVField(txt, i);
|
||||
print "^";
|
||||
}
|
||||
];
|
||||
|
@ -210,21 +210,21 @@ Global match0_idx2; ! for plain text match, index of final character match
|
|||
offset n i ch ctxt cl csize;
|
||||
for (n=0:(n<RE_Subexpressions-->10) && (n<10): n++) {
|
||||
offset = RE_Subexpressions-->n;
|
||||
if (Allocated_Match_Vars-->n) BlkValueFree(Allocated_Match_Vars-->n);
|
||||
Allocated_Match_Vars-->n = BlkValueCreate(TEXT_TY);
|
||||
if (Allocated_Match_Vars-->n) DestroyPV(Allocated_Match_Vars-->n);
|
||||
Allocated_Match_Vars-->n = CreatePV(TEXT_TY);
|
||||
TEXT_TY_Transmute(Allocated_Match_Vars-->n);
|
||||
ctxt = Allocated_Match_Vars-->n;
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
cl = 0;
|
||||
for (i=offset-->RE_DATA1:i<offset-->RE_DATA2:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (cl+1 >= csize) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl, 0);
|
||||
WritePVField(ctxt, cl, 0);
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -232,7 +232,7 @@ Global match0_idx2; ! for plain text match, index of final character match
|
|||
n;
|
||||
for (n=0:((n<RE_Subexpressions-->10) && (n<10)): n++)
|
||||
if (Allocated_Match_Vars-->n ~= 0)
|
||||
BlkValueWrite(Allocated_Match_Vars-->n, 0, 0);
|
||||
WritePVField(Allocated_Match_Vars-->n, 0, 0);
|
||||
];
|
||||
|
||||
[ TEXT_TY_RE_GetMatchVar vn
|
||||
|
@ -339,7 +339,7 @@ but it is relatively compact and we keep it just in case.
|
|||
NOTHING_RE_CC: print "NOTHING";
|
||||
RANGE_RE_CC: print "RANGE"; if (par3 == true) print " (negated)";
|
||||
print " ";
|
||||
for (i=par1:i<par2:i++) print (char) BlkValueRead(ftxt, i);
|
||||
for (i=par1:i<par2:i++) print (char) PVField(ftxt, i);
|
||||
VARIABLE_RE_CC: print "VARIABLE ", par1;
|
||||
SUBEXP_RE_CC:
|
||||
if (par1 == 0) print "EXP";
|
||||
|
@ -365,7 +365,7 @@ but it is relatively compact and we keep it just in case.
|
|||
if (par3) print " (lazy)"; else print " (greedy)";
|
||||
LITERAL_RE_CC: print "LITERAL";
|
||||
print " ";
|
||||
for (i=par1:i<par2:i++) print (char) BlkValueRead(ftxt, i);
|
||||
for (i=par1:i<par2:i++) print (char) PVField(ftxt, i);
|
||||
DISJUNCTION_RE_CC: print "DISJUNCTION of ", par1, " choices";
|
||||
CHOICE_RE_CC: print "CHOICE no ", par1;
|
||||
SENSITIVITY_RE_CC: print "SENSITIVITY";
|
||||
|
@ -445,10 +445,10 @@ Array Subexp_Posns --> 20;
|
|||
quantifiable = false; blevel = 0;
|
||||
|
||||
for (ffrom = 0: ffrom < fto: ) {
|
||||
cc = BlkValueRead(ftxt, ffrom++); par1 = 0; par2 = 0; par3 = 0;
|
||||
cc = PVField(ftxt, ffrom++); par1 = 0; par2 = 0; par3 = 0;
|
||||
if (cc == '\') {
|
||||
if (ffrom == fto) return "Search pattern not terminated";
|
||||
cc = BlkValueRead(ftxt, ffrom++);
|
||||
cc = PVField(ftxt, ffrom++);
|
||||
switch (cc) {
|
||||
'b': cc = BOUNDARY_RE_CC;
|
||||
'B': cc = NONBOUNDARY_RE_CC;
|
||||
|
@ -481,21 +481,21 @@ Array Subexp_Posns --> 20;
|
|||
} else {
|
||||
switch (cc) {
|
||||
'(': par2 = 0;
|
||||
!if (BlkValueRead(ftxt, ffrom) == ')') return "empty subexpression";
|
||||
if (BlkValueRead(ftxt, ffrom) == '?') {
|
||||
!if (PVField(ftxt, ffrom) == ')') return "empty subexpression";
|
||||
if (PVField(ftxt, ffrom) == '?') {
|
||||
ffrom++;
|
||||
bits = true;
|
||||
if (BlkValueRead(ftxt, ffrom) == '-') { ffrom++; bits = false; }
|
||||
else if (BlkValueRead(ftxt, ffrom) == '<') { ffrom++; bits = false; }
|
||||
switch (cc = BlkValueRead(ftxt, ffrom++)) {
|
||||
'#': while (BlkValueRead(ftxt, ffrom++) ~= 0 or ')') ;
|
||||
if (BlkValueRead(ftxt, ffrom-1) == 0)
|
||||
if (PVField(ftxt, ffrom) == '-') { ffrom++; bits = false; }
|
||||
else if (PVField(ftxt, ffrom) == '<') { ffrom++; bits = false; }
|
||||
switch (cc = PVField(ftxt, ffrom++)) {
|
||||
'#': while (PVField(ftxt, ffrom++) ~= 0 or ')') ;
|
||||
if (PVField(ftxt, ffrom-1) == 0)
|
||||
return "comment never ends";
|
||||
continue;
|
||||
'(': cc = BlkValueRead(ftxt, ffrom);
|
||||
'(': cc = PVField(ftxt, ffrom);
|
||||
if ((cc == '1' or '2' or '3' or '4' or
|
||||
'5' or '6' or '7' or '8' or '9') &&
|
||||
(BlkValueRead(ftxt, ffrom+1) ==')')) {
|
||||
(PVField(ftxt, ffrom+1) ==')')) {
|
||||
ffrom = ffrom + 2;
|
||||
par1 = cc - '0';
|
||||
} else ffrom--;
|
||||
|
@ -511,13 +511,13 @@ Array Subexp_Posns --> 20;
|
|||
':': par2 = 3; ! (?:...) uncollecting subexpression
|
||||
'>': par2 = 4; ! (?>...) possessive
|
||||
default:
|
||||
if (BlkValueRead(ftxt, ffrom) == ')') {
|
||||
if (PVField(ftxt, ffrom) == ')') {
|
||||
if (cc == 'i') {
|
||||
cc = SENSITIVITY_RE_CC; par1 = bits; ffrom++;
|
||||
jump CClassKnown;
|
||||
}
|
||||
}
|
||||
if (BlkValueRead(ftxt, ffrom) == ':') {
|
||||
if (PVField(ftxt, ffrom) == ':') {
|
||||
if (cc == 'i') {
|
||||
par1 = bits; par2 = 3; par3 = bits+1; ffrom++;
|
||||
jump AllowForm;
|
||||
|
@ -549,7 +549,7 @@ Array Subexp_Posns --> 20;
|
|||
'$': cc = END_RE_CC; quantifiable = false;
|
||||
'{': if (quantifiable == false) return "quantifier misplaced";
|
||||
par1 = 0; par2 = -1; bits = 1;
|
||||
while ((cc=BlkValueRead(ftxt, ffrom++)) ~= 0 or '}') {
|
||||
while ((cc=PVField(ftxt, ffrom++)) ~= 0 or '}') {
|
||||
if (cc == ',') {
|
||||
bits++;
|
||||
if (bits >= 3) return "too many colons in ?{...}";
|
||||
|
@ -572,25 +572,25 @@ Array Subexp_Posns --> 20;
|
|||
else par2 = par1;
|
||||
}
|
||||
if (par1 > par2) return "{x,y} with x greater than y";
|
||||
if (BlkValueRead(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
if (PVField(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
quantifiable = false;
|
||||
'<', '[': par3 = false; if (cc == '<') bits = '>'; else bits = ']';
|
||||
if (BlkValueRead(ftxt, ffrom) == '^') { ffrom++; par3 = true; }
|
||||
if (PVField(ftxt, ffrom) == '^') { ffrom++; par3 = true; }
|
||||
par1 = ffrom;
|
||||
if (BlkValueRead(ftxt, ffrom) == bits) { ffrom++; }
|
||||
if (PVField(ftxt, ffrom) == bits) { ffrom++; }
|
||||
while (cc ~= bits or 0) {
|
||||
cc = BlkValueRead(ftxt, ffrom++);
|
||||
cc = PVField(ftxt, ffrom++);
|
||||
if (cc == '\') {
|
||||
cc = BlkValueRead(ftxt, ffrom++);
|
||||
if (cc ~= 0) cc = BlkValueRead(ftxt, ffrom++);
|
||||
cc = PVField(ftxt, ffrom++);
|
||||
if (cc ~= 0) cc = PVField(ftxt, ffrom++);
|
||||
}
|
||||
}
|
||||
if (cc == 0) return "Character range never ends";
|
||||
par2 = ffrom-1;
|
||||
if ((par2 > par1 + 1) &&
|
||||
(BlkValueRead(ftxt, par1) == ':') &&
|
||||
(BlkValueRead(ftxt, par2-1) == ':') &&
|
||||
(BlkValueRead(ftxt, par2-2) ~= '\'))
|
||||
(PVField(ftxt, par1) == ':') &&
|
||||
(PVField(ftxt, par2-1) == ':') &&
|
||||
(PVField(ftxt, par2-2) ~= '\'))
|
||||
return "POSIX named character classes unsupported";
|
||||
bits = TEXT_TY_RE_RangeSyntaxCorrect(ftxt, par1, par2);
|
||||
if (bits) return bits;
|
||||
|
@ -600,17 +600,17 @@ Array Subexp_Posns --> 20;
|
|||
'*': if (quantifiable == false) return "quantifier misplaced";
|
||||
cc = QUANTIFIER_RE_CC;
|
||||
par1 = 0; par2 = 30000;
|
||||
if (BlkValueRead(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
if (PVField(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
quantifiable = false;
|
||||
'+': if (quantifiable == false) return "quantifier misplaced";
|
||||
cc = QUANTIFIER_RE_CC;
|
||||
par1 = 1; par2 = 30000;
|
||||
if (BlkValueRead(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
if (PVField(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
quantifiable = false;
|
||||
'?': if (quantifiable == false) return "quantifier misplaced";
|
||||
cc = QUANTIFIER_RE_CC;
|
||||
par1 = 0; par2 = 1;
|
||||
if (BlkValueRead(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
if (PVField(ftxt, ffrom) == '?') { ffrom++; par3 = true; }
|
||||
quantifiable = false;
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ Array Subexp_Posns --> 20;
|
|||
if (cc >= 0) {
|
||||
quantifiable = true;
|
||||
if ((attach_to-->RE_CCLASS == LITERAL_RE_CC) &&
|
||||
(BlkValueRead(ftxt, ffrom) ~= '*' or '+' or '?' or '{')) {
|
||||
(PVField(ftxt, ffrom) ~= '*' or '+' or '?' or '{')) {
|
||||
(attach_to-->RE_PAR2)++;
|
||||
if (TEXT_TY_RE_Trace == 2) {
|
||||
print "Extending literal by ", cc, "=", (char) cc, "^";
|
||||
|
@ -729,9 +729,9 @@ Array Subexp_Posns --> 20;
|
|||
[ TEXT_TY_RE_RangeSyntaxCorrect ftxt rf rt
|
||||
i chm;
|
||||
for (i=rf: i<rt: i++) {
|
||||
chm = BlkValueRead(ftxt, i);
|
||||
chm = PVField(ftxt, i);
|
||||
if ((chm == '\') && (i+1<rt)) {
|
||||
chm = BlkValueRead(ftxt, ++i);
|
||||
chm = PVField(ftxt, ++i);
|
||||
if (((chm >= 'a') && (chm <= 'z')) ||
|
||||
((chm >= 'A') && (chm <= 'Z'))) {
|
||||
if (chm ~= 's' or 'S' or 'p' or 'P' or 'w' or 'W' or 'd'
|
||||
|
@ -739,8 +739,8 @@ Array Subexp_Posns --> 20;
|
|||
return "Invalid escape in {} range";
|
||||
}
|
||||
}
|
||||
if ((i+2<rt) && (BlkValueRead(ftxt, i+1) == '-')) {
|
||||
if (chm > BlkValueRead(ftxt, i+2)) return "Invalid {} range";
|
||||
if ((i+2<rt) && (PVField(ftxt, i+1) == '-')) {
|
||||
if (chm > PVField(ftxt, i+2)) return "Invalid {} range";
|
||||
i=i+2;
|
||||
}
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ but mostly in order to match against a |LITERAL_RE_CC| node.
|
|||
TEXT_TY_RE_DebugNode(token, ftxt, true);
|
||||
}
|
||||
|
||||
if (ipos<ito) ch = BlkValueRead(txt, ipos); else ch = 0;
|
||||
if (ipos<ito) ch = PVField(txt, ipos); else ch = 0;
|
||||
|
||||
token-->RE_MODES = mode_flags; ! Save in case of backtrack
|
||||
|
||||
|
@ -1030,15 +1030,15 @@ but mostly in order to match against a |LITERAL_RE_CC| node.
|
|||
START_RE_CC:
|
||||
if (ipos == 0) outcome = true;
|
||||
END_RE_CC:
|
||||
if (BlkValueRead(txt, ipos) == 0) outcome = true;
|
||||
if (PVField(txt, ipos) == 0) outcome = true;
|
||||
BOUNDARY_RE_CC:
|
||||
rv = 0;
|
||||
if (BlkValueRead(txt, ipos) == 0 or 10 or 13 or 32 or 9
|
||||
if (PVField(txt, ipos) == 0 or 10 or 13 or 32 or 9
|
||||
or '.' or ',' or '!' or '?'
|
||||
or '-' or '/' or '"' or ':' or ';'
|
||||
or '(' or ')' or '[' or ']' or '{' or '}') rv++;
|
||||
if (ipos == 0) ch = 0;
|
||||
else ch = BlkValueRead(txt, ipos-1);
|
||||
else ch = PVField(txt, ipos-1);
|
||||
if (ch == 0 or 10 or 13 or 32 or 9
|
||||
or '.' or ',' or '!' or '?'
|
||||
or '-' or '/' or '"' or ':' or ';'
|
||||
|
@ -1046,12 +1046,12 @@ but mostly in order to match against a |LITERAL_RE_CC| node.
|
|||
if (rv == 1) outcome = true;
|
||||
NONBOUNDARY_RE_CC:
|
||||
rv = 0;
|
||||
if (BlkValueRead(txt, ipos) == 0 or 10 or 13 or 32 or 9
|
||||
if (PVField(txt, ipos) == 0 or 10 or 13 or 32 or 9
|
||||
or '.' or ',' or '!' or '?'
|
||||
or '-' or '/' or '"' or ':' or ';'
|
||||
or '(' or ')' or '[' or ']' or '{' or '}') rv++;
|
||||
if (ipos == 0) ch = 0;
|
||||
else ch = BlkValueRead(txt, ipos-1);
|
||||
else ch = PVField(txt, ipos-1);
|
||||
if (ch == 0 or 10 or 13 or 32 or 9
|
||||
or '.' or ',' or '!' or '?'
|
||||
or '-' or '/' or '"' or ':' or ';'
|
||||
|
@ -1513,13 +1513,13 @@ position |ipos| in the source text |txt|.
|
|||
if (mfrom < 0) return 0;
|
||||
if (insens)
|
||||
for (i=mfrom:i<mto:i++) {
|
||||
ch = BlkValueRead(mtxt, i);
|
||||
if (BlkValueRead(txt, ipos++) ~= ch or TEXT_TY_RevCase(ch))
|
||||
ch = PVField(mtxt, i);
|
||||
if (PVField(txt, ipos++) ~= ch or TEXT_TY_RevCase(ch))
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
for (i=mfrom:i<mto:i++)
|
||||
if (BlkValueRead(txt, ipos++) ~= BlkValueRead(mtxt, i))
|
||||
if (PVField(txt, ipos++) ~= PVField(mtxt, i))
|
||||
return -1;
|
||||
return mto-mfrom;
|
||||
];
|
||||
|
@ -1540,9 +1540,9 @@ case insensitively if |insens| is set.
|
|||
rtrue;
|
||||
}
|
||||
for (i=rf: i<rt: i++) {
|
||||
chm = BlkValueRead(ftxt, i);
|
||||
chm = PVField(ftxt, i);
|
||||
if ((chm == '\') && (i+1<rt)) {
|
||||
chm = BlkValueRead(ftxt, ++i);
|
||||
chm = PVField(ftxt, ++i);
|
||||
switch (chm) {
|
||||
's':
|
||||
if (ch == 10 or 13 or 32 or 9) rtrue;
|
||||
|
@ -1580,8 +1580,8 @@ case insensitively if |insens| is set.
|
|||
't': if (ch == 9) rtrue;
|
||||
}
|
||||
} else {
|
||||
if ((i+2<rt) && (BlkValueRead(ftxt, i+1) == '-')) {
|
||||
upper = BlkValueRead(ftxt, i+2);
|
||||
if ((i+2<rt) && (PVField(ftxt, i+1) == '-')) {
|
||||
upper = PVField(ftxt, i+2);
|
||||
if ((ch >= chm) && (ch <= upper)) rtrue;
|
||||
if (insens) {
|
||||
crev = TEXT_TY_RevCase(ch);
|
||||
|
@ -1621,9 +1621,6 @@ For an explanation of the use of the word "blob", see "Text.i6t".
|
|||
=
|
||||
[ TEXT_TY_Replace_RE ftxtype txt ftxt rtxt insens exactly
|
||||
r p p1 p2 cp cp1 cp2;
|
||||
!print "Find: "; BlkValueDebug(ftxt); print "^";
|
||||
!print "Rep: "; BlkValueDebug(rtxt); print "^";
|
||||
!print "In: "; BlkValueDebug(txt); print "^";
|
||||
if (rtxt == 0 or 1) { cp = txt-->0; p = TEXT_TY_Temporarily_Transmute(txt); }
|
||||
else TEXT_TY_Transmute(txt);
|
||||
cp1 = ftxt-->0; p1 = TEXT_TY_Temporarily_Transmute(ftxt);
|
||||
|
@ -1674,7 +1671,7 @@ For an explanation of the use of the word "blob", see "Text.i6t".
|
|||
print "<empty>";
|
||||
}
|
||||
for (i=RE_PACKET_space-->RE_DATA1:i<RE_PACKET_space-->RE_DATA2:i++) {
|
||||
print (char) BlkValueRead(txt, i);
|
||||
print (char) PVField(txt, i);
|
||||
}
|
||||
print " ***^";
|
||||
}
|
||||
|
@ -1686,23 +1683,23 @@ For an explanation of the use of the word "blob", see "Text.i6t".
|
|||
|
||||
if (rtxt ~= 0 or 1) {
|
||||
if (chm == 1) {
|
||||
ctxt = BlkValueCreate(TEXT_TY);
|
||||
ctxt = CreatePV(TEXT_TY);
|
||||
TEXT_TY_Transmute(ctxt);
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
}
|
||||
|
||||
for (i=cpos:i<RE_PACKET_space-->RE_DATA1:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (cl+1 >= csize) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl, 0);
|
||||
WritePVField(ctxt, cl, 0);
|
||||
|
||||
TEXT_TY_Concatenate(ctxt, rtxt, ftxtype, txt);
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
cl = TEXT_TY_CharacterLength(ctxt);
|
||||
}
|
||||
|
||||
|
@ -1719,12 +1716,12 @@ For an explanation of the use of the word "blob", see "Text.i6t".
|
|||
if (chm > 0) {
|
||||
if (rtxt ~= 0 or 1) {
|
||||
for (i=cpos:i<ilen:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (cl+1 >= csize) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1735,9 +1732,9 @@ For an explanation of the use of the word "blob", see "Text.i6t".
|
|||
}
|
||||
|
||||
if (rtxt ~= 0 or 1) {
|
||||
BlkValueWrite(ctxt, cl, 0);
|
||||
BlkValueCopy(txt, ctxt);
|
||||
BlkValueFree(ctxt);
|
||||
WritePVField(ctxt, cl, 0);
|
||||
CopyPV(txt, ctxt);
|
||||
DestroyPV(ctxt);
|
||||
}
|
||||
}
|
||||
return chm;
|
||||
|
@ -1750,21 +1747,21 @@ which handles the special syntaxes used in search-and-replace.
|
|||
=
|
||||
[ TEXT_TY_RE_Concatenate txt_to txt_from blobtype txt_ref
|
||||
pos len ch i tosize x y case;
|
||||
if ((txt_to==0) || (BlkValueWeakKind(txt_to) ~= TEXT_TY)) rfalse;
|
||||
if ((txt_from==0) || (BlkValueWeakKind(txt_from) ~= TEXT_TY)) return txt_to;
|
||||
if (WeakKindOfPV(txt_to) ~= TEXT_TY) rfalse;
|
||||
if (WeakKindOfPV(txt_from) ~= TEXT_TY) return txt_to;
|
||||
pos = TEXT_TY_CharacterLength(txt_to);
|
||||
tosize = BlkValueLBCapacity(txt_to);
|
||||
tosize = PVFieldCapacity(txt_to);
|
||||
len = TEXT_TY_CharacterLength(txt_from);
|
||||
for (i=0:i<len:i++) {
|
||||
ch = BlkValueRead(txt_from, i);
|
||||
ch = PVField(txt_from, i);
|
||||
if ((ch == '\') && (i < len-1)) {
|
||||
ch = BlkValueRead(txt_from, ++i);
|
||||
ch = PVField(txt_from, ++i);
|
||||
if (ch == 'n') ch = 10;
|
||||
if (ch == 't') ch = 9;
|
||||
case = -1;
|
||||
if (ch == 'l') case = 0;
|
||||
if (ch == 'u') case = 1;
|
||||
if (case >= 0) ch = BlkValueRead(txt_from, ++i);
|
||||
if (case >= 0) ch = PVField(txt_from, ++i);
|
||||
if ((ch >= '0') && (ch <= '9')) {
|
||||
ch = ch - '0';
|
||||
if (ch < RE_Subexpressions-->10) {
|
||||
|
@ -1772,15 +1769,15 @@ which handles the special syntaxes used in search-and-replace.
|
|||
y = (RE_Subexpressions-->ch)-->RE_DATA2;
|
||||
if (x >= 0) {
|
||||
for (:x<y:x++) {
|
||||
ch = BlkValueRead(txt_ref, x);
|
||||
ch = PVField(txt_ref, x);
|
||||
if (pos+1 >= tosize) {
|
||||
if (BlkValueSetLBCapacity(txt_to, 2*tosize) == false) break;
|
||||
tosize = BlkValueLBCapacity(txt_to);
|
||||
if (SetPVFieldCapacity(txt_to, 2*tosize) == false) break;
|
||||
tosize = PVFieldCapacity(txt_to);
|
||||
}
|
||||
if (case >= 0)
|
||||
BlkValueWrite(txt_to, pos++, CharToCase(ch, case));
|
||||
WritePVField(txt_to, pos++, CharToCase(ch, case));
|
||||
else
|
||||
BlkValueWrite(txt_to, pos++, ch);
|
||||
WritePVField(txt_to, pos++, ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1789,11 +1786,11 @@ which handles the special syntaxes used in search-and-replace.
|
|||
|
||||
}
|
||||
if (pos+1 >= tosize) {
|
||||
if (BlkValueSetLBCapacity(txt_to, 2*tosize) == false) break;
|
||||
tosize = BlkValueLBCapacity(txt_to);
|
||||
if (SetPVFieldCapacity(txt_to, 2*tosize) == false) break;
|
||||
tosize = PVFieldCapacity(txt_to);
|
||||
}
|
||||
BlkValueWrite(txt_to, pos++, ch);
|
||||
WritePVField(txt_to, pos++, ch);
|
||||
}
|
||||
BlkValueWrite(txt_to, pos, 0);
|
||||
WritePVField(txt_to, pos, 0);
|
||||
return txt_to;
|
||||
];
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -28,10 +28,10 @@ Array latest_rule_result --> 3;
|
|||
|
||||
[ RecordRuleOutcome usage strong_kind val;
|
||||
if ((latest_rule_result-->0 == RS_SUCCEEDS or RS_FAILS) &&
|
||||
(KOVIsBlockValue(latest_rule_result-->1)))
|
||||
BlkValueFree(latest_rule_result-->2);
|
||||
if ((usage == RS_SUCCEEDS or RS_FAILS) && (KOVIsBlockValue(strong_kind)))
|
||||
val = BlkValueCopy(BlkValueCreate(strong_kind), val);
|
||||
(ConformsTo_POINTER_VALUE_TY(latest_rule_result-->1)))
|
||||
DestroyPV(latest_rule_result-->2);
|
||||
if ((usage == RS_SUCCEEDS or RS_FAILS) && (ConformsTo_POINTER_VALUE_TY(strong_kind)))
|
||||
val = CopyPV(CreatePV(strong_kind), val);
|
||||
latest_rule_result-->0 = usage;
|
||||
latest_rule_result-->1 = strong_kind;
|
||||
latest_rule_result-->2 = val;
|
||||
|
|
|
@ -185,7 +185,7 @@ also setting the relevant bit in the blanks bitmap, if there is one.
|
|||
|
||||
We need to be careful if the column holds a kind of value where values are
|
||||
pointers to blocks of allocated memory, because if so then overwriting such
|
||||
a value might lead to a memory leak. So in such cases we call |BlkValueFree|
|
||||
a value might lead to a memory leak. So in such cases we call |DestroyPV|
|
||||
to free the memory block. (Note that each memory block is pointed to by one
|
||||
and only one I7 value at any given time: we are using them as values, not
|
||||
pointers to values. So if this reference is deleted, it's by definition the
|
||||
|
@ -200,7 +200,7 @@ block allocated yet".)
|
|||
flags = (tab-->col)-->1;
|
||||
oldv = (tab-->col)-->(row+COL_HSIZE);
|
||||
if ((flags & TB_COLUMN_ALLOCATED) && (oldv ~= 0 or TABLE_NOVALUE))
|
||||
BlkValueFree(oldv);
|
||||
DestroyPV(oldv);
|
||||
(tab-->col)-->(row+COL_HSIZE) = TABLE_NOVALUE;
|
||||
if (flags & TB_COLUMN_NOBLANKBITS) return;
|
||||
row--;
|
||||
|
@ -231,7 +231,7 @@ memory block for the KOV in question, and set the entry to that.
|
|||
tc = ((tab-->col)-->1) & TB_COLUMN_NUMBER;
|
||||
kov = TC_KOV(tc);
|
||||
if (kov ~= UNKNOWN_TY) {
|
||||
(tab-->col)-->(row+COL_HSIZE) = BlkValueCreate(kov);
|
||||
(tab-->col)-->(row+COL_HSIZE) = CreatePV(kov);
|
||||
}
|
||||
}
|
||||
row--;
|
||||
|
@ -332,7 +332,7 @@ general parsing routine.
|
|||
v = lookup_col-->(i+COL_HSIZE);
|
||||
if ((v == TABLE_NOVALUE) &&
|
||||
(CheckTableEntryIsBlank(tab,col,i))) continue;
|
||||
if (BlkValueCompare(v, lookup_value) == 0)
|
||||
if (ComparePV(v, lookup_value) == 0)
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
|
@ -365,7 +365,7 @@ general parsing routine.
|
|||
if ((v == TABLE_NOVALUE) && (CheckTableEntryIsBlank(tab,col,i))) continue;
|
||||
switch (f) {
|
||||
1: if ((v)(entry/100, entry%100) ~= GPR_FAIL) return i;
|
||||
2: if (BlkValueCompare(v, entry) == 0) return i;
|
||||
2: if (ComparePV(v, entry) == 0) return i;
|
||||
default: if (v == entry) return i;
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ value in |C1|.
|
|||
|
||||
if ((v == TABLE_NOVALUE) && (CheckTableEntryIsBlank(tab,col2,i-COL_HSIZE))) continue;
|
||||
if (f == 1) {
|
||||
if (BlkValueCompare(v, lookup_value) ~= 0) continue;
|
||||
if (ComparePV(v, lookup_value) ~= 0) continue;
|
||||
} else if (f == 2) {
|
||||
if ((v)(lookup_value/100, lookup_value%100) == GPR_FAIL) continue;
|
||||
} else {
|
||||
|
@ -435,7 +435,7 @@ value in |C1|.
|
|||
if ((cola1-->i == TABLE_NOVALUE) &&
|
||||
(CheckTableEntryIsBlank(tab,col1,i-COL_HSIZE))) continue;
|
||||
if (f == 1) {
|
||||
if (BlkValueCompare(cola2-->i, lookup_value) ~= 0) continue;
|
||||
if (ComparePV(cola2-->i, lookup_value) ~= 0) continue;
|
||||
} else if (f == 2) {
|
||||
if ((cola2-->i)(lookup_value/100, lookup_value%100) == GPR_FAIL) continue;
|
||||
} else {
|
||||
|
@ -644,7 +644,7 @@ where other entries are not.
|
|||
if (bl2) return -1*dir;
|
||||
f = ((tab-->col)-->1);
|
||||
if (f & TB_COLUMN_ALLOCATED) {
|
||||
if (BlkValueCompare(val2, val1) < 0) return 1;
|
||||
if (ComparePV(val2, val1) < 0) return 1;
|
||||
return -1;
|
||||
} else if (f & TB_COLUMN_REAL) {
|
||||
if (REAL_NUMBER_TY_Compare(val1, val2) > 0) return 1;
|
||||
|
@ -748,9 +748,9 @@ will perform a loop of valid row numbers in order of column |C|.
|
|||
continue;
|
||||
if (blk) {
|
||||
dv = v;
|
||||
if (row == 0) z = 1; else z = BlkValueCompare(v, val);
|
||||
if (row == 0) z = 1; else z = ComparePV(v, val);
|
||||
f = (((z > 0) || ((z == 0) && (i > row))) &&
|
||||
((min_at == 0) || (BlkValueCompare(v, min_dv) < 0)));
|
||||
((min_at == 0) || (ComparePV(v, min_dv) < 0)));
|
||||
} else {
|
||||
dv = dir*v;
|
||||
if (signed_arithmetic)
|
||||
|
@ -769,9 +769,9 @@ will perform a loop of valid row numbers in order of column |C|.
|
|||
continue;
|
||||
if (blk) {
|
||||
dv = v;
|
||||
if (row == 0) z = -1; else z = BlkValueCompare(v, val);
|
||||
if (row == 0) z = -1; else z = ComparePV(v, val);
|
||||
f = (((z < 0) || ((z == 0) && (i < row))) &&
|
||||
((min_at == 0) || (BlkValueCompare(v, min_dv) > 0)));
|
||||
((min_at == 0) || (ComparePV(v, min_dv) > 0)));
|
||||
} else {
|
||||
dv = dir*v;
|
||||
if (signed_arithmetic)
|
||||
|
@ -863,7 +863,7 @@ is called.
|
|||
if ((v == TABLE_NOVALUE) && (CheckTableEntryIsBlank(tab,col,row)))
|
||||
print "-- ";
|
||||
else {
|
||||
if (BlkValueWriteToFile(v, kov) == false) print v;
|
||||
if (WritePVToFile(v, kov) == false) print v;
|
||||
print " ";
|
||||
}
|
||||
}
|
||||
|
@ -911,13 +911,13 @@ And this is how we unserialise again. It makes sense only on Glulx.
|
|||
if (((tab-->col)-->1) & TB_COLUMN_ALLOCATED)
|
||||
ForceTableEntryNonBlank(tab, col, row);
|
||||
!print "A";
|
||||
v = BlkValueReadFromFile(0, 0, -1, kov);
|
||||
v = PVFromFile(0, 0, -1, kov);
|
||||
if (v) {
|
||||
if (((tab-->col)-->1) & TB_COLUMN_ALLOCATED)
|
||||
v = BlkValueReadFromFile(TableLookUpEntry(tab, col, row),
|
||||
v = PVFromFile(TableLookUpEntry(tab, col, row),
|
||||
auxf, ch, kov);
|
||||
else
|
||||
v = BlkValueReadFromFile(0, auxf, ch, kov);
|
||||
v = PVFromFile(0, auxf, ch, kov);
|
||||
ch = 32;
|
||||
} else {
|
||||
dg = ch - '0';
|
||||
|
|
|
@ -115,7 +115,7 @@ A newly created text is a two-word short block with no long block, like this:
|
|||
|
||||
=
|
||||
[ TEXT_TY_Create short_block x;
|
||||
return BlkValueCreateSB2(short_block, PACKED_TEXT_STORAGE, EMPTY_TEXT_PACKED);
|
||||
return CreatePVShortBlockOfSize2(short_block, PACKED_TEXT_STORAGE, EMPTY_TEXT_PACKED);
|
||||
];
|
||||
|
||||
@h Copy Short Block.
|
||||
|
@ -124,7 +124,7 @@ any more.
|
|||
|
||||
=
|
||||
[ TEXT_TY_CopySB to_bv from_bv;
|
||||
BlkValueCopySB2(to_bv, from_bv);
|
||||
CopyPVShortBlockOfSize2(to_bv, from_bv);
|
||||
if (to_bv-->0 & BLK_BVBITMAP_CONSTANTMASK) to_bv-->0 = PACKED_TEXT_STORAGE;
|
||||
];
|
||||
|
||||
|
@ -183,7 +183,7 @@ cast here is that a snippet can be turned into a text.
|
|||
=
|
||||
[ TEXT_TY_Cast to_txt from_kind from_value;
|
||||
if (from_kind == TEXT_TY) {
|
||||
BlkValueCopy(to_txt, from_value);
|
||||
CopyPV(to_txt, from_value);
|
||||
} else if (from_kind == SNIPPET_TY) {
|
||||
TEXT_TY_Transmute(to_txt);
|
||||
TEXT_TY_CastPrimitive(to_txt, true, from_value);
|
||||
|
@ -191,7 +191,7 @@ cast here is that a snippet can be turned into a text.
|
|||
];
|
||||
|
||||
[ SNIPPET_TY_to_TEXT_TY to_txt snippet;
|
||||
return BlkValueCast(to_txt, SNIPPET_TY, snippet);
|
||||
return CastPV(to_txt, SNIPPET_TY, snippet);
|
||||
];
|
||||
|
||||
@h Data Conversion.
|
||||
|
@ -261,7 +261,7 @@ it's clearer to give two definitions, so:
|
|||
buffer->(len+2) = 0;
|
||||
|
||||
TEXT_TY_CastPrimitiveNesting--;
|
||||
BlkValueMassCopyFromArray(to_txt, buffer+2, 1, len+1);
|
||||
WritePVFieldsFromByteArray(to_txt, buffer+2, len+1);
|
||||
];
|
||||
|
||||
@h Glulx Version.
|
||||
|
@ -322,7 +322,7 @@ it's clearer to give two definitions, so:
|
|||
buffer-->(len) = 0;
|
||||
|
||||
TEXT_TY_CastPrimitiveNesting--;
|
||||
BlkValueMassCopyFromArray(to_txt, buffer, 4, len+1);
|
||||
WritePVFieldsFromWordArray(to_txt, buffer, len+1);
|
||||
if (memory_to_free) VM_FreeMemory(memory_to_free);
|
||||
];
|
||||
#endif;
|
||||
|
@ -368,11 +368,11 @@ and "17" can be equal as texts if X is 17.
|
|||
TEXT_TY_Untransmute(right_txt, cr, cpr);
|
||||
return pos;
|
||||
}
|
||||
capacity_left = BlkValueLBCapacity(left_txt);
|
||||
capacity_right = BlkValueLBCapacity(right_txt);
|
||||
capacity_left = PVFieldCapacity(left_txt);
|
||||
capacity_right = PVFieldCapacity(right_txt);
|
||||
for (pos=0:(pos<capacity_left) && (pos<capacity_right):pos++) {
|
||||
ch1 = BlkValueRead(left_txt, pos);
|
||||
ch2 = BlkValueRead(right_txt, pos);
|
||||
ch1 = PVField(left_txt, pos);
|
||||
ch2 = PVField(right_txt, pos);
|
||||
if (ch1 ~= ch2) return ch1-ch2;
|
||||
if (ch1 == 0) return 0;
|
||||
}
|
||||
|
@ -392,9 +392,9 @@ This calculates a hash value for the string, using Bernstein's algorithm.
|
|||
[ TEXT_TY_Hash txt rv len i p cp;
|
||||
cp = txt-->0; p = TEXT_TY_Temporarily_Transmute(txt);
|
||||
rv = 0;
|
||||
len = BlkValueLBCapacity(txt);
|
||||
len = PVFieldCapacity(txt);
|
||||
for (i=0: i<len: i++)
|
||||
rv = rv * 33 + BlkValueRead(txt, i);
|
||||
rv = rv * 33 + PVField(txt, i);
|
||||
TEXT_TY_Untransmute(txt, p, cp);
|
||||
return rv;
|
||||
];
|
||||
|
@ -405,9 +405,9 @@ This calculates a hash value for the string, using Bernstein's algorithm.
|
|||
[ TEXT_TY_Say txt ch i dsize;
|
||||
if (txt==0) rfalse;
|
||||
if (txt-->0 & BLK_BVBITMAP_LONGBLOCKMASK == 0) return PrintI6Text(txt-->1);
|
||||
dsize = BlkValueLBCapacity(txt);
|
||||
dsize = PVFieldCapacity(txt);
|
||||
for (i=0: i<dsize: i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (ch == 0) break;
|
||||
print (char) ch;
|
||||
}
|
||||
|
@ -420,15 +420,15 @@ It turns out to be useful to have a variation on this:
|
|||
|
||||
=
|
||||
[ TEXT_TY_Say_Capitalised txt mod rc;
|
||||
mod = BlkValueCreate(TEXT_TY);
|
||||
mod = CreatePV(TEXT_TY);
|
||||
TEXT_TY_SubstitutedForm(mod, txt);
|
||||
if (TEXT_TY_CharacterLength(mod) > 0) {
|
||||
BlkValueWrite(mod, 0, CharToCase(BlkValueRead(mod, 0), 1));
|
||||
WritePVField(mod, 0, CharToCase(PVField(mod, 0), 1));
|
||||
TEXT_TY_Say(mod);
|
||||
rc = true;
|
||||
say__p = 1;
|
||||
}
|
||||
BlkValueFree(mod);
|
||||
DestroyPV(mod);
|
||||
return rc;
|
||||
];
|
||||
|
||||
|
@ -444,10 +444,10 @@ a semicolon: thus |S65,66,67,0;| is the serialised form of the text "ABC".
|
|||
=
|
||||
[ TEXT_TY_WriteFile txt len pos ch p cp;
|
||||
cp = txt-->0; p = TEXT_TY_Temporarily_Transmute(txt);
|
||||
len = BlkValueLBCapacity(txt);
|
||||
len = PVFieldCapacity(txt);
|
||||
print "S";
|
||||
for (pos=0: pos<=len: pos++) {
|
||||
if (pos == len) ch = 0; else ch = BlkValueRead(txt, pos);
|
||||
if (pos == len) ch = 0; else ch = PVField(txt, pos);
|
||||
if (ch == 0) {
|
||||
print "0;"; break;
|
||||
} else {
|
||||
|
@ -465,15 +465,15 @@ them.
|
|||
=
|
||||
[ TEXT_TY_ReadFile txt auxf ch i v dg pos tsize p;
|
||||
TEXT_TY_Transmute(txt);
|
||||
tsize = BlkValueLBCapacity(txt);
|
||||
tsize = PVFieldCapacity(txt);
|
||||
while (ch ~= 32 or 9 or 10 or 13 or 0 or -1) {
|
||||
ch = FileIO_GetC(auxf);
|
||||
if (ch == ',' or ';') {
|
||||
if (pos+1 >= tsize) {
|
||||
if (BlkValueSetLBCapacity(txt, 2*pos) == false) break;
|
||||
tsize = BlkValueLBCapacity(txt);
|
||||
if (SetPVFieldCapacity(txt, 2*pos) == false) break;
|
||||
tsize = PVFieldCapacity(txt);
|
||||
}
|
||||
BlkValueWrite(txt, pos++, v);
|
||||
WritePVField(txt, pos++, v);
|
||||
v = 0;
|
||||
if (ch == ';') break;
|
||||
} else {
|
||||
|
@ -481,7 +481,7 @@ them.
|
|||
v = v*10 + dg;
|
||||
}
|
||||
}
|
||||
BlkValueWrite(txt, pos, 0);
|
||||
WritePVField(txt, pos, 0);
|
||||
return txt;
|
||||
];
|
||||
|
||||
|
@ -490,7 +490,7 @@ them.
|
|||
=
|
||||
[ TEXT_TY_SubstitutedForm to txt;
|
||||
if (txt) {
|
||||
BlkValueCopy(to, txt);
|
||||
CopyPV(to, txt);
|
||||
TEXT_TY_Transmute(to);
|
||||
}
|
||||
return to;
|
||||
|
@ -575,23 +575,23 @@ Constant ACCEPTEDPN_BRM = 6;
|
|||
];
|
||||
[ TEXT_TY_BlobAccessI txt blobtype ctxt wanted rtxt
|
||||
brm oldbrm ch i dsize blobcount gp cl j;
|
||||
dsize = BlkValueLBCapacity(txt);
|
||||
dsize = PVFieldCapacity(txt);
|
||||
if ((rtxt) && (ctxt == 0)) "*** rtxt without ctxt ***";
|
||||
brm = WS_BRM;
|
||||
for (i=0:i<dsize:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (ch == 0) break;
|
||||
oldbrm = brm;
|
||||
if (ch == 10 or 13 or 32 or 9) {
|
||||
if (oldbrm ~= WS_BRM) {
|
||||
gp = 0;
|
||||
for (j=i:j<dsize:j++) {
|
||||
ch = BlkValueRead(txt, j);
|
||||
ch = PVField(txt, j);
|
||||
if (ch == 0) { brm = WS_BRM; break; }
|
||||
if (ch == 10 or 13) { gp++; continue; }
|
||||
if (ch ~= 32 or 9) break;
|
||||
}
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (j == dsize) brm = WS_BRM;
|
||||
switch (blobtype) {
|
||||
PARA_BLOB: if (gp >= 2) brm = WS_BRM;
|
||||
|
@ -630,7 +630,7 @@ Constant ACCEPTEDPN_BRM = 6;
|
|||
if (blobtype == PWORD_BLOB) {
|
||||
if (gp == false) brm = ACCEPTED_BRM;
|
||||
else {
|
||||
if ((ch == BlkValueRead(txt, i-1)) &&
|
||||
if ((ch == PVField(txt, i-1)) &&
|
||||
(ch == '-' or '.')) blobcount--;
|
||||
blobcount++;
|
||||
}
|
||||
|
@ -646,7 +646,7 @@ Constant ACCEPTEDPN_BRM = 6;
|
|||
if (blobtype == PWORD_BLOB) {
|
||||
if (gp == false) brm = ACCEPTED_BRM;
|
||||
else {
|
||||
if ((ch == BlkValueRead(txt, i-1)) &&
|
||||
if ((ch == PVField(txt, i-1)) &&
|
||||
(ch == '-' or '.')) blobcount--;
|
||||
blobcount++;
|
||||
}
|
||||
|
@ -657,42 +657,42 @@ Constant ACCEPTEDPN_BRM = 6;
|
|||
if (oldbrm ~= brm) blobcount++;
|
||||
if ((ctxt) && (blobcount == wanted)) {
|
||||
if (rtxt) {
|
||||
if (cl+1 >= BlkValueLBCapacity(ctxt)) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
if (cl+1 >= PVFieldCapacity(ctxt)) {
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
}
|
||||
BlkValueWrite(ctxt, cl, 0);
|
||||
WritePVField(ctxt, cl, 0);
|
||||
TEXT_TY_Concatenate(ctxt, rtxt, CHR_BLOB);
|
||||
cl = TEXT_TY_CharacterLength(ctxt);
|
||||
if (brm == ACCEPTED_BRM) brm = ACCEPTEDN_BRM;
|
||||
if (brm == ACCEPTEDP_BRM) brm = ACCEPTEDPN_BRM;
|
||||
} else {
|
||||
if (cl+1 >= BlkValueLBCapacity(ctxt)) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
if (cl+1 >= PVFieldCapacity(ctxt)) {
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
} else {
|
||||
if (rtxt) {
|
||||
if (cl+1 >= BlkValueLBCapacity(ctxt)) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
if (cl+1 >= PVFieldCapacity(ctxt)) {
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((rtxt) && (brm ~= ACCEPTEDN_BRM or ACCEPTEDPN_BRM)) {
|
||||
if (cl+1 >= BlkValueLBCapacity(ctxt)) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
if (cl+1 >= PVFieldCapacity(ctxt)) {
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ctxt) {
|
||||
if (cl+1 >= BlkValueLBCapacity(ctxt)) {
|
||||
BlkValueSetLBCapacity(ctxt, 2*cl);
|
||||
if (cl+1 >= PVFieldCapacity(ctxt)) {
|
||||
SetPVFieldCapacity(ctxt, 2*cl);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, 0);
|
||||
WritePVField(ctxt, cl++, 0);
|
||||
}
|
||||
return blobcount;
|
||||
];
|
||||
|
@ -723,28 +723,28 @@ characters are handled directly to avoid incurring all that overhead.)
|
|||
wanted--;
|
||||
if ((wanted >= 0) && (wanted<ilen)) {
|
||||
if (rlen == 1) {
|
||||
BlkValueWrite(txt, wanted, BlkValueRead(rtxt, 0));
|
||||
WritePVField(txt, wanted, PVField(rtxt, 0));
|
||||
} else {
|
||||
ctxt = BlkValueCreate(TEXT_TY);
|
||||
ctxt = CreatePV(TEXT_TY);
|
||||
TEXT_TY_Transmute(ctxt);
|
||||
if (BlkValueSetLBCapacity(ctxt, ilen+rlen+1)) {
|
||||
if (SetPVFieldCapacity(ctxt, ilen+rlen+1)) {
|
||||
for (i=0:i<wanted:i++)
|
||||
BlkValueWrite(ctxt, i, BlkValueRead(txt, i));
|
||||
WritePVField(ctxt, i, PVField(txt, i));
|
||||
for (i=0:i<rlen:i++)
|
||||
BlkValueWrite(ctxt, wanted+i, BlkValueRead(rtxt, i));
|
||||
WritePVField(ctxt, wanted+i, PVField(rtxt, i));
|
||||
for (i=wanted+1:i<ilen:i++)
|
||||
BlkValueWrite(ctxt, rlen+i-1, BlkValueRead(txt, i));
|
||||
BlkValueWrite(ctxt, rlen+ilen, 0);
|
||||
BlkValueCopy(txt, ctxt);
|
||||
WritePVField(ctxt, rlen+i-1, PVField(txt, i));
|
||||
WritePVField(ctxt, rlen+ilen, 0);
|
||||
CopyPV(txt, ctxt);
|
||||
}
|
||||
BlkValueFree(ctxt);
|
||||
DestroyPV(ctxt);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ctxt = BlkValueCreate(TEXT_TY);
|
||||
ctxt = CreatePV(TEXT_TY);
|
||||
TEXT_TY_BlobAccess(txt, blobtype, ctxt, wanted, rtxt);
|
||||
BlkValueCopy(txt, ctxt);
|
||||
BlkValueFree(ctxt);
|
||||
CopyPV(txt, ctxt);
|
||||
DestroyPV(ctxt);
|
||||
}
|
||||
TEXT_TY_Untransmute(rtxt, p, cp);
|
||||
];
|
||||
|
@ -779,16 +779,16 @@ than something literal to find: see "RegExp.i6t" for what happens next.
|
|||
|
||||
ilen = TEXT_TY_CharacterLength(txt);
|
||||
flen = TEXT_TY_CharacterLength(ftxt);
|
||||
ctxt = BlkValueCreate(TEXT_TY);
|
||||
ctxt = CreatePV(TEXT_TY);
|
||||
TEXT_TY_Transmute(ctxt);
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
mpos = 0;
|
||||
|
||||
whitespace = true; punctuation = false;
|
||||
for (i=0:i<=ilen:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
.MoreMatching;
|
||||
chm = BlkValueRead(ftxt, mpos++);
|
||||
chm = PVField(ftxt, mpos++);
|
||||
if (mpos == 1) {
|
||||
switch (blobtype) {
|
||||
WORD_BLOB:
|
||||
|
@ -807,7 +807,7 @@ than something literal to find: see "RegExp.i6t" for what happens next.
|
|||
if (ch == chm) {
|
||||
if (mpos == flen) {
|
||||
if (i == ilen) chm = 0;
|
||||
else chm = BlkValueRead(txt, i+1);
|
||||
else chm = PVField(txt, i+1);
|
||||
if ((blobtype == CHR_BLOB) ||
|
||||
(chm == 0 or 10 or 13 or 32 or 9) ||
|
||||
(chm == '.' or ',' or '!' or '?'
|
||||
|
@ -815,9 +815,9 @@ than something literal to find: see "RegExp.i6t" for what happens next.
|
|||
or '(' or ')' or '[' or ']' or '{' or '}')) {
|
||||
mpos = 0;
|
||||
cl = cl - (flen-1);
|
||||
BlkValueWrite(ctxt, cl, 0);
|
||||
WritePVField(ctxt, cl, 0);
|
||||
TEXT_TY_Concatenate(ctxt, rtxt, CHR_BLOB);
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
cl = TEXT_TY_CharacterLength(ctxt);
|
||||
continue;
|
||||
}
|
||||
|
@ -826,13 +826,13 @@ than something literal to find: see "RegExp.i6t" for what happens next.
|
|||
mpos = 0;
|
||||
}
|
||||
if (cl+1 >= csize) {
|
||||
if (BlkValueSetLBCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = BlkValueLBCapacity(ctxt);
|
||||
if (SetPVFieldCapacity(ctxt, 2*cl) == false) break;
|
||||
csize = PVFieldCapacity(ctxt);
|
||||
}
|
||||
BlkValueWrite(ctxt, cl++, ch);
|
||||
WritePVField(ctxt, cl++, ch);
|
||||
}
|
||||
BlkValueCopy(txt, ctxt);
|
||||
BlkValueFree(ctxt);
|
||||
CopyPV(txt, ctxt);
|
||||
DestroyPV(ctxt);
|
||||
];
|
||||
|
||||
@h Character Length.
|
||||
|
@ -843,9 +843,9 @@ and we needn't go through any finite state machine palaver.
|
|||
[ TEXT_TY_CharacterLength txt ch i dsize p cp r;
|
||||
if (txt==0) return 0;
|
||||
cp = txt-->0; p = TEXT_TY_Temporarily_Transmute(txt);
|
||||
dsize = BlkValueLBCapacity(txt); r = dsize;
|
||||
dsize = PVFieldCapacity(txt); r = dsize;
|
||||
for (i=0:i<dsize:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (ch == 0) { r = i; break; }
|
||||
}
|
||||
TEXT_TY_Untransmute(txt, p, cp);
|
||||
|
@ -873,9 +873,9 @@ block-value, which counts from 0.
|
|||
cp = txt-->0; p = TEXT_TY_Temporarily_Transmute(txt);
|
||||
TEXT_TY_Transmute(ctxt);
|
||||
if ((i<=0) || (i>TEXT_TY_CharacterLength(txt))) ch = 0;
|
||||
else ch = BlkValueRead(txt, i-1);
|
||||
BlkValueWrite(ctxt, 0, ch);
|
||||
BlkValueWrite(ctxt, 1, 0);
|
||||
else ch = PVField(txt, i-1);
|
||||
WritePVField(ctxt, 0, ch);
|
||||
WritePVField(ctxt, 1, 0);
|
||||
TEXT_TY_Untransmute(txt, p, cp);
|
||||
return ctxt;
|
||||
];
|
||||
|
@ -901,7 +901,7 @@ long.
|
|||
len = TEXT_TY_CharacterLength(txt);
|
||||
r = true;
|
||||
for (i=0:i<len:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if ((ch) && (CharIsOfCase(ch, case) == false)) { r = false; break; }
|
||||
}
|
||||
TEXT_TY_Untransmute(txt, p, cp);
|
||||
|
@ -920,14 +920,14 @@ are as specified in the ZSCII and Unicode standards.
|
|||
cp = txt-->0; pk = TEXT_TY_Temporarily_Transmute(txt);
|
||||
TEXT_TY_Transmute(ctxt);
|
||||
len = TEXT_TY_CharacterLength(txt);
|
||||
if (BlkValueSetLBCapacity(ctxt, len+1)) {
|
||||
if (SetPVFieldCapacity(ctxt, len+1)) {
|
||||
bnd = 1;
|
||||
for (i=0:i<len:i++) {
|
||||
ch = BlkValueRead(txt, i);
|
||||
ch = PVField(txt, i);
|
||||
if (case < 2) {
|
||||
BlkValueWrite(ctxt, i, CharToCase(ch, case));
|
||||
WritePVField(ctxt, i, CharToCase(ch, case));
|
||||
} else {
|
||||
BlkValueWrite(ctxt, i, CharToCase(ch, bnd));
|
||||
WritePVField(ctxt, i, CharToCase(ch, bnd));
|
||||
if (case == 2) {
|
||||
bnd = 0;
|
||||
if (ch == 0 or 10 or 13 or 32 or 9
|
||||
|
@ -945,7 +945,7 @@ are as specified in the ZSCII and Unicode standards.
|
|||
}
|
||||
}
|
||||
}
|
||||
BlkValueWrite(ctxt, len, 0);
|
||||
WritePVField(ctxt, len, 0);
|
||||
}
|
||||
TEXT_TY_Untransmute(txt, pk, cp);
|
||||
return ctxt;
|
||||
|
@ -979,12 +979,12 @@ expression search-and-replace is going on: see "RegExp.i6t".
|
|||
CHR_BLOB, 0:
|
||||
pos = TEXT_TY_CharacterLength(to_txt);
|
||||
len = TEXT_TY_CharacterLength(from_txt);
|
||||
if (BlkValueSetLBCapacity(to_txt, pos+len+1) == false) return to_txt;
|
||||
if (SetPVFieldCapacity(to_txt, pos+len+1) == false) return to_txt;
|
||||
for (i=0:i<len:i++) {
|
||||
ch = BlkValueRead(from_txt, i);
|
||||
BlkValueWrite(to_txt, i+pos, ch);
|
||||
ch = PVField(from_txt, i);
|
||||
WritePVField(to_txt, i+pos, ch);
|
||||
}
|
||||
BlkValueWrite(to_txt, len+pos, 0);
|
||||
WritePVField(to_txt, len+pos, 0);
|
||||
return to_txt;
|
||||
REGEXP_BLOB:
|
||||
return TEXT_TY_RE_Concatenate(to_txt, from_txt, blobtype, ref_txt);
|
||||
|
|
|
@ -329,7 +329,7 @@ This is not quite so efficient as Memcpy, but not terrible.
|
|||
];
|
||||
|
||||
[ VerbIsMeaningful vb;
|
||||
if ((vb) && (BlkValueCompare(vb(CV_MEANING), MEANINGLESS_RR) ~= 0)) rtrue;
|
||||
if ((vb) && (ComparePV(vb(CV_MEANING), MEANINGLESS_RR) ~= 0)) rtrue;
|
||||
rfalse;
|
||||
];
|
||||
|
||||
|
|
|
@ -4213,9 +4213,9 @@ recognises an existing value: it doesn't parse a new one.
|
|||
[ TEXT_TY_ROGPRI txt
|
||||
pos len wa wl wpos wach bdm ch own;
|
||||
bdm = true; own = wn;
|
||||
len = BlkValueLBCapacity(txt);
|
||||
len = PVFieldCapacity(txt);
|
||||
for (pos=0: pos<=len: pos++) {
|
||||
if (pos == len) ch = 0; else ch = BlkValueRead(txt, pos);
|
||||
if (pos == len) ch = 0; else ch = PVField(txt, pos);
|
||||
if (ch == 32 or 9 or 10 or 0) {
|
||||
if (bdm) continue;
|
||||
bdm = true;
|
||||
|
@ -4279,11 +4279,11 @@ the heap.
|
|||
if (len > INPUT_BUFFER_LEN-2) len = INPUT_BUFFER_LEN-2;
|
||||
#Iftrue CHARSIZE == 1;
|
||||
buffer->1 = len; at = 2;
|
||||
for (i=0:i<len:i++) buffer->(i+at) = CharToCase(BlkValueRead(from_txt, i), 0);
|
||||
for (i=0:i<len:i++) buffer->(i+at) = CharToCase(PVField(from_txt, i), 0);
|
||||
for (:at+i<INPUT_BUFFER_LEN:i++) buffer->(at+i) = ' ';
|
||||
#ifnot;
|
||||
buffer-->0 = len; at = 1;
|
||||
for (i=0:i<len:i++) buffer-->(i+at) = CharToCase(BlkValueRead(from_txt, i), 0);
|
||||
for (i=0:i<len:i++) buffer-->(i+at) = CharToCase(PVField(from_txt, i), 0);
|
||||
for (:at+i<INPUT_BUFFER_LEN:i++) buffer-->(at+i) = ' ';
|
||||
#endif;
|
||||
VM_Tokenise(buffer, parse);
|
||||
|
@ -4300,7 +4300,7 @@ the list. The following converts it to a list structure.
|
|||
|
||||
=
|
||||
[ LIST_OF_TY_Mol list len i;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
len = multiple_object-->0;
|
||||
LIST_OF_TY_SetLength(list, len);
|
||||
for (i=1: i<=len: i++)
|
||||
|
@ -4309,11 +4309,11 @@ the list. The following converts it to a list structure.
|
|||
];
|
||||
|
||||
[ LIST_OF_TY_Set_Mol list len i;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
len = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
len = PVField(list, LIST_LENGTH_F);
|
||||
if (len > 63) len = 63;
|
||||
multiple_object-->0 = len;
|
||||
for (i=1: i<=len: i++)
|
||||
multiple_object-->i = BlkValueRead(list, LIST_ITEM_BASE+i-1);
|
||||
multiple_object-->i = PVField(list, LIST_ITEM_BASE+i-1);
|
||||
];
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ Constant REQUIRING_DBMETADATA = 5;
|
|||
|
||||
[ DirectorBeatRequiredList list db len i beatdata speaker;
|
||||
if ((db <= 0) || (db > NO_DIALOGUE_BEATS)) return list;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
len = 0;
|
||||
beatdata = TableOfDialogueBeats-->db;
|
||||
i = REQUIRING_DBMETADATA;
|
||||
|
|
|
@ -85,7 +85,7 @@ Constant OR_DSEL = 19; ! -- or
|
|||
[ DirectorChoiceTextContent dc text chdata;
|
||||
if ((dc <= 0) || (dc > NO_DIALOGUE_CHOICES)) return text;
|
||||
chdata = TableOfDialogueChoices-->dc;
|
||||
BlkValueCopy(text, chdata-->CONTENT_DCMETADATA);
|
||||
CopyPV(text, chdata-->CONTENT_DCMETADATA);
|
||||
return text;
|
||||
];
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ virtue of Inform lists, that is, their flexible size.
|
|||
|
||||
=
|
||||
[ DirectorLiveSubjectList list len i;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
len = 0;
|
||||
while (DialogueTopicPool-->len) len++;
|
||||
LIST_OF_TY_SetLength(list, len);
|
||||
|
@ -70,11 +70,11 @@ virtue of Inform lists, that is, their flexible size.
|
|||
];
|
||||
|
||||
[ DirectorAlterLiveSubjectList list len i;
|
||||
if ((list==0) || (BlkValueWeakKind(list) ~= LIST_OF_TY)) return 0;
|
||||
len = BlkValueRead(list, LIST_LENGTH_F);
|
||||
if (WeakKindOfPV(list) ~= LIST_OF_TY) return 0;
|
||||
len = PVField(list, LIST_LENGTH_F);
|
||||
if (len > DIALOGUE_MAX_LIVE_SUBJECTS) len = DIALOGUE_MAX_LIVE_SUBJECTS;
|
||||
for (i=0: i<len: i++)
|
||||
DialogueTopicPool-->i = BlkValueRead(list, LIST_ITEM_BASE+i);
|
||||
DialogueTopicPool-->i = PVField(list, LIST_ITEM_BASE+i);
|
||||
DialogueTopicPool-->len = 0;
|
||||
DialogueTopicPool-->DIALOGUE_MAX_LIVE_SUBJECTS = 0;
|
||||
];
|
||||
|
|
|
@ -83,7 +83,7 @@ Constant PLAYER_CONVERSATIONALIST = 1;
|
|||
[ DirectorLineContent dl text linedata;
|
||||
if ((dl == 0) || (dl > NO_DIALOGUE_LINES)) return text;
|
||||
linedata = TableOfDialogueLines-->dl;
|
||||
BlkValueCopy(text, linedata-->SPEECH_DLMETADATA);
|
||||
CopyPV(text, linedata-->SPEECH_DLMETADATA);
|
||||
return text;
|
||||
];
|
||||
|
||||
|
@ -133,8 +133,8 @@ Global director_speaker_list;
|
|||
if (metaclass(val) == Object) return val;
|
||||
if (metaclass(val) == Routine) {
|
||||
if (director_speaker_list == 0) {
|
||||
director_speaker_list = BlkValueCreate(LIST_OF_TY);
|
||||
BlkValueWrite(director_speaker_list, LIST_ITEM_KOV_F, OBJECT_TY);
|
||||
director_speaker_list = CreatePV(LIST_OF_TY);
|
||||
WritePVField(director_speaker_list, LIST_ITEM_KOV_F, OBJECT_TY);
|
||||
} else {
|
||||
LIST_OF_TY_SetLength(director_speaker_list, 0);
|
||||
}
|
||||
|
|
|
@ -232,8 +232,8 @@ still produce an empty list in a typesafe way.
|
|||
[ DirectorCurrentChoiceList i L;
|
||||
if (director_sp == 0) {
|
||||
if (DirectorStackChoices-->0 == 0) {
|
||||
DirectorStackChoices-->0 = BlkValueCreate(LIST_OF_TY);
|
||||
BlkValueWrite(DirectorStackChoices-->0, LIST_ITEM_KOV_F, DIALOGUE_CHOICE_TY);
|
||||
DirectorStackChoices-->0 = CreatePV(LIST_OF_TY);
|
||||
WritePVField(DirectorStackChoices-->0, LIST_ITEM_KOV_F, DIALOGUE_CHOICE_TY);
|
||||
}
|
||||
return DirectorStackChoices-->0;
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ dialogue tree, or any well-formed subtree of it.
|
|||
DirectorStackLastSpeaker-->director_sp = nothing;
|
||||
DirectorStackLastInterlocutor-->director_sp = nothing;
|
||||
if (DirectorStackChoices-->director_sp == 0) {
|
||||
DirectorStackChoices-->director_sp = BlkValueCreate(LIST_OF_TY);
|
||||
BlkValueWrite(DirectorStackChoices-->director_sp, LIST_ITEM_KOV_F, DIALOGUE_CHOICE_TY);
|
||||
DirectorStackChoices-->director_sp = CreatePV(LIST_OF_TY);
|
||||
WritePVField(DirectorStackChoices-->director_sp, LIST_ITEM_KOV_F, DIALOGUE_CHOICE_TY);
|
||||
} else {
|
||||
LIST_OF_TY_SetLength(DirectorStackChoices-->director_sp, 0);
|
||||
}
|
||||
|
|
|
@ -150,17 +150,17 @@ This is method (ii) in the summary above.
|
|||
else { inp2 = 1; parsed_number = s; }
|
||||
if (((ActionData-->(by+AD_NOUN_KOV) == UNDERSTANDING_TY) ||
|
||||
(ActionData-->(by+AD_SECOND_KOV) == UNDERSTANDING_TY)) && (tbits)) {
|
||||
saved_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCast(saved_command, SNIPPET_TY, players_command);
|
||||
text_of_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCopy(text_of_command, parsed_number);
|
||||
saved_command = CreatePV(TEXT_TY);
|
||||
SNIPPET_TY_to_TEXT_TY(saved_command, players_command);
|
||||
text_of_command = CreatePV(TEXT_TY);
|
||||
CopyPV(text_of_command, parsed_number);
|
||||
SetPlayersCommand(text_of_command);
|
||||
if (tbits == 16) {
|
||||
n = players_command; inp1 = 1; parsed_number = players_command;
|
||||
} else {
|
||||
s = players_command; inp2 = 1; parsed_number = players_command;
|
||||
}
|
||||
BlkValueFree(text_of_command);
|
||||
DestroyPV(text_of_command);
|
||||
@push consult_from; @push consult_words;
|
||||
consult_from = 1; consult_words = parsed_number - 100;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ This is method (ii) in the summary above.
|
|||
if (saved_command) {
|
||||
@pull consult_words; @pull consult_from;
|
||||
SetPlayersCommand(saved_command);
|
||||
BlkValueFree(saved_command);
|
||||
DestroyPV(saved_command);
|
||||
}
|
||||
|
||||
meta = smeta; @pull parsed_number;
|
||||
|
|
|
@ -518,7 +518,7 @@ variables detailing the current list-writing process, and begin.
|
|||
say__p = 1;
|
||||
} else {
|
||||
objectloop (ol provides list_together)
|
||||
BlkValueCopy(ol.list_together, EMPTY_TEXT_VALUE);
|
||||
CopyPV(ol.list_together, EMPTY_TEXT_VALUE);
|
||||
CarryOutActivity(LISTING_CONTENTS_ACT, parent(first));
|
||||
}
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ in the above sense.
|
|||
if (TEXT_TY_IsSubstituted(lt2) == false) {
|
||||
return -1;
|
||||
}
|
||||
return BlkValueCompare(lt1, lt2);
|
||||
return ComparePV(lt1, lt2);
|
||||
];
|
||||
|
||||
@h Write List Recursively.
|
||||
|
|
|
@ -28,7 +28,7 @@ Constant STORA_NOUN_F = 1;
|
|||
Constant STORA_SECOND_F = 2;
|
||||
Constant STORA_ACTOR_F = 3;
|
||||
Constant STORA_REQUEST_F = 4;
|
||||
Constant STORA_COMMAND_TEXT_F = 5;
|
||||
Constant STORA_COMMAND_TEXT_F = 5; ! text of command if necessary, 0 if not
|
||||
|
||||
@h KOV Support.
|
||||
See the "BlockValues.i6t" segment for the specification of the following
|
||||
|
@ -41,7 +41,7 @@ routines.
|
|||
DESTROY_KOVS: STORED_ACTION_TY_Destroy(arg1);
|
||||
MAKEMUTABLE_KOVS: return 1;
|
||||
COPYQUICK_KOVS: rtrue;
|
||||
COPYSB_KOVS: BlkValueCopySB1(arg1, arg2);
|
||||
COPYSB_KOVS: CopyPVShortBlockOfSize1(arg1, arg2);
|
||||
KINDDATA_KOVS: return 0;
|
||||
EXTENT_KOVS: return 6;
|
||||
COPY_KOVS: STORED_ACTION_TY_Copy(arg1, arg2);
|
||||
|
@ -60,15 +60,15 @@ Note that it initialises to the default value for this KOV, an action
|
|||
in which the player waits.
|
||||
|
||||
=
|
||||
[ STORED_ACTION_TY_Create sb stora;
|
||||
stora = FlexAllocate(6*WORDSIZE, STORED_ACTION_TY, BLK_FLAG_WORD);
|
||||
BlkValueWrite(stora, STORA_ACTION_F, ##Wait, true); ! action
|
||||
BlkValueWrite(stora, STORA_NOUN_F, 0, true); ! noun
|
||||
BlkValueWrite(stora, STORA_SECOND_F, 0, true); ! second
|
||||
BlkValueWrite(stora, STORA_ACTOR_F, player, true); ! actor
|
||||
BlkValueWrite(stora, STORA_REQUEST_F, false, true); ! whether a request
|
||||
BlkValueWrite(stora, STORA_COMMAND_TEXT_F, 0, true); ! text of command if necessary, 0 if not
|
||||
return BlkValueCreateSB1(sb, stora);
|
||||
[ STORED_ACTION_TY_Create short_block long_block;
|
||||
long_block = CreatePVLongBlock(6, STORED_ACTION_TY);
|
||||
InitialisePVLongBlockField(long_block, STORA_ACTION_F, ##Wait);
|
||||
InitialisePVLongBlockField(long_block, STORA_NOUN_F, 0);
|
||||
InitialisePVLongBlockField(long_block, STORA_SECOND_F, 0);
|
||||
InitialisePVLongBlockField(long_block, STORA_ACTOR_F, player);
|
||||
InitialisePVLongBlockField(long_block, STORA_REQUEST_F, false);
|
||||
InitialisePVLongBlockField(long_block, STORA_COMMAND_TEXT_F, 0);
|
||||
return CreatePVShortBlockOfSize1(short_block, long_block);
|
||||
];
|
||||
|
||||
@h Setting Up.
|
||||
|
@ -78,13 +78,13 @@ all one at a time, so the following is provided as a shorthand form.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_New a n s ac req stora;
|
||||
if (stora == 0) stora = BlkValueCreate(STORED_ACTION_TY);
|
||||
BlkValueWrite(stora, STORA_ACTION_F, a);
|
||||
BlkValueWrite(stora, STORA_NOUN_F, n);
|
||||
BlkValueWrite(stora, STORA_SECOND_F, s);
|
||||
BlkValueWrite(stora, STORA_ACTOR_F, ac);
|
||||
BlkValueWrite(stora, STORA_REQUEST_F, req);
|
||||
BlkValueWrite(stora, STORA_COMMAND_TEXT_F, 0);
|
||||
if (stora == 0) stora = CreatePV(STORED_ACTION_TY);
|
||||
WritePVField(stora, STORA_ACTION_F, a);
|
||||
WritePVField(stora, STORA_NOUN_F, n);
|
||||
WritePVField(stora, STORA_SECOND_F, s);
|
||||
WritePVField(stora, STORA_ACTOR_F, ac);
|
||||
WritePVField(stora, STORA_REQUEST_F, req);
|
||||
WritePVField(stora, STORA_COMMAND_TEXT_F, 0);
|
||||
return stora;
|
||||
];
|
||||
|
||||
|
@ -94,8 +94,8 @@ requires destruction.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Destroy stora toc;
|
||||
toc = BlkValueRead(stora, STORA_COMMAND_TEXT_F);
|
||||
if (toc) BlkValueFree(toc);
|
||||
toc = PVField(stora, STORA_COMMAND_TEXT_F);
|
||||
if (toc) DestroyPV(toc);
|
||||
];
|
||||
|
||||
@h Copying.
|
||||
|
@ -105,11 +105,11 @@ copy of the text.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Copy storato storafrom tocfrom tocto;
|
||||
tocfrom = BlkValueRead(storafrom, STORA_COMMAND_TEXT_F);
|
||||
tocfrom = PVField(storafrom, STORA_COMMAND_TEXT_F);
|
||||
if (tocfrom == 0) return;
|
||||
tocto = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCopy(tocto, tocfrom);
|
||||
BlkValueWrite(storato, STORA_COMMAND_TEXT_F, tocto);
|
||||
tocto = CreatePV(TEXT_TY);
|
||||
CopyPV(tocto, tocfrom);
|
||||
WritePVField(storato, STORA_COMMAND_TEXT_F, tocto);
|
||||
];
|
||||
|
||||
@h Comparison.
|
||||
|
@ -119,18 +119,18 @@ are or are not different.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Compare storaleft storaright delta itleft itright;
|
||||
delta = BlkValueRead(storaleft, STORA_ACTION_F) - BlkValueRead(storaright, STORA_ACTION_F);
|
||||
delta = PVField(storaleft, STORA_ACTION_F) - PVField(storaright, STORA_ACTION_F);
|
||||
if (delta) return delta;
|
||||
delta = BlkValueRead(storaleft, STORA_NOUN_F) - BlkValueRead(storaright, STORA_NOUN_F);
|
||||
delta = PVField(storaleft, STORA_NOUN_F) - PVField(storaright, STORA_NOUN_F);
|
||||
if (delta) return delta;
|
||||
delta = BlkValueRead(storaleft, STORA_SECOND_F) - BlkValueRead(storaright, STORA_SECOND_F);
|
||||
delta = PVField(storaleft, STORA_SECOND_F) - PVField(storaright, STORA_SECOND_F);
|
||||
if (delta) return delta;
|
||||
delta = BlkValueRead(storaleft, STORA_ACTOR_F) - BlkValueRead(storaright, STORA_ACTOR_F);
|
||||
delta = PVField(storaleft, STORA_ACTOR_F) - PVField(storaright, STORA_ACTOR_F);
|
||||
if (delta) return delta;
|
||||
delta = BlkValueRead(storaleft, STORA_REQUEST_F) - BlkValueRead(storaright, STORA_REQUEST_F);
|
||||
delta = PVField(storaleft, STORA_REQUEST_F) - PVField(storaright, STORA_REQUEST_F);
|
||||
if (delta) return delta;
|
||||
itleft = BlkValueRead(storaleft, STORA_COMMAND_TEXT_F);
|
||||
itright = BlkValueRead(storaright, STORA_COMMAND_TEXT_F);
|
||||
itleft = PVField(storaleft, STORA_COMMAND_TEXT_F);
|
||||
itright = PVField(storaright, STORA_COMMAND_TEXT_F);
|
||||
if ((itleft ~= 0) && (itright ~= 0))
|
||||
return TEXT_TY_Support(COMPARE_KOVS, itleft, itright);
|
||||
return itleft - itright;
|
||||
|
@ -145,12 +145,12 @@ are or are not different.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Hash stora rv it;
|
||||
rv = BlkValueRead(stora, STORA_ACTION_F);
|
||||
rv = rv * 33 + BlkValueRead(stora, STORA_NOUN_F);
|
||||
rv = rv * 33 + BlkValueRead(stora, STORA_SECOND_F);
|
||||
rv = rv * 33 + BlkValueRead(stora, STORA_ACTOR_F);
|
||||
rv = rv * 33 + BlkValueRead(stora, STORA_REQUEST_F);
|
||||
it = BlkValueRead(stora, STORA_COMMAND_TEXT_F);
|
||||
rv = PVField(stora, STORA_ACTION_F);
|
||||
rv = rv * 33 + PVField(stora, STORA_NOUN_F);
|
||||
rv = rv * 33 + PVField(stora, STORA_SECOND_F);
|
||||
rv = rv * 33 + PVField(stora, STORA_ACTOR_F);
|
||||
rv = rv * 33 + PVField(stora, STORA_REQUEST_F);
|
||||
it = PVField(stora, STORA_COMMAND_TEXT_F);
|
||||
if (it ~= 0)
|
||||
rv = rv * 33 + TEXT_TY_Support(HASH_KOVS, it);
|
||||
return rv;
|
||||
|
@ -167,54 +167,55 @@ command, and we do that by creating a text for the duration.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Say stora text_of_command saved_command saved_pn saved_action K1 K2 at cf cw;
|
||||
if ((stora==0) || (BlkValueWeakKind(stora) ~= STORED_ACTION_TY)) return;
|
||||
text_of_command = BlkValueRead(stora, STORA_COMMAND_TEXT_F);
|
||||
if (WeakKindOfPV(stora) ~= STORED_ACTION_TY) return;
|
||||
text_of_command = PVField(stora, STORA_COMMAND_TEXT_F);
|
||||
if (text_of_command) {
|
||||
saved_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCast(saved_command, SNIPPET_TY, players_command);
|
||||
saved_command = CreatePV(TEXT_TY);
|
||||
SNIPPET_TY_to_TEXT_TY(saved_command, players_command);
|
||||
SetPlayersCommand(text_of_command);
|
||||
}
|
||||
saved_pn = parsed_number; saved_action = action;
|
||||
action = BlkValueRead(stora, STORA_ACTION_F);
|
||||
action = PVField(stora, STORA_ACTION_F);
|
||||
cf = consult_from; cw = consult_words;
|
||||
at = FindAction(-1);
|
||||
K1 = ActionData-->(at+AD_NOUN_KOV);
|
||||
K2 = ActionData-->(at+AD_SECOND_KOV);
|
||||
if (K1 ~= OBJECT_TY) {
|
||||
parsed_number = BlkValueRead(stora, STORA_NOUN_F);
|
||||
parsed_number = PVField(stora, STORA_NOUN_F);
|
||||
if ((K1 == UNDERSTANDING_TY) && (text_of_command == 0)) {
|
||||
if (saved_command == 0) saved_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCast(saved_command, SNIPPET_TY, players_command);
|
||||
text_of_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCopy(text_of_command, parsed_number);
|
||||
if (saved_command == 0) saved_command = CreatePV(TEXT_TY);
|
||||
SNIPPET_TY_to_TEXT_TY(saved_command, players_command);
|
||||
text_of_command = CreatePV(TEXT_TY);
|
||||
CopyPV(text_of_command, parsed_number);
|
||||
SetPlayersCommand(text_of_command);
|
||||
parsed_number = players_command;
|
||||
consult_from = parsed_number/100; consult_words = parsed_number%100;
|
||||
}
|
||||
}
|
||||
if (K2 ~= OBJECT_TY) {
|
||||
parsed_number = BlkValueRead(stora, STORA_SECOND_F);
|
||||
parsed_number = PVField(stora, STORA_SECOND_F);
|
||||
if ((K2 == UNDERSTANDING_TY) && (text_of_command == 0)) {
|
||||
if (saved_command == 0) saved_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCast(saved_command, SNIPPET_TY, players_command);
|
||||
text_of_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCopy(text_of_command, parsed_number);
|
||||
if (saved_command == 0) saved_command = CreatePV(TEXT_TY);
|
||||
SNIPPET_TY_to_TEXT_TY(saved_command, players_command);
|
||||
text_of_command = CreatePV(TEXT_TY);
|
||||
CopyPV(text_of_command, parsed_number);
|
||||
SetPlayersCommand(text_of_command);
|
||||
parsed_number = players_command;
|
||||
consult_from = parsed_number/100; consult_words = parsed_number%100;
|
||||
}
|
||||
}
|
||||
DB_Action(
|
||||
BlkValueRead(stora, STORA_ACTOR_F),
|
||||
BlkValueRead(stora, STORA_REQUEST_F),
|
||||
BlkValueRead(stora, STORA_ACTION_F),
|
||||
BlkValueRead(stora, STORA_NOUN_F),
|
||||
BlkValueRead(stora, STORA_SECOND_F), true);
|
||||
PVField(stora, STORA_ACTOR_F),
|
||||
PVField(stora, STORA_REQUEST_F),
|
||||
PVField(stora, STORA_ACTION_F),
|
||||
PVField(stora, STORA_NOUN_F),
|
||||
PVField(stora, STORA_SECOND_F),
|
||||
true);
|
||||
parsed_number = saved_pn; action = saved_action;
|
||||
consult_from = cf; consult_words = cw;
|
||||
if (text_of_command) {
|
||||
SetPlayersCommand(saved_command);
|
||||
BlkValueFree(saved_command);
|
||||
DestroyPV(saved_command);
|
||||
}
|
||||
];
|
||||
|
||||
|
@ -228,14 +229,14 @@ or second noun.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Involves stora item at;
|
||||
at = FindAction(BlkValueRead(stora, STORA_ACTION_F));
|
||||
at = FindAction(PVField(stora, STORA_ACTION_F));
|
||||
if (at) {
|
||||
if ((ActionData-->(at+AD_NOUN_KOV) == OBJECT_TY) &&
|
||||
(BlkValueRead(stora, STORA_NOUN_F) == item)) rtrue;
|
||||
(PVField(stora, STORA_NOUN_F) == item)) rtrue;
|
||||
if ((ActionData-->(at+AD_SECOND_KOV) == OBJECT_TY) &&
|
||||
(BlkValueRead(stora, STORA_SECOND_F) == item)) rtrue;
|
||||
(PVField(stora, STORA_SECOND_F) == item)) rtrue;
|
||||
}
|
||||
if (BlkValueRead(stora, STORA_ACTOR_F) == item) rtrue;
|
||||
if (PVField(stora, STORA_ACTOR_F) == item) rtrue;
|
||||
rfalse;
|
||||
];
|
||||
|
||||
|
@ -250,11 +251,11 @@ noun for such an action.
|
|||
[ STORED_ACTION_TY_Part stora ind at ado;
|
||||
if (ind == STORA_NOUN_F or STORA_SECOND_F) {
|
||||
if (ind == STORA_NOUN_F) ado = AD_NOUN_KOV; else ado = AD_SECOND_KOV;
|
||||
at = FindAction(BlkValueRead(stora, STORA_ACTION_F));
|
||||
if ((at) && (ActionData-->(at+ado) == OBJECT_TY)) return BlkValueRead(stora, ind);
|
||||
at = FindAction(PVField(stora, STORA_ACTION_F));
|
||||
if ((at) && (ActionData-->(at+ado) == OBJECT_TY)) return PVField(stora, ind);
|
||||
return nothing;
|
||||
}
|
||||
return BlkValueRead(stora, ind);
|
||||
return PVField(stora, ind);
|
||||
];
|
||||
|
||||
@h Pattern Matching.
|
||||
|
@ -281,22 +282,22 @@ Array SAT_Tmp-->7;
|
|||
SAT_Tmp-->4 = actor;
|
||||
SAT_Tmp-->5 = act_requester;
|
||||
SAT_Tmp-->6 = parsed_number;
|
||||
action = BlkValueRead(stora, STORA_ACTION_F);
|
||||
action = PVField(stora, STORA_ACTION_F);
|
||||
at = FindAction(-1);
|
||||
if (ActionData-->(at+AD_NOUN_KOV) == OBJECT_TY)
|
||||
noun = BlkValueRead(stora, STORA_NOUN_F);
|
||||
noun = PVField(stora, STORA_NOUN_F);
|
||||
else {
|
||||
parsed_number = BlkValueRead(stora, STORA_NOUN_F);
|
||||
parsed_number = PVField(stora, STORA_NOUN_F);
|
||||
noun = nothing;
|
||||
}
|
||||
if (ActionData-->(at+AD_SECOND_KOV) == OBJECT_TY)
|
||||
second = BlkValueRead(stora, STORA_SECOND_F);
|
||||
second = PVField(stora, STORA_SECOND_F);
|
||||
else {
|
||||
parsed_number = BlkValueRead(stora, STORA_SECOND_F);
|
||||
parsed_number = PVField(stora, STORA_SECOND_F);
|
||||
second = nothing;
|
||||
}
|
||||
actor = BlkValueRead(stora, STORA_ACTOR_F);
|
||||
if (BlkValueRead(stora, STORA_REQUEST_F)) act_requester = player; else act_requester = nothing;
|
||||
actor = PVField(stora, STORA_ACTOR_F);
|
||||
if (PVField(stora, STORA_REQUEST_F)) act_requester = player; else act_requester = nothing;
|
||||
];
|
||||
|
||||
[ STORED_ACTION_TY_Unadopt;
|
||||
|
@ -323,31 +324,31 @@ command into a text block-value in entry 5.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Current stora at text_of_command;
|
||||
if ((stora==0) || (BlkValueWeakKind(stora) ~= STORED_ACTION_TY)) return 0;
|
||||
BlkValueWrite(stora, STORA_ACTION_F, action);
|
||||
if (WeakKindOfPV(stora) ~= STORED_ACTION_TY) return 0;
|
||||
WritePVField(stora, STORA_ACTION_F, action);
|
||||
at = FindAction(-1);
|
||||
|
||||
if (ActionData-->(at+AD_NOUN_KOV) == OBJECT_TY)
|
||||
BlkValueWrite(stora, STORA_NOUN_F, noun);
|
||||
WritePVField(stora, STORA_NOUN_F, noun);
|
||||
else
|
||||
BlkValueWrite(stora, STORA_NOUN_F, parsed_number);
|
||||
WritePVField(stora, STORA_NOUN_F, parsed_number);
|
||||
if (ActionData-->(at+AD_SECOND_KOV) == OBJECT_TY)
|
||||
BlkValueWrite(stora, STORA_SECOND_F, second);
|
||||
WritePVField(stora, STORA_SECOND_F, second);
|
||||
else
|
||||
BlkValueWrite(stora, STORA_SECOND_F, parsed_number);
|
||||
BlkValueWrite(stora, STORA_ACTOR_F, actor);
|
||||
if (act_requester) BlkValueWrite(stora, STORA_REQUEST_F, true);
|
||||
else BlkValueWrite(stora, STORA_REQUEST_F, false);
|
||||
WritePVField(stora, STORA_SECOND_F, parsed_number);
|
||||
WritePVField(stora, STORA_ACTOR_F, actor);
|
||||
if (act_requester) WritePVField(stora, STORA_REQUEST_F, true);
|
||||
else WritePVField(stora, STORA_REQUEST_F, false);
|
||||
|
||||
if ((at) && ((ActionData-->(at+AD_NOUN_KOV) == UNDERSTANDING_TY) ||
|
||||
(ActionData-->(at+AD_SECOND_KOV) == UNDERSTANDING_TY))) {
|
||||
text_of_command = BlkValueRead(stora, STORA_COMMAND_TEXT_F);
|
||||
text_of_command = PVField(stora, STORA_COMMAND_TEXT_F);
|
||||
if (text_of_command == 0) {
|
||||
text_of_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueWrite(stora, STORA_COMMAND_TEXT_F, text_of_command);
|
||||
text_of_command = CreatePV(TEXT_TY);
|
||||
WritePVField(stora, STORA_COMMAND_TEXT_F, text_of_command);
|
||||
}
|
||||
BlkValueCast(text_of_command, SNIPPET_TY, players_command);
|
||||
} else BlkValueWrite(stora, STORA_COMMAND_TEXT_F, 0);
|
||||
SNIPPET_TY_to_TEXT_TY(text_of_command, players_command);
|
||||
} else WritePVField(stora, STORA_COMMAND_TEXT_F, 0);
|
||||
|
||||
return stora;
|
||||
];
|
||||
|
@ -358,23 +359,23 @@ either silently or not.
|
|||
|
||||
=
|
||||
[ STORED_ACTION_TY_Try stora ks text_of_command saved_command;
|
||||
if ((stora==0) || (BlkValueWeakKind(stora) ~= STORED_ACTION_TY)) return;
|
||||
if (WeakKindOfPV(stora) ~= STORED_ACTION_TY) return;
|
||||
if (ks) { @push keep_silent; keep_silent=1; }
|
||||
text_of_command = BlkValueRead(stora, STORA_COMMAND_TEXT_F);
|
||||
text_of_command = PVField(stora, STORA_COMMAND_TEXT_F);
|
||||
if (text_of_command) {
|
||||
saved_command = BlkValueCreate(TEXT_TY);
|
||||
BlkValueCast(saved_command, SNIPPET_TY, players_command);
|
||||
saved_command = CreatePV(TEXT_TY);
|
||||
SNIPPET_TY_to_TEXT_TY(saved_command, players_command);
|
||||
SetPlayersCommand(text_of_command);
|
||||
}
|
||||
TryAction(
|
||||
BlkValueRead(stora, STORA_REQUEST_F),
|
||||
BlkValueRead(stora, STORA_ACTOR_F),
|
||||
BlkValueRead(stora, STORA_ACTION_F),
|
||||
BlkValueRead(stora, STORA_NOUN_F),
|
||||
BlkValueRead(stora, STORA_SECOND_F));
|
||||
PVField(stora, STORA_REQUEST_F),
|
||||
PVField(stora, STORA_ACTOR_F),
|
||||
PVField(stora, STORA_ACTION_F),
|
||||
PVField(stora, STORA_NOUN_F),
|
||||
PVField(stora, STORA_SECOND_F));
|
||||
if (text_of_command) {
|
||||
SetPlayersCommand(saved_command);
|
||||
BlkValueFree(saved_command);
|
||||
DestroyPV(saved_command);
|
||||
}
|
||||
if (ks) { @pull keep_silent; }
|
||||
];
|
||||
|
|
|
@ -22,7 +22,7 @@ new base STORED_ACTION_TY {
|
|||
|
||||
distinguishing-routine: STORED_ACTION_TY_Distinguish
|
||||
printing-routine: STORED_ACTION_TY_Say
|
||||
comparison-routine: BlkValueCompare
|
||||
comparison-routine: STORED_ACTION_TY_Compare
|
||||
|
||||
documentation-reference: kind_storedaction
|
||||
index-default-value: waiting
|
||||
|
|
|
@ -981,8 +981,11 @@ Section 1 - Enumerations
|
|||
To decide which number is number of (S - description of values)
|
||||
(documented at ph_numberof):
|
||||
(- {-primitive-definition:number-of} -).
|
||||
To decide what number is the numerical value of (X - enumerated value): (- {X} -).
|
||||
To decide what number is the sequence number of (X - enumerated value of kind K):
|
||||
To decide what number is the numerical value of (X - enumerated value)
|
||||
(documented at ph_numericalvalue):
|
||||
(- {X} -).
|
||||
To decide what number is the sequence number of (X - enumerated value of kind K)
|
||||
(documented at ph_sequencenumber):
|
||||
(- {-indexing-routine:K}({X}) -).
|
||||
To decide which K is (name of kind of enumerated value K) after (X - K)
|
||||
(documented at ph_enumafter):
|
||||
|
|
|
@ -203,22 +203,22 @@ To group (OS - description of objects) together
|
|||
(documented at ph_group): (-
|
||||
objectloop({-my:1} provides list_together)
|
||||
if ({-matches-description:1:OS})
|
||||
BlkValueCopy({-my:1}.list_together, {-list-together:unarticled});
|
||||
CopyPV({-my:1}.list_together, {-list-together:unarticled});
|
||||
-).
|
||||
To group (OS - description of objects) together giving articles
|
||||
(documented at ph_groupart): (-
|
||||
objectloop({-my:1} provides list_together)
|
||||
if ({-matches-description:1:OS})
|
||||
BlkValueCopy({-my:1}.list_together, {-list-together:articled});
|
||||
CopyPV({-my:1}.list_together, {-list-together:articled});
|
||||
-).
|
||||
To group (OS - description of objects) together as (T - text)
|
||||
(documented at ph_grouptext): (-
|
||||
{-my:2} = BlkValueCreate(TEXT_TY);
|
||||
{-my:2} = CreatePV(TEXT_TY);
|
||||
{-my:2} = TEXT_TY_SubstitutedForm({-my:2}, {-by-reference:T});
|
||||
objectloop({-my:1} provides list_together)
|
||||
if ({-matches-description:1:OS})
|
||||
BlkValueCopy({-my:1}.list_together, {-my:2});
|
||||
BlkValueFree({-my:2});
|
||||
CopyPV({-my:1}.list_together, {-my:2});
|
||||
DestroyPV({-my:2});
|
||||
-).
|
||||
To omit contents in listing
|
||||
(documented at ph_omit):
|
||||
|
|
|
@ -66,8 +66,7 @@ regular users: it would be quite slow to read in.
|
|||
inter_architecture *A = PipelineModule::get_architecture();
|
||||
if (A == NULL) Errors::fatal("no -architecture given");
|
||||
filename *arch_file = Architectures::canonical_binary(req->location, A);
|
||||
if (TextFiles::exists(arch_file) == FALSE)
|
||||
internal_error("no arch file for requirement");
|
||||
if (TextFiles::exists(arch_file) == FALSE) continue;
|
||||
if (BinaryInter::test_file(arch_file)) BinaryInter::read(sidecar, arch_file);
|
||||
else TextualInter::read(sidecar, arch_file);
|
||||
|
||||
|
|
Loading…
Reference in a new issue