<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Alistair,<div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 30, 2018 at 7:48 AM Alistair Grant <<a href="mailto:akgrant0710@gmail.com">akgrant0710@gmail.com</a>> wrote:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Hi Ben,<div dir="auto"><br></div><div dir="auto">Disclaimer: I haven't gone through the code, but this is my understanding.<br><br></div><div class="gmail_quote"><div dir="ltr">On Tue., 30 Oct. 2018, 14:26 Ben Coman, <<a href="mailto:btc@openinworld.com" target="_blank">btc@openinworld.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, 30 Oct 2018 at 20:22, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" rel="noreferrer" target="_blank">eliot.miranda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <div dir="auto">Hi Ben,<div dir="ltr"><br>On Oct 30, 2018, at 4:57 AM, Ben Coman <<a href="mailto:btc@openinworld.com" rel="noreferrer" target="_blank">btc@openinworld.com</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr"><span></span></div></blockquote><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div></div></div></blockquote><div><br></div>Those implementations can come later.  Right now the plugin doesn’t simulate anyway.  You’re right I could have written them then and there, but I would rather do real o es than simple failing stubs.  If I find that I can’t simulate without stubs I’ll add them.  Feel free to provide them if you’re motivated.  I should have just fixed the digitCompare: issue but got carried away...</div></blockquote><div><br></div><div>I'm still missing something basic, but guessing... the "inSmalltalk:" part is what is performed by the simulator?</div><div><br></div><div>and the "cCode:" is generated into a C-code-call that expects that function linked in from a library?</div><div><br></div><div>and now there is no simulation and "b3dxAllocateTexture:_:_:_:" is generated to C-code-call?</div><div><br></div><div>So is there a mechanism that any unknown message (i.e. "b3dxAllocateTexture:_:_:_:") is generated to a C-code-call?</div><div></div></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Not quite.  There is a table of special messages, e.g ifTrue:ifFalse: is converted to the normal C if else statement.</div><div dir="auto"><br></div><div dir="auto">Every other message send is converted to a function call.  The function is either internal, i.e. Supplied by another method, or external (which the linker should find).</div></div></blockquote><div><br></div><div>Very close!  This is TSendNode>>emitCCodeOn: aStream level: level generator: aCodeGen</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>"Emit the receiver as a statement."</div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>"If the selector is a built-in construct, translate it and return"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>(aCodeGen emitBuiltinConstructFor: self on: aStream level: level) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">             </span>["If it is a pointer dereference generate it"</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>(self emitCCodeAsFieldReferenceOn: aStream level: level generator: aCodeGen) ifFalse:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                  </span>["Otherwise generate the vanilla C function call."</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                   </span> self emitCCodeAsFunctionCallOn: aStream level: level generator: aCodeGen]]</div><div><br></div><div>The built-in constructs are many, but the ones that aren't arithmetic or a function call, or control (ifTrue: => if () { ...) are</div><div>1. cCode: stringOrBlock [inSmalltalk: ] => emit stringOrBlock</div><div>2. cPreprocessorDirective: => emit whatever the argument is literally (very similar to 1. but not indented)</div><div>3. cppIf:ifTrue:ifFalse: => #if EXPR ... #else ... #endif</div><div>4. addressOf: expr [put: block] => &expr</div><div>5. touch => nothing (allows referencing variables for 1.)</div><div>6. some unusual translations for shouldNotImplement, asInteger et al (see CCodeGenerator>>#initializeCTranslationDictionary)</div><div><br></div><div>Then field references are inst var accessors of instances of subclasses of VMStructType, which get translated into</div><div>    foo.bar</div><div>    foo.bar = expr</div><div>    foo->bar</div>    foo->bar = expr</div><div class="gmail_quote">depending on the type of foo.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Only after this do sends get mapped to function calls.</div><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="auto"><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><span style="font-family:sans-serif">Cheers,</span><br style="font-family:sans-serif"><span style="font-family:sans-serif">Alistair</span><br style="font-family:sans-serif"><span style="font-family:sans-serif">(on phone)</span><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div></div></div>
</blockquote></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div></div></div></div></div>