⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-shell3.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    Shell   </title></head><body bgcolor="FFFFFF"><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-shell2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-shell4.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="91066">6.3  &nbsp;&nbsp;The Shell C-Expression Interpreter</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="91068"> </a>The C-expression interpreter is the most common command interface to the Tornado shell. This interpreter can evaluate almost any C expression interactively in the context of the attached target. This includes the ability to use variables and functions whose names are defined in the symbol table. Any command you type is interpreted as a C expression. The shell evaluates that expression and, if the expression so specifies, assigns the result to a variable.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="97118">6.3.1  &nbsp;&nbsp;Data Types</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84726"> </a>The most significant difference between the shell C-expression interpreter and a C compiler lies in the way that they handle data types. The shell does not accept any C declaration statements, and no data-type information is available in the symbol table. Instead, an expression's type is determined by the types of its terms.</p><dd><p class="Body"><a name="84727"> </a>Unless you use explicit type-casting, the shell makes the following assumptions about data types:</p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84728"> </a>In an assignment statement, the type of the left hand side is determined by the type of the right hand side.</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84729"> </a>If floating-point numbers and integers both appear in an arithmetic expression, the resulting type is a floating-point number. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84771"> </a>Data types are assigned to various elements as shown in <a href="c-shell3.html#84736">Table&nbsp;6-9</a>. <p class="table"><h4 class="EntityTitle"><a name="84736"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 6-9:&nbsp;&nbsp;<b></b>Shell C Interpreter Data-Type Assumptions</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84740"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Element</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84742"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Data Type</font></b></div></th><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84748"> </a>variable</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84750"> </a><b class="keyword">int</b> </div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84752"> </a>variable used as floating-point</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84754"> </a><b class="keyword">double</b></div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84756"> </a>return value of subroutine</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84758"> </a><b class="keyword">int</b></div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84760"> </a>constant with no decimal point</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84762"> </a><b class="keyword">int</b>/<b class="keyword">long</b></div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84764"> </a>constant with decimal point</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBody"><a name="84766"> </a><b class="keyword">double</b> </div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="84772"> </a>A constant or variable can be treated as a different type than what the shell assumes by explicitly specifying the type with the syntax of C type-casting. Functions that return values other than integers require a slightly different type-casting; see <a href="c-shell3.html#85146"><i class="title">Function Calls</i></a>. <a href="c-shell3.html#84782">Table&nbsp;6-10</a> shows the various data types available in the shell C interpreter, with examples of how they can be set and referenced.<p class="table"><h4 class="EntityTitle"><a name="84782"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 6-10:&nbsp;&nbsp;Data Types in the Shell C Interpreter</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84790"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Type</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeadingC" align="center"><a name="84792"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Bytes</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84794"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Set Variable</font></b></div></th><td width="10">&nbsp;</td><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="84796"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Display Variable</font></b></div></th><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=2><div class="CellBody"><a name="84798"> </a><b class="keyword">int</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=2><div class="CellBodyC" align="center"><a name="84800"> </a>4</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=2><pre class="CodeLeft"><b><a name="84802">x = 99</a></b></pre></td><td width="10">&nbsp;</td><td colspan=1 rowspan=2><pre class="CodeLeft"><b><a name="84805">x (int) x</a></b></pre></td><td width="10">&nbsp;</td></tr><tr valign="top"></tr><tr valign="top"><td colspan=1 rowspan=2><div class="CellBody"><a name="84815"> </a><b class="keyword">long</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=2><div class="CellBodyC" align="center"><a name="84817"> </a>4</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=2><pre class="CodeLeft"><b><a name="84819">x = 33 x = (long)33</a></b></pre></td><td width="10">&nbsp;</td><td colspan=1 rowspan=2><pre class="CodeLeft"><b><a name="84823">x (long) x</a></b></pre></td><td width="10">&nbsp;</td></tr><tr valign="top"></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="84833"> </a><b class="keyword">short</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="84835"> </a>2</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><pre class="CodeLeft"><b><a name="84837">x = (short)20</a></b></pre></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><pre class="CodeLeft"><b><a name="84839">(short) x</a></b></pre></td><td width="10">&nbsp;</td></tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -