TriOS-alt/zubehör/sphinx/spinx100225-ori/dokumentation/sobstory.htm

272 lines
18 KiB
HTML
Raw Normal View History

2010-11-26 23:58:06 +01:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">/* Copyright 2008 Google. */ (function() { // Input 0
var a=window;
// Input 1
var b="start";function d(f){this.t={};this.tick=function(g,h,c){c=c?c:(new Date).getTime();this.t[g]=[c,h]};this.tick(b,null,f)}var e=new d;a.jstiming={Timer:d,load:e};try{var i=null;if(a.chrome&&a.chrome.csi)i=Math.floor(a.chrome.csi().pageT);if(i==null)if(a.gtbExternal)i=a.gtbExternal.pageT();if(i==null)if(a.external)i=a.external.pageT;if(i)a.jstiming.pt=i}catch(j){};
// Input 2
})()
</script>
<link rel="shortcut icon" type="image/x-icon" href="//www.google.com/images/icons/product/sites-16.ico" />
<link rel="apple-touch-icon" href="http://www.gstatic.com/sites/p/934749/system/app/images/apple-touch-icon.png" type="image/png" />
<script type="text/javascript">/* Copyright 2008 Google. */ (function() { var e=parseInt,h=window,i="length";function j(c){return document.getElementById(c)}h.byId=j;var k="";function l(c){return c.replace(/^\s+|\s+$/g,k)}h.trim=l;
var m="MSIE",n="6.0",o="string",p='id="',q='" ',r='class="',s='title="',t="display:inline-block;",u="left",v="float:left;",w="right",x="float:right;",y="cursor:hand;",z="<span ",A=' style="width:',B="px; height:",C="px;",D=";padding: 0;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='",E="', sizingMethod='scale');\"></span><span style=\"padding: ",F=" ",G=";",H="float:",I='"></span>';
h.ie6ImgFix=function(c){var b=h.navigator?navigator.userAgent:k;if(b.indexOf(m)!=-1&&typeof opera=="undefined"){var d=/MSIE\s+([^\);]+)(\)|;)/;d.test(b);b=RegExp.$1;if(b==n){var a=typeof c==o?j(c):c;c=a.id?p+a.id+q:k;b=a.className?r+a.className+q:k;d=a.title?s+a.title+q:s+a.alt+q;var f=t+a.style.cssText;if(a.align==u)f=v+f;if(a.align==w)f=x+f;if(a.parentElement.href)f=y+f;var g=a.currentStyle,L=a.width-e(g.paddingLeft,10)-e(g.paddingRight,10),M=a.height-e(g.paddingTop,10)-e(g.paddingBottom,10),N=
z+c+b+d+A+L+B+M+C+f+D+a.src+E+g.paddingTop+F+g.paddingRight+F+g.paddingBottom+F+g.paddingLeft+G+(g.styleFloat?H+g.styleFloat+G:k)+I;h.setTimeout(function(){a.outerHTML=N},1)}}};var J=[],K=0;h.JOT_addListener=function(c,b,d){var a=new String(K++);c={eventName:c,handler:b,compId:d,key:a};J.push(c);return a};h.JOT_removeListenerByKey=function(c){for(var b=0;b<J[i];b++)if(J[b].key==c){J.splice(b,1);break}};
h.JOT_removeAllListenersForName=function(c){for(var b=0;b<J[i];b++)J[b].eventName==c&&J.splice(b,1)};var O="function";h.JOT_postEvent=function(c,b,d){var a={eventName:c,eventSrc:b||{},payload:d||{}};if(h.JOT_fullyLoaded){b=J[i];for(d=0;d<b&&d<J[i];d++){var f=J[d];if(f&&f.eventName==c){a.listenerCompId=f.compId||k;(f=typeof f.handler==O?f.handler:h[f.handler])&&f(a)}}}else h.JOT_delayedEvents.push({eventName:c,eventSrc:b,payload:d})};h.JOT_delayedEvents=[];h.JOT_fullyLoaded=false;var P="__duration__";
h.JOT_formatRelativeToNow=function(c,b){var d=((new Date).getTime()-c)/6E4;if(d>=1440||d<0)return null;var a=0;if(d>=60){d/=60;a=2}d>=2&&a++;return b?h.JOT_siteRelTimeStrs[a].replace(P,Math.floor(d)):h.JOT_userRelTimeStrs[a].replace(P,Math.floor(d))}; })()
</script>
<script>
var webspace = {"signInUrl":"https://www.google.com/a/UniversalLogin?continue=http%3A%2F%2Fsites.google.com%2Fsite%2Fsphinxcompiler%2FHome%2Fsphinx-documentation%2Fsobstory&service=jotspot","isConsumer":true,"termsUrl":"http://www.google.com/sites/help/intl/de/terms.html","enableAnalytics":false,"homePath":"/","sharingId":"jotspot","sharingPolicy":"OPENED","isAdsenseEnabled":true,"analyticsAccountId":"","baseUri":"","name":"sphinxcompiler","features":{"structuredDataGviz":false,"horizontalNavigationDropdownMenus":true,"subpageNav":false,"kixEditorPageType":false,"maestroIntegration":false,"newPageFinder":true,"pdfEmbedSupport":false,"experimental":{"displayEditorLockExceptions":false,"commonSharingExperiment":false},"useStandardEmbedsInSidebar":false,"pageLevelPermissions":false,"navadminperf":true,"adminInfo":false,"lazySiteHierarchy":true,"dragDropHierarchy":true,"headerAlignmentOptions":true,"horizontalNavigationBar":true,"keyboardShortcuts":true,"commonSharing":false,"spreadsheetsEmbedLoadRedirect":false,"structuredDataSchemas":false,"footerCustomOptions":true},"domain":"defaultdomain","adsensePublisherId":"ca-pub-9569899026815114","isStartPageEnabled":false,"domainAnalyticsAccountId":"","siteTitle":"sphinxcompiler"};
webspace.gadgets = {"isGadgetDirectoryEnabled":true,"baseUri":"/system/app/pages/gadgets","isGgsRenderingEnabled":true};
webspace.user = {"uid":"","hasAdminAccess":false,"guest_":true,"keyboardShortcuts":true,"domain":"","hasWriteAccess":false,"userName":"guest","dasherUser":false,"primaryEmail":"guest","sessionIndex":"","namespaceUser":false,"displayNameOrEmail":"guest"};
webspace.page = {"canDeleteWebspace":null,"locale":"de","state":"","wuid":"wuid:gx:42b8839a5da5c6fb","timeZone":"Europe/Paris","properties":{},"type":"text","canChangePath":true,"parentWuid":"wuid:gx:6a8841c52faad061","revision":8,"title":"Compiling and linking: a SOB story","isRtlLocale":false,"bidiEnabled":false,"siteLocale":"en","name":"sobstory","path":"/Home/sphinx-documentation/sobstory","isSiteRtlLocale":false,"parentPath":"/Home/sphinx-documentation"};
var editorResources = [
'http://www.gstatic.com/sites/p/934749/system/js/trog_edit__de.js',
'http://www.gstatic.com/sites/p/934749/system/app/css/trogedit.css',
'/_/rsrc/1287429563000/system/app/css/editor.css'
];
var JOT_clearDotPath = 'http://www.gstatic.com/sites/p/934749/system/app/images/cleardot.gif';
var JOT_userRelTimeStrs = ["vor einer Minute","vor __duration__ Minuten","vor einer Stunde","vor __duration__ Stunden"];
webspace.page.currentTemplate = {"title":"Webseite","path":"/system/app/pagetemplates/text"};
var JOT_siteRelTimeStrs = ["a minute ago","__duration__ minutes ago","an hour ago","__duration__ hours ago"];
</script>
<script type="text/javascript">
window.jstiming.load.tick('scl');
</script>
<link rel="stylesheet" type="text/css" href="http://www.gstatic.com/sites/p/934749/system/app/themes/simplywhite/standard-css-simplywhite-ltr-ltr.css" />
<link rel="stylesheet" type="text/css" href="/_/rsrc/1287429563000/system/app/css/overlay.css?cb=simplywhite100%250150goog-ws-left" />
<title>Compiling and linking: a SOB story - sphinxcompiler</title>
<script type="text/javascript">
window.jstiming.load.tick('cl');
</script>
</head>
<body xmlns="http://www.google.com/ns/jotspot" id="body" class=" en">
<div id="sites-page-toolbar">
<div id="sites-status" class="sites-status" style="display:none;">
<div id="sites-notice" class="sites-notice"> </div>
</div>
</div>
<div id="sites-chrome-everything" style="direction: ltr">
<div id="sites-chrome-page-wrapper">
<div id="sites-chrome-page-wrapper-inside">
<div xmlns="http://www.w3.org/1999/xhtml" id="sites-chrome-header-wrapper">
<table id="sites-chrome-header" class="sites-layout-hbox" cellspacing="0">
<tr class="sites-header-primary-row">
<td id="sites-header-title">
<div class="sites-header-cell-buffer-wrapper">
<h2>
<a href="http://www.sphinxcompiler.com/" dir="ltr">sphinxcompiler</a>
</h2>
</div>
</td>
<td class="sites-layout-searchbox">
<div class="sites-header-cell-buffer-wrapper">
<div>
<form id="sites-searchbox-form" action="/system/app/pages/search">
<input type="text" onpropertychange="JOT_setTextDir(this)" oninput="JOT_setTextDir(this)" dir="" id="jot-ui-searchInput" name="q" size="20" />
<input type="hidden" id="sites-searchbox-scope" name="scope" value="search-site" />
<div class="goog-inline-block goog-button goog-button-base "><div class="goog-inline-block goog-button-base-outer-box TOP"><div class="goog-inline-block goog-button-base-inner-box"><div class="goog-button-base-pos"><div class="goog-button-base-top-shadow"> </div><div id="sites-searchbox-search-button" class="goog-button-base-content " style="" onclick=""><span id="sites-searchbox-search-button-label">Search this site</span></div></div></div></div></div>
</form>
</div>
</div>
</td>
</tr>
<tr class="sites-header-secondary-row">
<td colspan="2">
</td>
</tr>
</table>
</div>
<div id="sites-chrome-main-wrapper">
<div id="sites-chrome-main-wrapper-inside">
<table id="sites-chrome-main" class="sites-layout-hbox" cellspacing="0">
<tr>
<td id="sites-chrome-sidebar-left" class="sites-layout-sidebar-left">
</td>
<td id="sites-canvas-wrapper">
<div id="sites-canvas">
<div id="goog-ws-editor-toolbar-container"> </div>
<div xmlns="http://www.w3.org/1999/xhtml" id="title-crumbs" style="">
<A dir="ltr" href="/Home">Sphinx</A> &gt; <A dir="ltr" href="/Home/sphinx-documentation">Documentation</A> &gt;
</div>
<h3 xmlns="http://www.w3.org/1999/xhtml" id="sites-page-title-header" style="" align="left">
<span id="sites-page-title" dir="ltr">Compiling and linking: a SOB story</span>
</h3>
<div id="sites-canvas-main" class="sites-canvas-main">
<div id="sites-canvas-main-content">
<table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" class="sites-layout-name-one-column sites-layout-hbox"><tbody><tr><td class="sites-layout-tile sites-tile-name-content-1"><div dir="ltr"><div>The process of building a program with Sphinx is divided into two steps, compiling and linking. Compiling transforms a Spin source file into a Spin Object Binary (SOB) file. Linking converts a SOB and its sub-SOBs into an executable binary image.<br /></div>
<div>
<h3><a name="TOC-Compiling"></a>Compiling</h3></div>
<div>The Sphinx "compiler" proper actually consists of two programs, <a href="http://www.sphinxcompiler.com/Home/sphinx-documentation/reference/lexbin">lex.bin</a> and <a href="http://www.sphinxcompiler.com/Home/sphinx-documentation/reference/codegenbin">codegen.bin</a>, but they work so closely together that they are best considered a unit. Lex.bin reads a .spn file, tokenizes it, and produces an intermediate .tok file. Codegen.bin reads the .tok file, parses it, and generates object code which it saves in a .sob file.</div>
<div> </div>
<div>A SOB contains the Spin bytecodes for the object's PUB and PRI methods. In addition, it contains a list of the object's <i>imports</i> (sub-objects) and its <i>exports</i> (constants and PUB method signatures). A SOB is the compiled essence of an object. As far as Sphinx is concerned, a SOB contains the same information as its corresponding Spin file, just in convenient binary form. </div>
<div> </div>
<div>The compiler only compiles a single .spn file at a time. If the .spn file contains a sub-object, the compiler reads the .sob file for that sub-object and retrieves its exported information. This gives the compiler enough information to compile the .spn file without having to compile additional .spn files.</div>
<div> </div>
<div>This also means that programs have to be compiled from the bottom up. That is, sub-objects have to be compiled before any containing objects are compiled.</div>
<div> </div>
<div>Consider a simple program that prints "Hello, world" on the screen. The top object, <i>hello</i>, contains a sub-object, <i>tv_text</i>. <i>Tv_text</i> in turn contains sub-object <i>tv</i>. When you compile hello.spn, the compiler will need to read tv_text.sob, so you have to have compiled tv_text.spn beforehand. Similarly, before compiling tv_text.spn, you must compile tv.spn to produce tv.sob. So to compile <i>hello</i> from a standing start you must issue these commands:</div>
<div><font face="courier new,monospace">c tv</font></div>
<div><font face="courier new,monospace">c tv_text</font></div>
<div><font face="courier new,monospace">cl hello</font></div>
<div><font face="arial,sans-serif"> </font></div>
<div>Of course, subsequently you will not have to compile all three objects every time, just the objects that change.</div>
<div>
<h3><a name="TOC-Linking"></a>Linking</h3></div>
<div>You invoke the linker (<a href="http://www.sphinxcompiler.com/Home/sphinx-documentation/reference/linkbin">link.bin</a>) with the name of the top-level object. The linker reads the top-level SOB and goes through its list of imports (in other words, its sub-objects). The linker recursively reads the sub-SOBs and their sub-SOBs.</div>
<div> </div>
<div>Once all the SOBs are read, the linker determines how it will lay out all the objects' bytecode in memory and adjusts the various inter-object pointers so that they all refer to one another correctly. Then it writes an executable binary image (.bin file).</div><span lang="EN">
<h3><a name="TOC-Timestamps"></a>Timestamps</h3></span>
<div>Consider the following situation:
<ol>
<li>sub.spn is compiled, producing sub.sob.</li>
<li>top.spn is compiled using sub.sob, producing top.sob.</li>
<li>sub.spn is modified and recompiled, producing a new sub.sob.</li></ol>
<div>Now the top SOB is based on an old version of the sub-SOB. When the objects are linked, the resulting executable file may well fail because of that version mismatch.</div>
<div> </div>
<div>In order to detect such version mismatches, Sphinx maintains a 32-bit "timestamp" in a file named timestmp.d8a. Every time you compile an object, Sphinx increments the timestamp and stores it in the .sob file. (Of course an actual timestamp could be used, but Sphinx takes this approach so as not to require a real-time clock.)</div>
<div> </div>
<div>The linker compares timestamps and warns if any object being linked is out of date with respect to a sub-object.</div>
<div> </div>
<div>Note that this timestamp mechanism cannot detect when a .sob file is out of date with respect to its .spn counterpart. That is, Sphinx cannot tell if a .spn file has been modified after being compiled. If you edit a source file, it is your responsibility to remember to compile it.</div></div>
<div> </div>
<div style="text-align:right">Next: <a href="http://www.sphinxcompiler.com/Home/sphinx-documentation/the-sphinx-operating-environment">The Sphinx operating environment</a></div></div></td></tr></tbody></table>
</div>
</div>
<div id="sites-canvas-bottom-panel">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
<div id="sites-chrome-footer-wrapper">
<div id="sites-chrome-footer-wrapper-inside">
<div id="sites-chrome-footer">
</div>
</div>
</div>
</div>
</div>
<div xmlns="http://www.w3.org/1999/xhtml" class="sites-adminfooter">
<p>
 
