Ok thank a lot nicolas (in fact those ifNil: were boring me)<br><br>Now I understand the hasInterned:ifTrue: :).<br>I ask those question because I am adding this to the new compiler.<br><br>So I have to follow the same structur to get the ExternalType. But it seem to be not really pretty with nil value.
<br><br>Now I am writing the grammar so is the atomicType restrict to <br><br>&nbsp;bool,&nbsp; void,&nbsp; byte,&nbsp; schar,&nbsp; double, <br>&nbsp;float,&nbsp; sbyte,&nbsp; char,&nbsp; ushort,&nbsp; short, <br>&nbsp;longlong,&nbsp; ulong,&nbsp; ulonglong,&nbsp; long<br><br>?<br><br><br>
<div><span class="gmail_quote">2006/7/19, nicolas cellier &lt;<a href="mailto:ncellier@ifrance.com">ncellier@ifrance.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Le Mercredi 19 Juillet 2006 08:24, mathieu a écrit :<br>&gt; Andreas Raab a écrit :<br>&gt; &gt; Since this is the second time you're posting a question in this area<br>&gt; &gt; (which makes me assume that you're actually interested in getting an
<br>&gt; &gt; answer) I'll point you gently to:<br>&gt; &gt;<br>&gt; &gt; <a href="http://linuxmafia.com/faq/Essays/smart-questions.html">http://linuxmafia.com/faq/Essays/smart-questions.html</a><br>&gt; &gt;<br>&gt; &gt; Please read it and note in particular the parts about &quot;Be precise and
<br>&gt; &gt; informative about your problem&quot; and &quot;Be explicit about your question&quot;.<br>&gt;<br>&gt; ok sorry.<br>&gt;<br>&gt; So what the ExternalType served for?<br>&gt;<br><br>ExternalType is Smalltalk class used to handle external function argument
<br>types and function return types. It is necessary to handle automatic<br>conversions from Smalltalk Objects to C Objects et vice et versa.<br><br>&gt; I don't understand why you have to ask in 2 different way the<br>&gt; ExternalType (xType := descriptorClass atomicTypeNamed: here and xType
<br>&gt;<br><br>This is a list of tests:<br><br>1) check if there is an atomic type whose name is here (atomic types are non<br>composed types like float double short long int etc...)<br>2) if the answer is nil, then here is not an atomic type, try to see if it is
<br>the name of a structure type...<br><br>You must understand that returning nil is a simple way to indicate a failure<br>(a kind of C-style programming).<br><br>&gt; := descriptorClass structTypeNamed: sym)?<br>&gt;<br>
&gt; What the mssage #hasInterned:ifTrue: served for in this case?<br><br>here is aString (a token parsed by the parser). It should be the name of a<br>known type.<br><br>If here is a known type, then corresponding symbol (here asSymbol) must
<br>already exist in the image.<br><br>That is exactly what #hasInterned:ifTrue: is cheking: does a Symbol having<br>same characters as here exist in the image, and if true, it will try to set<br>the type to be a structure...
<br><br>Once again, structTypeNamed: will do the job of checking if (here asSymbol) is<br>really the name of an ExternalStructure (most Symbols are not the name of a<br>structure). If not, it will answer nil.<br><br>If there is no symbol like here, then we are sure that there is currently no
<br>such ExternalStructure declared in the Smalltalk image, and it's not even<br>necessary to check if an ExternalStructure does have that name.<br><br>&gt;<br>&gt; &gt; Cheers,<br>&gt; &gt; - Andreas<br>&gt; &gt;<br>&gt; &gt; mathieu wrote:
<br>&gt; &gt;&gt; Hi,<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; I was wondering how the type was handle when apicall or cdecl occur.<br>&gt; &gt;&gt; I have read how it is parse by the compiler and don't understand the<br>&gt; &gt;&gt; following:
<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; ======================================<br>&gt; &gt;&gt; Parser&gt;&gt;externalType: descriptorClass<br>&gt; &gt;&gt; &quot;Parse an return an external type&quot;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; | xType |
<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; xType _ descriptorClass atomicTypeNamed: here.<br>&gt; &gt;&gt; xType == nil ifTrue:[&quot;Look up from class scope&quot;<br>&gt; &gt;&gt; *here* Symbol hasInterned: here ifTrue:[:sym|<br>
&gt; &gt;&gt; *here* xType _ descriptorClass structTypeNamed: sym]].<br>&gt; &gt;&gt; xType == nil ifTrue:[<br>&gt; &gt;&gt; &quot;Raise an error if user is there&quot;<br>&gt; &gt;&gt; *here* self interactive ifTrue:[^nil].
<br><br>An error is detected; no such named type does exist in the image, neither a<br>known atomic type, nor a known structure type:<br>If compilation isInteractive (that is user did select accept menu in the<br>browser), then it's better to warn the user because he is trying to enter
<br>some incorrect code. Answering nil here will be checked at upper level and<br>raise a SyntaxError notified to the user.<br><br>If not interactive (as for example he is loading code from a file, Monticello<br>or whatever source), it's bad to warn the user for something he is not
<br>responsible for. And maybe, the type is not known yet, but is defined further<br>in the file...<br>In this case, force the type to be recognized as a structure (I let you<br>inquire how).<br><br>&gt; &gt;&gt; &quot;otherwise go over it silently&quot;
<br>&gt; &gt;&gt; *here* xType _ descriptorClass forceTypeNamed: here].<br>&gt; &gt;&gt; self advance.<br>&gt; &gt;&gt; (self matchToken:#*)<br>&gt; &gt;&gt; ifTrue:[^xType asPointerType]<br>&gt; &gt;&gt; ifFalse:[^xType]
<br>&gt; &gt;&gt; =============================================<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; So if somebody can explain it to me thanks :)<br>&gt; &gt;&gt;<br>&gt; &gt;&gt; Math<br><br><br></blockquote></div><br>