<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<a class="moz-txt-link-freetext" href="http://sdmeta.gforge.inria.fr/FreeBooks/CollectiveNBlueBook/greenberg.pdf">http://sdmeta.gforge.inria.fr/FreeBooks/CollectiveNBlueBook/greenberg.pdf</a><br>
<br>
Write it in Smalltalk:<br>
<br>
#reverseInPlaceFrom:to:<br>
<br>
<meta charset="utf-8">
| temp |
<br>
0 to: to - from // 2 do:
<br>
[:index | temp ← self at: from + index.
<br>
self at: from + index put: (self at: to-index). <br>
self at: to-index put: temp]<br>
<br>
Re-write it as Slang: <br>
<br>
#primReverseFromto<br>
<br>
<meta charset="utf-8">
self export: true. <br>
self var: #rcvr declareC: 'int *rcvr'. <br>
to ← interpreterProxy stackIntegerValue: 0.
from ← interpreterProxy stackIntegerValue: 1. <br>
rcvrOop ← interpreterProxy stackObjectValue: 2. <br>
rcvr ← self
cCoerce: (interpreterProxy firstIndexableField: rcvrOop)
to: 'int *'. <br>
interpreterProxy success: (from >= 1 and: [from+1 <= to]).
interpreterProxy success: (to <= (interpreterProxy stSizeOf:
rcvrOop)). <br>
interpreterProxy failed ifTrue: [^nil]. <br>
rcvr ← rcvr - 1. "adjust for 1-based indexing."<br>
0 to: to-from/2 do:
<br>
[:index | t ← rcvr at: from + index. <br>
rcvr at: from + index put: (rcvr at: to-index). <br>
rcvr at: to-index put: t]. <br>
interpreterProxy pop: 3 thenPush: rcvrOop<br>
<br>
Or subclass the long lost TestCodeGenerator to do it for you!<br>
<br>
Chris<br>
<br>
For those of you watching at home, the article above has the
HelloWorld of plugins. Igor changed is slightly for a lecture in
2011 to make a plugin called TheUniversalAnswer. It returns 42. <br>
<br>
#answerSeventeen<br>
<br>
self export: true. <br>
interpreterProxy<br>
pop: 1<br>
thenPush: (interpreterProxy integerObjectOf: 17)<br>
<br>
All you need now is a compiling rig with two VMs and two images. <br>
The VM you start your VMMaker image with. The VM you compile from
the VMMaker source you just generated. <br>
And the pristine target image you start with the VM you just
compiled to prove it works. <br>
<br>
Your spiral into plugin compiling madness starts with this handy
script: <br>
<br>
<a class="moz-txt-link-freetext" href="http://lists.squeakfoundation.org/pipermail/squeak-dev/2012-October/166038.html">http://lists.squeakfoundation.org/pipermail/squeak-dev/2012-October/166038.html</a><br>
<br>
<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 2015-09-09 9:53 PM, David T. Lewis
wrote:<br>
</div>
<blockquote cite="mid:20150910015303.GA58560@shell.msen.com"
type="cite">
<pre wrap="">On Wed, Sep 09, 2015 at 11:17:08AM -0700, tim Rowledge wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I?m trying - and so far failing - to do what should surely be a very simple
thing. This isn?t a new situation? especially on unix.
I have a single C file with just two functions. I have a matching H file.
I want to make them into a dynamic library that I can call via FFI. This
really shouldn?t be rocket science stuff!
</pre>
</blockquote>
<pre wrap="">
<OT>
I assume there is some good reason that you would not do an end run
around all that rocket science and just write a plugin? After all, you
are the person who wrote the excellent early papers on how to extend the
VM with plugins, and most of what little I know of VMs came from reading
your early work on the topic.
I would hate to be the one to deny a masochist his private pleasures, but
really, why not not just do it the easy way?
</OT>
Dave
</pre>
</blockquote>
<br>
</body>
</html>