From: "Walter Smith" <wrs@pobox.com>
Subject: Re: hints on special ref values
Newsgroups: comp.sys.newton.programmer
Date: Tue, 7 Sep 1999 10:35:09 -0700
Organization: Posted via Supernews, http://www.supernews.com
Path: newshost.dstc.edu.au!bunyip.cc.uq.edu.au!news1.optus.net.au!optus!ozemail.com.au!nsw.nntp.telstra.net!news.syd.connect.com.au!news.mel.connect.com.au!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.direct.ca!remarQ73!rQdQ!supernews.com!remarQ.com!corp.supernews.com!not-for-mail
Lines: 52
Message-ID: <rtaj89528os30@corp.supernews.com>
References: <o4ogfg5a3v.fsf@fig.dstc.edu.au>
X-Complaints-To: newsabuse@supernews.com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2918.2701
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2918.2701
X-IProxy-NNTP-Posting-Host: 216.39.145.132
Xref: newshost.dstc.edu.au comp.sys.newton.programmer:22935

David Arnold <arnold@fig.dstc.edu.au> wrote ...
> in disassembling some package files (package1, fast compression), i have
> come across some function frames with an unusual class values, and
> wondered if anyone knew what it might mean ...
>
> according to the bytecode interpreter spec in the apple formats doc, a
> function frame in a package must consist of
>
>   class: 'CodeBlock,
>   ...

The formats doc only documents the 1.0-style 'CodeBlock function format.
Nobody ever got around to documenting the 2.0 function format, which is what
you're seeing.

> however, i am seeing some frames with the class ref set to a Special,
> with a value of 0x32 ...

That's a 2.0-format bytecode function. The 2.0 interpreter has numerous
optimizations over the 1.0 version that required a slightly different
function format. A 2.0 argFrame contains only what's necessary to make
closures work. The _parent, _nextArgFrame, and _implementor slots can
contain NIL if the function doesn't use them. Most important, a 2.0 argFrame
will have a slot for a local variable only if the variable is referenced in
another function and so must be present in a closure. Purely local variables
are kept on the stack in 2.0.

> note also the curious numArgs value -- should it be only four?  with a
> flag bit set in the higher two bytes of the word?

NumArgs in a 2.0 function has two bitfields. The lower 14 bits gives the
number of arguments, and the upper 16 bits gives the number of locals to
allocate on the stack.

> and this frame has class ref == 0x232, and doesn't quite look like a
> function frame.  anyone recognise it?

That's a 2.0-format native function (the 1.0 equivalent would be a
'BinCFunction if I remember right). The code slot points to a binary object
with the code in it. The offset slot gives the relative entry point of the
function in that code.

- W

--
Walter Smith    wrs@pobox.com    http://www.pobox.com/wrs
I am speaking for myself, not my employer.





