<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<p>Alright, Eliot! I finally got the changes made. You know that
time when you have 2 images and you do the work in one and forget,
then delete that one and have to recode all those changes?
Exactly.</p>
<p>Nonetheless, I got the changes made and did a test of creating a
ByteArray in a primitive/computation method:</p>
<blockquote>
<p>#fecAddOrSubtractPolySelfCoefficients:selfCount:otherCoefficients:otherCount:.
<br/>
</p>
</blockquote>
<p>In my case, I decided to create the result ByteArray in the
computation method and return the resultOop to the primitive for #methodReturnValue:.
Here is the primitive, followed by the computation method. This
seems to work as I compiled and tested it. One consideration is
that if we are in a primitive and call another, like happens in
the decode methods, then I must remember to #interpreterProxy
firstIndexableField: resultOop to access the array again (pass as
argument to yet another compute method, for instance). Is this the
best approach? </p>
<blockquote>
<p> resultOop := self <br/>
fecAddOrSubtractPolySelfCoefficients: selfCoefficients <br/>
selfCount: selfCount <br/>
otherCoefficients: otherCoefficients <br/>
otherCount: otherCount.<br/>
<br/>
^ interpreterProxy failed<br/>
ifTrue: [interpreterProxy primitiveFail]<br/>
ifFalse: [interpreterProxy methodReturnValue:
resultOop].<br/>
</p>
</blockquote>
<p>And the computation method</p>
<blockquote>
<p> resultOop := interpreterProxy <br/>
instantiateClass: interpreterProxy
classByteArray<br/>
indexableSize: (selfCount max: otherCount).<br/>
result := interpreterProxy firstIndexableField: resultOop.</p>
<p><br/>
^ resultOop<br/>
</p>
</blockquote>
<p><br/>
</p>
<div class="moz-signature">---<br/>
Kindly,<br/>
Robert<br/>
<br/>
<br/>
</div>
<div class="moz-cite-prefix">On 6/5/21 7:39 PM, Eliot Miranda wrote:<br/>
</div>
<blockquote type="cite" cite="mid:B46AC4BF-2F92-4B99-900B-F26E48B54D76@gmail.com">
<pre class="moz-quote-pre" wrap="">Hi Robert,
_,,,^..^,,,_ (phone)
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">On Jun 4, 2021, at 11:52 AM, Robert Withers <a class="moz-txt-link-rfc2396E" href="mailto:robert.withers@pm.me"><robert.withers@pm.me></a> wrote:
fieldSize := interpreterProxy stackIntegerValue: 1.
coefficientsOop := interpreterProxy stackObjectValue: 0.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">Since you check for isBytes: below you can use stackValue:. isBytes: can safely be passed any object, including immediates. So the stackObjectValue: call implies a redundant validation.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap=""> (interpreterProxy isIntegerValue: fieldSize)
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">This is implicit. stackIntegerValue: fails if the object is not a SmallInteger (retiring zero) and otherwise answers its integerValue. So you should check if stackIntegerValue: fails since its return value will always answer true to isIntegerValue:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap=""> (interpreterProxy isBytes: coefficientsOop)
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">I would write
fieldSize := interpreterProxy stackIntegerValue: 1.
coefficientsOop := interpreterProxy stackValue: 0.
(interpreterProxy failed not
and: [interpreterProxy isBytes: coefficientsOop])
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
or
fieldSizeOop := interpreterProxy stackValue: 1.
coefficientsOop := interpreterProxy stackValue: 0.
((interpreterProxy isIntegerObject: fieldSizeOop)
and: [interpreterProxy isBytes: coefficientsOop])
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
fieldSize := interpreterProxy integerValueOf: fieldSizeOop.
</pre>
</blockquote>
</body></html>