內容列表(Table of Contents)


14. 選用的記憶體配置詞集(The optional Memory-Allocation word set)


14.1 介紹(Introduction)

參閱(See): A.14 選用的記憶體配置詞集(The optional Memory-Allocation word set)


14.2 附加的專有名詞和記號(Additional terms and notation)

無(None).


14.3 附加的使用需求(Additional usage requirements)


14.3.1 輸出入結果資料型別(I/O Results data type)

輸出入結果是單一單元數字, 提示了輸出入操作的結果. 值零提示了輸出入結果成功地完成; 其他的值和它們的意義是實作自訂的.

I/O results are single-cell numbers indicating the result of I/O operations. A value of zero indicates that the I/O operation completed successfully; other values and their meanings are implementation-defined.

將表格 14.1 加進 表格 3.1.

Append table 14.1 to table 3.1.

表格 14.1 - 資料型別

符號    資料型別        在堆疊上的大小
------  ---------       -------------
ior     輸出入結果      1 cell

Table 14.1 - Data types

Symbol  Data type       Size on stack
------  ---------       -------------
ior     I/O results     1 cell


14.3.2 環境的詢問(Environmental queries)

將表格 14.1 加進表格 3.5.

Append table 14.2 to table 3.5.

參閱(See): 3.2.6 環境的詢問(Environmental queries)

表格 14.2 - 環境詢問字串

字串               值     資料型別  常數?      意義
------             ---------------  ---------  -------
MEMORY-ALLOC       flag             no         記憶體配置詞集存在
MEMORY-ALLOC-EXT   flag             no         記憶體配置延伸詞集存在

Table 14.2 - Environmental query strings

String             Value data type  Constant?  Meaning
------             ---------------  ---------  -------
MEMORY-ALLOC       flag             no         memory-allocation word set present
MEMORY-ALLOC-EXT   flag             no         memory-allocation extensions word set present


14.3.3 配置的區域(Allocated regions)

一個程式可以定址透過由 ALLOCATERESIZE 提供的、或是尚未由 FREE 釋放的資料空間中的記憶體.

A program may address memory in data space regions made available by ALLOCATE or RESIZE and not yet released by FREE.

參閱(See): 3.3.3 資料空間(Data space)


14.4 附加的文件需求(Additional documentation requirements)


14.4.1 系統文件(System documentation)


14.4.1.1 實作自訂選項(Implementation-defined options)


14.4.1.2 模稜兩可的情況(Ambiguous conditions)


14.4.1.3 其他的系統文件(Other system documentation)


14.4.2 程式文件(Program documentation)


14.5 遵守標準和命名(Compliance and labeling)


14.5.1 ANS Forth 系統(ANS Forth systems)

措辭 提供記憶體配置詞集 必須被加到任何提供記憶體配置詞集的標準系統的描述之中.

The phrase Providing the Memory-Allocation word set shall be appended to the label of any Standard System that provides all of the Memory-Allocation word set.

措辭 從記憶體配置延伸詞集提供 name(s) 必須被加到任何提供部分記憶體配置延伸詞集的標準系統的描述之中.

The phrase Providing name(s) from the Memory-Allocation Extensions word set shall be appended to the label of any Standard System that provides portions of the Memory-Allocation Extensions word set.

措辭 提供記憶體配置延伸詞集 必須被加到任何提供所有記憶體配置詞集和記憶體配置延伸詞集的標準系統的描述之中.

The phrase Providing the Memory-Allocation Extensions word set shall be appended to the label of any Standard System that provides all of the Memory-Allocation and Memory-Allocation Extensions word sets.


14.5.2 ANS Forth 程式(ANS Forth programs)

措辭 需要記憶體配置詞集 必須被加到任何需要系統提供記憶體配置詞集的標準程式的描述之中.

The phrase Requiring the Memory-Allocation word set shall be appended to the label of Standard Programs that require the system to provide the Memory-Allocation word set.

措辭 需要記憶體配置延伸詞集中的 name(s) 必須被加到任何需要系統提供部分記憶體配置延伸詞集的標準程式的描述之中.

The phrase Requiring name(s) from the Memory-Allocation Extensions word set shall be appended to the label of Standard Programs that require the system to provide portions of the Memory-Allocation Extensions word set.

措辭 需要記憶體配置延伸詞集 必須被加到任何需要系統提供所有記憶體配置和記憶體配置延伸詞集的標準程式的描述之中.

The phrase Requiring the Memory-Allocation Extensions word set shall be appended to the label of Standard Programs that require the system to provide all of the Memory-Allocation and Memory-Allocation Extensions word sets.


14.6 詞彙表(Glossary)


14.6.1 記憶體配置詞(Memory-Allocation words)


14.6.1.0707 ALLOCATE
MEMORY
	( u -- a-addr ior )

配置連續的資料空間中的 u 位址單元. 資料空間指標不會被這項操作影響. 這塊被配置的空間的初始內容是未定義的.

如果這項配置成功, a-addr 是被配置空間的對齊的開始位置, 並且 ior 是零.

如果這項操作失敗, a-addr 不會代表一個正確的位置, 並且 ior 是實作自訂的輸出入結果代碼.

參閱: 6.1.1650 HERE , 14.6.1.1605 FREE , 14.6.1.2145 RESIZE


14.6.1.0707 ALLOCATE
MEMORY
	( u -- a-addr ior )

Allocate u address units of contiguous data space. The data-space pointer is unaffected by this operation. The initial content of the allocated space is undefined.

If the allocation succeeds, a-addr is the aligned starting address of the allocated space and ior is zero.

If the operation fails, a-addr does not represent a valid address and ior is the implementation-defined I/O result code.

See: 6.1.1650 HERE , 14.6.1.1605 FREE , 14.6.1.2145 RESIZE


14.6.1.1605 FREE
MEMORY
	( a-addr -- ior )

傳回由 a-addr 提示的資料空間中的連續的區域給系統, 能稍後再被配置. a-addr 必須提示之前由 ALLOCATERESIZE 取得的資料空間中的區域. 資料空間指標在這項操作中不受影響.

如果這項操作成功, ior 是零. 如果這項操作失敗, ior 是實作自訂的輸出入結果代碼.

參閱: 6.1.1650 HERE


14.6.1.1605 FREE
MEMORY
	( a-addr -- ior )

Return the contiguous region of data space indicated by a-addr to the system for later allocation. a-addr shall indicate a region of data space that was previously obtained by ALLOCATE or RESIZE. The data-space pointer is unaffected by this operation.

If the operation succeeds, ior is zero. If the operation fails, ior is the implementation-defined I/O result code.

See: 6.1.1650 HERE


14.6.1.2145 RESIZE
MEMORY
	( a-addr1 u -- a-addr2 ior )

改變之前由 ALLOCATE 或 RESIZE 配置的, 開始於位址 a-addr1 的連續的資料空間中的分配物成為 u 個位址單元. u 可以是較大或較小於目前區域的大小. 資料空間指標不受這項操作影響.

如果這項操作成功, a-addr2 是 u 個被配置的記憶體的位址單元的對齊的開始位址, 並且 ior 是零. a-addr2 可以是, 但不需要是與 a-addr1 相同. 如果它們不同, 包含於區域 a-addr1 的內容會被複製於 a-addr2, 直到兩個區域的最小大小為止. 如果它們是相同的, 包含於區域中的值會保留 u 的最小值或是原始的大小. 如果 a-addr2 不同於 a-addr1, 在 a-addr1 區域的記憶體將會依照 FREE 的操作被傳回給系統.

如果這項操作失敗, a-addr2 等於 a-addr1, 在 a-addr1 這區域的記憶體不受影響, 並且 ior 會是實作自訂的輸出入結果代碼.

參閱: 6.1.1650 HERE


14.6.1.2145 RESIZE
MEMORY
	( a-addr1 u -- a-addr2 ior )

Change the allocation of the contiguous data space starting at the address a-addr1, previously allocated by ALLOCATE or RESIZE, to u address units. u may be either larger or smaller than the current size of the region. The data-space pointer is unaffected by this operation.

If the operation succeeds, a-addr2 is the aligned starting address of u address units of allocated memory and ior is zero. a-addr2 may be, but need not be, the same as a-addr1. If they are not the same, the values contained in the region at a-addr1 are copied to a-addr2, up to the minimum size of either of the two regions. If they are the same, the values contained in the region are preserved to the minimum of u or the original size. If a-addr2 is not the same as a-addr1, the region of memory at a-addr1 is returned to the system according to the operation of FREE.

If the operation fails, a-addr2 equals a-addr1, the region of memory at a-addr1 is unaffected, and ior is the implementation-defined I/O result code.

See: 6.1.1650 HERE


14.6.2 記憶體延伸配置詞(Memory-Allocation extension words)

無(None)


內容列表(Table of Contents)
下一章(Next Section)