VM Maker: VMMaker.oscog-eem.2896.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMaker.oscog-eem.2896.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2896.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2896
Author: eem
Time: 24 November 2020, 7:08:08.082966 pm
UUID: 0f15d287-0675-49c0-8fed-925890a76ffc
Ancestors: VMMaker.oscog-eem.2895

An alloca version of stackStringValue: (stackEphemeralStringValue:) could be generally useful.

=============== Diff against VMMaker.oscog-eem.2895 ===============

Item was added:
+ ----- Method: InterpreterPlugin>>stackEphemeralStringValue: (in category 'API access') -----
+ stackEphemeralStringValue: index
+ "Convenience to answer a given argument as a C string using stack allocation.
+ Fails if the argument is not a string or there is no memory."
+ <returnTypeC: #'char *'>
+ <inline: #always>
+ | obj sz dstPtr |
+ <var: 'dstPtr' type: #'char *'>
+ obj := interpreterProxy stackValue: index.
+ (interpreterProxy isBytes: obj) ifFalse:
+ [interpreterProxy primitiveFailFor: PrimErrBadArgument.
+ ^nil].
+ sz := interpreterProxy byteSizeOf: obj.
+ dstPtr := self alloca: sz+1.
+ dstPtr ifNil:
+ [interpreterProxy primitiveFailFor: PrimErrNoCMemory.
+ ^nil].
+ self memcpy: dstPtr _: (interpreterProxy firstIndexableField: obj) _: sz.
+ dstPtr at: sz put: 0.
+ ^dstPtr!