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> bool, void, byte, schar, double, <br> float, sbyte, char, ushort, short, <br> longlong, ulong, ulonglong, long<br><br>?<br><br><br>
<div><span class="gmail_quote">2006/7/19, nicolas cellier <<a href="mailto:ncellier@ifrance.com">ncellier@ifrance.com</a>>:</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>> Andreas Raab a écrit :<br>> > Since this is the second time you're posting a question in this area<br>> > (which makes me assume that you're actually interested in getting an
<br>> > answer) I'll point you gently to:<br>> ><br>> > <a href="http://linuxmafia.com/faq/Essays/smart-questions.html">http://linuxmafia.com/faq/Essays/smart-questions.html</a><br>> ><br>> > Please read it and note in particular the parts about "Be precise and
<br>> > informative about your problem" and "Be explicit about your question".<br>><br>> ok sorry.<br>><br>> So what the ExternalType served for?<br>><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>> I don't understand why you have to ask in 2 different way the<br>> ExternalType (xType := descriptorClass atomicTypeNamed: here and xType
<br>><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>> := descriptorClass structTypeNamed: sym)?<br>><br>
> 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>><br>> > Cheers,<br>> > - Andreas<br>> ><br>> > mathieu wrote:
<br>> >> Hi,<br>> >><br>> >> I was wondering how the type was handle when apicall or cdecl occur.<br>> >> I have read how it is parse by the compiler and don't understand the<br>> >> following:
<br>> >><br>> >> ======================================<br>> >> Parser>>externalType: descriptorClass<br>> >> "Parse an return an external type"<br>> >><br>> >> | xType |
<br>> >><br>> >> xType _ descriptorClass atomicTypeNamed: here.<br>> >> xType == nil ifTrue:["Look up from class scope"<br>> >> *here* Symbol hasInterned: here ifTrue:[:sym|<br>
> >> *here* xType _ descriptorClass structTypeNamed: sym]].<br>> >> xType == nil ifTrue:[<br>> >> "Raise an error if user is there"<br>> >> *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>> >> "otherwise go over it silently"
<br>> >> *here* xType _ descriptorClass forceTypeNamed: here].<br>> >> self advance.<br>> >> (self matchToken:#*)<br>> >> ifTrue:[^xType asPointerType]<br>> >> ifFalse:[^xType]
<br>> >> =============================================<br>> >><br>> >> So if somebody can explain it to me thanks :)<br>> >><br>> >> Math<br><br><br></blockquote></div><br>