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

📄 language.values.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 5 页
字号:
VALIGN="TOP">logical and</TD></TR><TR><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">4</TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP"><TTCLASS="LITERAL">||</TT></TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">logical or</TD></TR><TR><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">3</TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP"><TTCLASS="LITERAL">xor, eqv</TT></TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">logical equivalance</TD></TR><TR><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">2</TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP"><TTCLASS="LITERAL">implies</TT></TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">logical implication</TD></TR><TR><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">1</TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP"><TTCLASS="LITERAL">? :</TT></TD><TDWIDTH="33%"ALIGN="CENTER"VALIGN="TOP">conditional</TD></TR></TBODY></TABLE><P></P></DIV><P>Function calls have the usual format of a name, an opening bracket,one or more arguments separated by commas, and a closing bracket. Forexample:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { !is_substr(CYGBLD_GLOBAL_CFLAGS, " -fno-rtti") }</PRE></TD></TR></TABLE><P>Functions will differ in the number of arguments and may imposerestrictions on some or all of their arguments. For example it may benecessary for the first argument to be a reference to a configurationoption. The available functions are described in <AHREF="language.values.html#LANGUAGE.FUNCTIONS">the Section called <I>Functions</I></A>. </P><P>The logical <TTCLASS="LITERAL">xor</TT> operator evaluates to true ifeither the left hand side or the right hand side but not both evaluateto true The logical <TTCLASS="LITERAL">eqv</TT> operator evaluates to trueif both the left and right hand sides evaluate to true, or if bothevaluate to false. The <TTCLASS="LITERAL">implies</TT> operator evaluatesto true either if the left hand side is false or if the right handside is true, in other words <TTCLASS="LITERAL">A&nbsp;implies&nbsp;B</TT>has the same meaning as <TTCLASS="LITERAL">!A&nbsp;||&nbsp;B</TT>. Anexample use would be:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires { is_active(CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE) implies                   (CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE &#62;= (16 * 1024)) }</PRE></TD></TR></TABLE><P>This constraint would be satisfied if either the support for a mainstack size is disabled, or if that stack is at least 16K. However ifsuch a stack were in use but was too small, a conflict would be raised.</P><P>A valid <SPANCLASS="APPLICATION">CDL</SPAN> identifier in an expression, for example<TTCLASS="VARNAME">CYGGLO_SPEED</TT>, will be interpreted as a reference toa configuration option by that name. The option does not have to beloaded into the current configuration. When the component frameworkevaluates the expression it will substitute in a suitable value thatdepends on whether or not the option is loaded, active, and enabled.The exact rules are described in <AHREF="language.values.html#LANGUAGE.VALUES.VALUE">the Section called <I>Option Values</I></A>.</P><P>A constant string is any sequence of characters enclosed in quotes.Care has to be taken that these quotes are not stripped off by the<SPANCLASS="APPLICATION">Tcl</SPAN> interpreter before the <SPANCLASS="APPLICATION">CDL</SPAN> expression parser sees them.Consider the following:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    default_value "RAM"</PRE></TD></TR></TABLE><P>The quote marks will be stripped before the <SPANCLASS="APPLICATION">CDL</SPAN> expression parsersees the data, so the expression will be interpreted as a reference toa configuration option <TTCLASS="VARNAME">RAM</TT>. There is unlikely to besuch an option, so the actual default value will be<TTCLASS="LITERAL">0</TT>. Careful use of braces or other <SPANCLASS="APPLICATION">Tcl</SPAN> quotingmechanisms can be used to avoid such problems.</P><P>		String constants consist of the data inside the quotes. If the dataitself needs to contain quote characters then appropriate quoting isagain necessary, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    default_value { "\"/dev/ser0\"" }</PRE></TD></TR></TABLE><P>An integer constant consists of a sequence of digits, optionallypreceeded with the unary <TTCLASS="LITERAL">+</TT> or <TTCLASS="LITERAL">-</TT>operators. As usual the sequence <TTCLASS="LITERAL">0x</TT> or<TTCLASS="LITERAL">0X</TT> can be used for hexadecimal data, and a leading<TTCLASS="LITERAL">0</TT> indicates octal data. Internally the componentframework uses 64-bit arithmetic for integer data. If a constant istoo large then double precision arithmetic will be used instead.Traditional syntax is also used for double precision numbers, forexample <TTCLASS="LITERAL">3.141592</TT> or <TTCLASS="LITERAL">-3E6</TT>. </P><P>Of course this is not completely accurate: <SPANCLASS="APPLICATION">CDL</SPAN> is not a typedlanguage, all data is treated as if it were a string. For example thefollowing two lines are equivalent:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">    requires CYGNUM_UITRON_SEMAS &#62; 10    requires { CYGNUM_UITRON_SEMAS &#62; "10" }</PRE></TD></TR></TABLE><P>When an expression gets evaluated the operators will attemptappropriate conversions. The <TTCLASS="LITERAL">&gt;</TT> comparisonoperator can be used on either integer or double precision numbers, soit will begin by attempting a string to integer conversion of bothoperands. If that fails it will attempt string to double conversions.If that fails as well then the component framework will report aconflict, an evaluation exception. If the conversions from string tointeger are successful then the result will be either the string<TTCLASS="LITERAL">0</TT> or the string <TTCLASS="LITERAL">1</TT>, both of whichcan be converted to integers or doubles as required.</P><P>It is worth noting that the expression<TTCLASS="LITERAL">CYGNUM_UITRON_SEMAS&nbsp;&gt;10</TT> is not ambiguous.<SPANCLASS="APPLICATION">CDL</SPAN> identifiers can never begin with a digit, so it is not possiblefor <TTCLASS="LITERAL">10</TT> to be misinterpreted as a reference to anidentifier instead of as a string.</P><P>Of course the implementation is slightly different again. The <SPANCLASS="APPLICATION">CDL</SPAN>language definition is such that all data is treated as if it were astring, with conversions to integer, double or boolean as and whenrequired. The implementation is allowed to avoid conversions untilthey are necessary. For example, given<TTCLASS="LITERAL">CYGNUM_UITRON_SEMAS&nbsp;&gt;&nbsp;10</TT> theexpression parsing code will perform an immediate conversion fromstring to integer, storing the integer representation, and there is noneed for a conversion by the comparison operator when the expressiongets evaluated. Given<TTCLASS="LITERAL">{&nbsp;CYGNUM_UITRON_SEMAS&nbsp;&gt;&nbsp;"10"&nbsp;}</TT>the parsing code will store the string representation and a conversionhappens the first time the expression is evaluated. All of this is animplementation detail, and does not affect the semantics of thelanguage. </P><P>Different operators have different requirements, for example thebitwise or operator only makes sense if both operands have an integerrepresentation. For operators which can work with either integer ordouble precision numbers, integer arithmetic will be preferred.</P><P>The following operators only accept integer operands:unary <TTCLASS="LITERAL">~</TT> (bitwise not), the shift operators<TTCLASS="LITERAL">&lt;&lt;</TT> and <TTCLASS="LITERAL">&gt;&gt;</TT>, and thebitwise operators <TTCLASS="LITERAL">&#38;</TT>, <TTCLASS="LITERAL">|</TT> and<TTCLASS="LITERAL">^</TT>.</P><P>The following operators will attempt integer arithmetic first, thendouble precision arithmetic: unary <TTCLASS="LITERAL">-</TT>,the arithmetic operators <TTCLASS="LITERAL">+</TT>, <TTCLASS="LITERAL">-</TT>,<TTCLASS="LITERAL">*</TT>, <TTCLASS="LITERAL">/</TT>, and <TTCLASS="LITERAL">%</TT>;and the comparision operators <TTCLASS="LITERAL">&lt;</TT>,<TTCLASS="LITERAL">&lt;=</TT>, <TTCLASS="LITERAL">&gt;</TT> and<TTCLASS="LITERAL">&gt;=</TT>. </P><P>The equality <TTCLASS="LITERAL">==</TT> and inequality<TTCLASS="LITERAL">!=</TT> operators will first attempt integer conversionand comparison. If that fails then double precision will be attempted(although arguably using these operators on double precision data isnot sensible). As a last resort string comparison will be used.</P><P>The operators <TTCLASS="LITERAL">!</TT>, <TTCLASS="LITERAL">&#38;&#38;</TT> and<TTCLASS="LITERAL">||</TT> all work with boolean data. Any string that canbe converted to the integer <TTCLASS="LITERAL">0</TT> or the double<TTCLASS="LITERAL">0.0</TT> is treated as false, as is the empty string orthe constant string <TTCLASS="LITERAL">false</TT>. Anything else isinterpreted as true. The result is either <TTCLASS="LITERAL">0</TT> or<TTCLASS="LITERAL">1</TT>.</P><P>The conditional operator <TTCLASS="LITERAL">?&nbsp;:</TT> will interpretits first operand as a boolean. It does not perform any processing onthe second or third operands.</P><P>In practice it is rarely necessary to worry about any of thesedetails. In nearly every case <SPANCLASS="APPLICATION">CDL</SPAN> expressions just work as expected,and there is no need to understand the full details.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>The current expression syntax does not meet all the needs of componentwriters. Some future enhancements will definitely be made, others aremore controversial. The list includes the following:</P><P></P><OLTYPE="1"><LI><P>An option's value is determined by several different factors: whetheror not it is loaded, whether or not it is active, whether or not it isenabled, and the data part. Currently there is no way of queryingthese individually. This is very significant in the context of optionswith the <TTCLASS="LITERAL">bool</TT> or <TTCLASS="LITERAL">booldata</TT>flavors, because there is no way of distinguishing between the optionbeing absent/inactive/disabled or it being enabled with a data fieldof <TTCLASS="LITERAL">0</TT>. There should be unary operators that allowany of the factors to be checked.</P></LI><LI><P>Only the <TTCLASS="LITERAL">==</TT> and <TTCLASS="LITERAL">!=</TT> operators canbe used for string data. More string-related facilities are needed.</P></LI><LI><P>An implies operator would be useful for many goal expression, where<TTCLASS="LITERAL">A&nbsp;implies&nbsp;B</TT> is equivalent to<TTCLASS="LITERAL">!A&nbsp;||B</TT>.</P></LI><LI><P>Similarly there is inadequate support for lists. On occasion it wouldbe useful to write expressions involving say the list of implementorsof a given CDL interface, for example a sensible default value couldbe the first implementor. Associated with this is a need for anindirection operator.</P></LI><LI><P>Arguably extending the basic <SPANCLASS="APPLICATION">CDL</SPAN> expression syntax with lots of newoperators is unnecessary, instead expressions should just support<SPANCLASS="APPLICATION">Tcl</SPAN> command substitution and then component writers could escapeinto <SPANCLASS="APPLICATION">Tcl</SPAN> scripts for complicated operations. This has some majordisadvantages. First, the inference engine would no longer have anysensible way of interpreting an expression to resolve a conflict.Second, the component framework's value propagation code keeps trackof which options get referenced in which expressions and avoidsunnecessary re-evaluation of expressions; if expressions can involvearbitrary <SPANCLASS="APPLICATION">Tcl</SPAN> code then there is no simple way to eliminateunnecessary recalculations, with a potentially major impact onperformance.</P></LI></OL></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>The current implementation of the component framework uses 64 bitarithmetic on all host platforms. Although this is adequate forcurrent target architectures, it may cause problems in future. At somestage it is likely that an arbitrary precision integer arithmeticpackage will be used instead.</P></BLOCKQUOTE></DIV></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><A

⌨️ 快捷键说明

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