VM Maker: VMMaker.oscog-eem.2368.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.2368.mcz

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

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

Name: VMMaker.oscog-eem.2368
Author: eem
Time: 20 April 2018, 9:42:35.891238 am
UUID: aeb838a7-9c90-4db7-95a1-41a95014cee8
Ancestors: VMMaker.oscog-sk.2367

Check collation order byte array size in new string compare primitive as per Levente's suggestion.

=============== Diff against VMMaker.oscog-sk.2367 ===============

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveCompareWith (in category 'string primitives') -----
  primitiveCompareWith
  "<string1> primitiveCompareWith: string2 [collated: order] "
  <export: true>
 
  | string1 string2 order strLength1 strLength2 result |
 
  "1 - fetch the parameters from the stack"
+ argumentCount = 1 ifFalse:
+ [argumentCount ~= 2 ifTrue:
+ [^self primitiveFailFor: PrimErrBadNumArgs].
+ order := self stackTop.
+ ((objectMemory isBytes: order)
+ and: [(objectMemory numBytesOfBytes: order) = 256]) ifFalse:
+ [^self primitiveFailFor: PrimErrBadArgument]].
- (argumentCount = 0 or: [argumentCount > 2]) ifTrue:
- [^self primitiveFailFor: PrimErrBadNumArgs].
- argumentCount = 1
- ifFalse: "argCount must be 2"
- [order := self stackTop.
- (objectMemory isBytes: order) ifFalse: [^self primitiveFailFor: PrimErrBadArgument]].
  string1 := self stackValue: argumentCount.
  string2 := self stackValue: argumentCount - 1.
 
  "2 - check their types - all parameters are ByteObject"
  ((objectMemory isBytes: string1)
+ and: [objectMemory isBytes: string2]) ifFalse:
+ [^self primitiveFailFor: PrimErrBadArgument].
- and: [objectMemory isBytes: string2 ])
- ifFalse:
- [^self primitiveFailFor: PrimErrBadArgument].
 
  "3 - compare the strings"
  strLength1 := objectMemory numBytesOfBytes: string1.
  strLength2 := objectMemory numBytesOfBytes: string2.
  result := order
+ ifNil: [self rawCompare: string1 length: strLength1 with: string2 length: strLength2 accessBlock:
+ [:str :index | objectMemory fetchByte: index ofObject: str ]]
- ifNil: [self rawCompare: string1 length: strLength1 with: string2 length: strLength2 accessBlock: [:str :index | objectMemory fetchByte: index ofObject: str ]]
  ifNotNil:
+ [self rawCompare: string1 length: strLength1 with: string2 length: strLength2 accessBlock:
+ [:str :index | objectMemory fetchByte: (objectMemory fetchByte: index ofObject: str) + 1 ofObject: order ]].
- [self rawCompare: string1 length: strLength1 with: string2 length: strLength2 accessBlock: [:str :index | objectMemory fetchByte: (objectMemory fetchByte: index ofObject: str) +1 ofObject: order ]].
- self pop: argumentCount + 1 thenPush: (objectMemory integerObjectOf: result)
-
 
+ self methodReturnInteger: result
 
 
 
  !