<a href="https://www.google.com/a/UniversalLogin?continue=http%3A%2F%2Fsites.google.com%2Fsite%2Fsphinxcompiler%2FHome%2Fsphinx-documentation%2Fsobstory&amp;service=jotspot" class="sites-system-link">Anmelden</a>
 
<a href="/system/app/pages/recentChanges" rel="nofollow" class="sites-system-link">Site-Aktivität in letzter Zeit</a>
 
<a href="javascript:void(window.open('http://www.google.com/sites/help/intl/de/terms.html'))" class="sites-system-link">Nutzungsbedingungen</a>
 
<a href="/system/app/pages/reportAbuse?src=/Home/sphinx-documentation/sobstory" rel="nofollow" target="_blank" class="sites-system-link">Missbrauch melden</a>
 
<a href="javascript:;" onclick="window.open(webspace.printUrl)" class="sites-system-link">Seite drucken</a>
 | 
<b class="powered-by">Powered by <a href="http://sites.google.com">Google Sites</a></b>
</p>
</div>
</div>
<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
window.jstiming.load.tick('sjl');
</script>
<script xmlns="http://www.w3.org/1999/xhtml" src="http://www.gstatic.com/sites/p/934749/system/js/jot_min_view__en.js"></script>
<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
window.jstiming.load.tick('jl');
</script>
<script xmlns="http://www.w3.org/1999/xhtml">
if (editorResources) {
//<![CDATA[
editorResources.unshift('/system/app/css/overlay.css?cb=simplywhite100%250150goog-ws-left');
editorResources.unshift('/_/rsrc/1287429563000/system/app/themes/simplywhite/standard-css-simplywhite-ltr-ltr.css');
//]]>
}
</script>
<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
var searchBox = new gsites.Searchbox('sites-searchbox-search-button');
searchBox.initListeners();
searchBox.setScopesMenu(webspace.page.isSiteRtlLocale);
</script>
<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
gsites.HoverPopupMenu.createHoverPopupMenu('sites-header-nav-dropdown');
</script>
<script xmlns="http://www.w3.org/1999/xhtml">
window.onload = function() {
var loadTimer = window.jstiming.load;
loadTimer.tick("ol");
loadTimer["name"] = "load," + webspace.page.type;
window.jstiming.report(loadTimer);
}
</script>
<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript">
JOT_insertAnalyticsCode(false);
</script>
<script xmlns="http://www.w3.org/1999/xhtml">
JOT_insertTranslateCode('de', 'en');
</script>
<script xmlns="http://www.w3.org/1999/xhtml" type="text/javascript" defer="true">
//<![CDATA[
// Fires delayed events.
(function() {
JOT_fullyLoaded = true;
var delayedEvents = JOT_delayedEvents;
for (var x = 0; x < delayedEvents.length; x++) {
var event = delayedEvents[x];
JOT_postEvent(event.eventName, event.eventSrc, event.payload);
}
JOT_delayedEvents = null;
JOT_postEvent('pageLoaded');
})();
// Decorate any fastUI buttons on the page with a class of 'goog-button'.
if (webspace.user.hasWriteAccess) {
JOT_decorateButtons();
}
//]]>
</script>
<div id="server-timer-div" style="display:none"> </div>
<script>
window.jstiming.load.tick('render');
</script>
</body>
</html>