📄 c-shell8.html
字号:
<div class="CellBody"><a name="93841"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93843"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93845"> </a>Look up <b class="symbol_lc">dir</b> (fails).</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93847"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93849"> </a>Request a new symbol table entry <b class="symbol_lc">dir</b>. </div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93851"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93853"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93855"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93857"> </a>Define <b class="symbol_lc">dir</b>; return symbol <b class="symbol_lc">D</b>.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93859"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93861"> </a>Parse the assignment <br><b class="symbol_lc">D=C</b>.</div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93863"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93865"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93867"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93869"> </a>Allocate agent-pool memory for the value of <b class="symbol_lc">dir</b>. </div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93871"> </a></div></td><td width="10"> </td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="93873"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93875"> </a></div></td><td width="10"> </td><td colspan=1 rowspan=1><div class="CellBody"><a name="93877"> </a>Write the value of <b class="symbol_lc">dir</b>. </div></td><td width="10"> </td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></b></li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="89167"> </a>The first access to server and agent is to allocate storage for the string <b>"/myDev/myFile"</b> on the target and store it there, so that VxWorks subroutines (notably <b class="routine"><i class="routine">opendir</i></b><b>( )</b> in this case) have access to it. There is a pool of target memory reserved for host interactions. Because this pool is reserved, it can be managed from the host system. The server allocates the required memory, and informs the shell of its location; the shell then issues the requests to actually copy the string to that memory. This request reaches the agent on the target, and it writes the 14 bytes (including the terminating null) there.</p><dd><p class="Body"><a name="89169"> </a>The shell's C-expression interpreter must now determine what the name <b class="symbol_lc">opendir</b> represents. Because <b class="routine"><i class="routine">opendir</i></b><b>( )</b> is not one of the shell's own commands, the shell looks up the symbol (through the target server) in the symbol table.</p><dd><p class="Body"><a name="89172"> </a>The C interpreter now needs to evaluate the function call to <b class="routine"><i class="routine">opendir</i></b><b>( )</b> with the particular argument specified, now represented by a memory location on the target. It instructs the agent (through the server) to spawn a task on the target for that purpose, and awaits the result.</p><dd><p class="Body"><a name="89173"> </a>As before, the C interpreter looks up a symbol name (<b class="symbol_lc">dir</b>) through the target server; when the name turns out to be undefined, it instructs the target server to allocate storage for a new <b class="keyword">int</b> and to make an entry pointing to it with the name <b class="symbol_lc">dir</b> in the symbol table. Again these symbol-table manipulations take place entirely on the host.</p><dd><p class="Body"><a name="89174"> </a>The interpreter now has an address (in target memory) corresponding to <b class="symbol_lc">dir</b>, on the left of the assignment statement; and it has the value returned by <b class="routine"><i class="routine">opendir</i></b><b>( )</b>, on the right of the assignment statement. It instructs the agent (again, through the server) to record the result at the <b class="symbol_lc">dir</b> address, and evaluation of the statement is complete. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="89177">6.8.2 Shell Components</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89179"> </a>The Tornado shell includes two interpreters, a common front end for command entry and history, and a back end that connects the shell to the global Tornado environment to communicate with the target server. <a href="c-shell8.html#89186">Figure 6-4</a> illustrates these components:<div class="frame"><h4 class="EntityTitle"><a name="89186"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6-4: Components of the Tornado Shell</font></a></h4><dl class="margin"><div class="Anchor"><a name="89214"> </a><img class="figure" border="0" src="images/c-shella2.gif"></div></dl></div></p></dl><dl class="margin"><dd><div class="Item"><a name="89215"> </a>Line Editing</div><dl class="margin"><dd><div class="Indent"><a name="89216"> </a>The line-editing and command history facilities are designed to be unobtrusive, and support your access to the interpreters. <a href="c-shell5.html#100817"><i class="title">6.5 Shell Line Editing</i></a> describes the <b class="command">vi</b>-like editing and history front end.</div><br></dl><dd><div class="Item"><a name="89220"> </a>C-Expression Interpreter</div><dl class="margin"><dd><div class="Indent"><a name="89221"> </a>The most visible component is the C-expression interpreter, because it is the interface that most closely resembles the application programming environment. The bulk of this chapter describes that interpreter.</div><br></dl><dd><div class="Item"><a name="89222"> </a>Tcl Interpreter</div><dl class="margin"><dd><div class="Indent"><a name="89223"> </a>An interface for extending the shell or automating shell interactions, described in <a href="c-shell7.html#86665"><i class="title">6.7 Tcl: Shell Interpretation</i></a>.</div><br></dl><dd><div class="Item"><a name="89227"> </a>WTX Tcl</div><dl class="margin"><dd><div class="Indent"><a name="89366"> </a>The back-end mechanism that ties together all of Tornado; the Wind River Systems Tool Exchange protocol, implemented as a set of Tcl extensions.</div><br></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="91659">6.8.3 Layers of Interpretation</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="92092"> </a>In daily use, the shell seems to be a seamless environment; but in fact, the characters you type in WindSh go through several layers of interpretation, as illustrated by <a href="c-shell8.html#91674">Figure 6-5</a>. First, input is examined for special editing keystrokes (described in <a href="c-shell5.html#100817"><i class="title">6.5 Shell Line Editing</i></a>). Then as much interpretation as possible is done in WindSh itself. In particular, execution of any subroutine is first attempted in the shell itself; if a shell built-in (also called a <i class="term">primitive</i>) with that name exists, the built-in runs without any further checking. Only when a subroutine call does not match any shell built-ins does WindSh call a target routine. See <a href="c-shell2.html#99723"><i class="title">6.2.3 Invoking Built-In Shell Routines</i></a> for more information. For a list of all WindSh primitives, see <a href="c-shell3.html#96869"><i class="title">Table 6-13List of WindSh Commands</i></a>.<div class="frame"><h4 class="EntityTitle"><a name="91674"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6-5: Layers of Interpretation in the Shell</font></a></h4><dl class="margin"><div class="Anchor"><a name="91771"> </a><img class="figure" border="0" src="images/c-shella6.gif"></div></dl></div> </p><dd><p class="Body"><a name="83403"> </a></p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-shell.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-shell7.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-browser.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -