2021-04-21 14:02:18 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
< html >
< head >
< title > Enclosures< / title >
< link href = "../docs-assets/Breadcrumbs.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< meta name = "viewport" content = "width=device-width initial-scale=1" >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" >
< meta http-equiv = "Content-Language" content = "en-gb" >
< link href = "../docs-assets/Contents.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< link href = "../docs-assets/Progress.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< link href = "../docs-assets/Navigation.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< link href = "../docs-assets/Fonts.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< link href = "../docs-assets/Base.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< script >
function togglePopup(material_id) {
var popup = document.getElementById(material_id);
popup.classList.toggle("show");
}
< / script >
< link href = "../docs-assets/Popups.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< script src = "http://code.jquery.com/jquery-1.12.4.min.js"
integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous">< / script >
< script src = "../docs-assets/Bigfoot.js" > < / script >
< link href = "../docs-assets/Bigfoot.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< link href = "../docs-assets/Colours.css" rel = "stylesheet" rev = "stylesheet" type = "text/css" >
< / head >
< body class = "commentary-font" >
< nav role = "navigation" >
2022-04-28 19:37:28 +03:00
< h1 > < a href = "../index.html" >
2021-04-21 14:02:18 +03:00
< img src = "../docs-assets/Inform.png" height = 72" >
< / a > < / h1 >
2022-04-28 19:37:28 +03:00
< ul > < li > < a href = "../index.html" > home< / a > < / li >
2022-04-04 20:31:44 +03:00
< / ul > < h2 > Compiler< / h2 > < ul >
< li > < a href = "../structure.html" > structure< / a > < / li >
< li > < a href = "../inbuildn.html" > inbuild< / a > < / li >
< li > < a href = "../inform7n.html" > inform7< / a > < / li >
< li > < a href = "../intern.html" > inter< / a > < / li >
< li > < a href = "../services.html" > services< / a > < / li >
2022-04-18 17:46:46 +03:00
< li > < a href = "../secrets.html" > secrets< / a > < / li >
2022-04-04 20:31:44 +03:00
< / ul > < h2 > Other Tools< / h2 > < ul >
< li > < a href = "../inblorbn.html" > inblorb< / a > < / li >
< li > < a href = "../indocn.html" > indoc< / a > < / li >
< li > < a href = "../inform6.html" > inform6< / a > < / li >
< li > < a href = "../inpolicyn.html" > inpolicy< / a > < / li >
2022-04-07 00:04:57 +03:00
< / ul > < h2 > Resources< / h2 > < ul >
< li > < a href = "../extensions.html" > extensions< / a > < / li >
< li > < a href = "../kits.html" > kits< / a > < / li >
2022-04-04 20:31:44 +03:00
< / ul > < h2 > Repository< / h2 > < ul >
< li > < a href = "https://github.com/ganelson/inform" > < img src = "../docs-assets/github.png" height = 18 > github< / a > < / li >
< / ul > < h2 > Related Projects< / h2 > < ul >
2022-04-28 19:20:06 +03:00
< li > < a href = "../../../inweb/index.html" > inweb< / a > < / li >
< li > < a href = "../../../intest/index.html" > intest< / a > < / li >
2021-04-21 14:02:18 +03:00
< / ul >
< / nav >
< main role = "main" >
<!-- Weave of 'Enclosures' generated by Inweb -->
< div class = "breadcrumbs" >
2022-04-28 19:37:28 +03:00
< ul class = "crumbs" > < li > < a href = "../index.html" > Home< / a > < / li > < li > < a href = "../inform7n.html" > Inform7< / a > < / li > < li > < a href = "index.html" > runtime< / a > < / li > < li > < a href = "index.html#4" > Chapter 4: Enclosed Resources< / a > < / li > < li > < b > Enclosures< / b > < / li > < / ul > < / div >
2021-04-21 14:02:18 +03:00
< p class = "purpose" > Packages which contain all the resources any of their subpackages will need are called "enclosures".< / p >
< p class = "commentary firstcommentary" > < a id = "SP1" class = "paragraph-anchor" > < / a > < b > § 1. < / b > The idea of "enclosure" lets us create something "nearby". We are generally
creating bytecode at a particular position in the hierarchy — say, in the
current function being compiled. We then want to create some associated local
resource, which can't be at that exact position, but which we want to keep
nearby. (For example, a constant list mentioned in the function will need an
associated array.)
< / p >
< p class = "commentary" > The following creates a package in the enclosure surrounding the current
emission position:
< / p >
< pre class = "displayed-code all-displayed-code code-font" >
2021-05-22 13:31:40 +03:00
< span class = "identifier-syntax" > inter_name< / span > < span class = "plain-syntax" > *< / span > < span class = "function-syntax" > Enclosures::new_iname< / span > < button class = "popup" onclick = "togglePopup('usagePopup1')" > < span class = "comment-syntax" > ?< / span > < span class = "popuptext" id = "usagePopup1" > Usage of < span class = "code-font" > < span class = "function-syntax" > Enclosures::new_iname< / span > < / span > :< br / > < a href = "4-enc.html#SP2" > § 2< / a > < br / > List Literals - < a href = "4-ll.html#SP4" > § 4< / a > < br / > Text Literals - < a href = "4-tl.html#SP4" > § 4< / a > < br / > Box Quotations - < a href = "4-bq.html#SP1" > § 1< / a > < br / > Group Together - < a href = "4-gt.html#SP2" > § 2< / a > < br / > Looping Over Scope - < a href = "4-los.html#SP2" > § 2< / a > < / span > < / button > < span class = "plain-syntax" > (< / span > < span class = "reserved-syntax" > int< / span > < span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > hap< / span > < span class = "plain-syntax" > , < / span > < span class = "reserved-syntax" > int< / span > < span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > hl< / span > < span class = "plain-syntax" > ) {< / span >
2021-04-21 14:02:18 +03:00
< span class = "plain-syntax" > < / span > < span class = "identifier-syntax" > package_request< / span > < span class = "plain-syntax" > *< / span > < span class = "identifier-syntax" > PR< / span > < span class = "plain-syntax" > = < / span > < span class = "identifier-syntax" > HierarchyLocations::attach_new_package< / span > < span class = "plain-syntax" > (< / span >
< span class = "plain-syntax" > < / span > < a href = "2-emt.html#SP1" class = "function-link" > < span class = "function-syntax" > Emit::tree< / span > < / a > < span class = "plain-syntax" > (), < / span > < span class = "identifier-syntax" > NULL< / span > < span class = "plain-syntax" > , < / span > < a href = "2-emt.html#SP1" class = "function-link" > < span class = "function-syntax" > Emit::current_enclosure< / span > < / a > < span class = "plain-syntax" > (), < / span > < span class = "identifier-syntax" > hap< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > < / span > < span class = "reserved-syntax" > return< / span > < span class = "plain-syntax" > < / span > < a href = "2-hrr.html#SP12" class = "function-link" > < span class = "function-syntax" > Hierarchy::make_iname_in< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "identifier-syntax" > hl< / span > < span class = "plain-syntax" > , < / span > < span class = "identifier-syntax" > PR< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > }< / span >
< / pre >
< p class = "commentary firstcommentary" > < a id = "SP2" class = "paragraph-anchor" > < / a > < b > § 2. < / b > As noted above, literal values for constants which cannot be stored in a
single word are a case in point. In general, these are represented in memory
like so:
< / p >
< pre class = "displayed-code all-displayed-code code-font" >
< span class = "plain-syntax" > small block:< / span >
< span class = "plain-syntax" > ----------------> data< / span >
< span class = "plain-syntax" > data< / span >
< span class = "plain-syntax" > ...< / span >
< / pre >
< p class = "commentary" > The size of the small block varies from kind to kind,< sup id = "fnref:1" > < a href = "#fn:1" rel = "footnote" > 1< / a > < / sup > but for any given
kind this size is fixed. For example, a text has a small block of 2 words.
< / p >
< p class = "commentary" > Often, but not always, the small block points to a larger and flexibly-sized
block of data elsewhere:
< / p >
< pre class = "displayed-code all-displayed-code code-font" >
< span class = "plain-syntax" > small block: large block:< / span >
< span class = "plain-syntax" > ----------------> metadata< / span >
< span class = "plain-syntax" > ...< / span >
< span class = "plain-syntax" > pointer ----------------> block value header< / span >
< span class = "plain-syntax" > ... data< / span >
< span class = "plain-syntax" > ...< / span >
< / pre >
< p class = "commentary" > The size of the large block, and the format of the small block and the "actual
data", vary from kind to kind.
< / p >
< ul class = "footnotetexts" > < li class = "footnote" id = "fn:1" > < p class = "inwebfootnote" > < sup id = "fnref:1" > < a href = "#fn:1" rel = "footnote" > 1< / a > < / sup > Properly speaking, from constructor to constructor. All lists have the
same size of small block.
< a href = "#fnref:1" title = "return to text" > ↩ < / a > < / p > < / li > < / ul >
< pre class = "displayed-code all-displayed-code code-font" >
2023-07-12 13:05:24 +03:00
< span class = "identifier-syntax" > inter_name< / span > < span class = "plain-syntax" > *< / span > < span class = "function-syntax" > Enclosures::new_small_block_for_constant< / span > < button class = "popup" onclick = "togglePopup('usagePopup2')" > < span class = "comment-syntax" > ?< / span > < span class = "popuptext" id = "usagePopup2" > Usage of < span class = "code-font" > < span class = "function-syntax" > Enclosures::new_small_block_for_constant< / span > < / span > :< br / > Default Values - < a href = "2-dv.html#SP2_8" > § 2.8< / a > < br / > List Literals - < a href = "4-ll.html#SP2" > § 2< / a > < br / > Text Literals - < a href = "4-tl.html#SP1" > § 1< / a > < br / > Relation Literals - < a href = "4-rl.html#SP1" > § 1< / a > < br / > Stored Action Literals - < a href = "4-sal.html#SP1" > § 1< / a > < / span > < / button > < span class = "plain-syntax" > (< / span > < span class = "reserved-syntax" > void< / span > < span class = "plain-syntax" > ) {< / span >
2021-04-21 14:02:18 +03:00
< span class = "plain-syntax" > < / span > < span class = "reserved-syntax" > return< / span > < span class = "plain-syntax" > < / span > < a href = "4-enc.html#SP1" class = "function-link" > < span class = "function-syntax" > Enclosures::new_iname< / span > < / a > < span class = "plain-syntax" > (< / span > < span class = "constant-syntax" > BLOCK_CONSTANTS_HAP< / span > < span class = "plain-syntax" > , < / span > < span class = "constant-syntax" > BLOCK_CONSTANT_HL< / span > < span class = "plain-syntax" > );< / span >
< span class = "plain-syntax" > }< / span >
< / pre >
< nav role = "progress" > < div class = "progresscontainer" >
2021-05-25 14:14:32 +03:00
< ul class = "progressbar" > < li class = "progressprev" > < a href = "3-uo.html" > ❮ < / a > < / li > < li class = "progresschapter" > < a href = "P-wtmd.html" > P< / a > < / li > < li class = "progresschapter" > < a href = "1-rm.html" > 1< / a > < / li > < li class = "progresschapter" > < a href = "2-hrr.html" > 2< / a > < / li > < li class = "progresschapter" > < a href = "3-gm.html" > 3< / a > < / li > < li class = "progresscurrentchapter" > 4< / li > < li class = "progresscurrent" > enc< / li > < li class = "progresssection" > < a href = "4-ll.html" > ll< / a > < / li > < li class = "progresssection" > < a href = "4-tl.html" > tl< / a > < / li > < li class = "progresssection" > < a href = "4-ts.html" > ts< / a > < / li > < li class = "progresssection" > < a href = "4-rsp.html" > rsp< / a > < / li > < li class = "progresssection" > < a href = "4-bq.html" > bq< / a > < / li > < li class = "progresssection" > < a href = "4-rl.html" > rl< / a > < / li > < li class = "progresssection" > < a href = "4-sal.html" > sal< / a > < / li > < li class = "progresssection" > < a href = "4-gt.html" > gt< / a > < / li > < li class = "progresssection" > < a href = "4-los.html" > los< / a > < / li > < li class = "progresschapter" > < a href = "5-act.html" > 5< / a > < / li > < li class = "progresschapter" > < a href = "6-bd.html" > 6< / a > < / li > < li class = "progresschapter" > < a href = "7-cg.html" > 7< / a > < / li > < li class = "progressnext" > < a href = "4-ll.html" > ❯ < / a > < / li > < / ul > < / div >
2021-04-21 14:02:18 +03:00
< / nav > <!-- End of weave -->
< / main >
< / body >
< / html >