Alistair Grant uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-akg.2474.mcz ==================== Summary ==================== Name: VMMaker.oscog-akg.2474 Author: akg Time: 24 October 2018, 3:57:54.515846 pm UUID: 6f62ab11-b855-47bf-9371-dea8cc27067e Ancestors: VMMaker.oscog-akg.2473 VMClass>>memcpy:_:_: handle CugMethodSurrogates =============== Diff against VMMaker.oscog-akg.2473 =============== Item was added: + ----- Method: CogMethodSurrogate>>isVMSimulationAddress (in category 'testing') ----- + isVMSimulationAddress + "Answer a boolean indicating whether the receiver is a kind of address in the VM simulation" + + ^true! Item was added: + ----- Method: Object>>isVMSimulationAddress (in category '*VMMaker-testing') ----- + isVMSimulationAddress + "Answer a boolean indicating whether the receiver is a kind of address in the VM simulation" + + ^false! Item was changed: ----- Method: VMClass>>memcpy:_:_: (in category 'C library simulation') ----- memcpy: dest _: src _: bytes <doNotGenerate> "implementation of memcpy(3). N.B. If ranges overlap, must use memmove." + | getBlock setBlock source destination | - | getBlock setBlock | + source := src isVMSimulationAddress + ifTrue: [src asInteger] + ifFalse: [src]. + destination := dest isVMSimulationAddress + ifTrue: [dest asInteger] + ifFalse: [dest]. + (source isInteger and: [destination isInteger]) ifTrue: + [ self deny: ((destination <= source and: [destination + bytes > source]) + or: [source <= destination and: [source + bytes > destination]])]. - (src isInteger and: [dest isInteger]) ifTrue: - [ self deny: ((dest <= src and: [dest + bytes > src]) - or: [src <= dest and: [src + bytes > dest]])]. "Determine the source and destination access blocks based on the parameter type" + getBlock := source isCollection ifTrue: + [source isString ifTrue: - getBlock := src isCollection ifTrue: - [src isString ifTrue: "basicAt: answers integers" + [[ :idx | source basicAt: idx]] - [[ :idx | src basicAt: idx]] ifFalse: + [source class == ByteArray ifTrue: + [[ :idx | source at: idx]]]] - [src class == ByteArray ifTrue: - [[ :idx | src at: idx]]]] ifFalse: + [source isInteger ifTrue: + [[ :idx | self byteAt: source + idx - 1]] - [src isInteger ifTrue: - [[ :idx | self byteAt: src + idx - 1]] ifFalse: + [source isCArray ifTrue: + [[ :idx | source at: idx - 1]]]]. - [src isCArray ifTrue: - [[ :idx | src at: idx - 1]]]]. getBlock ifNil: [self error: 'unhandled type of source string']. + setBlock := destination isCollection ifTrue: + [destination isString ifTrue: - setBlock := dest isCollection ifTrue: - [dest isString ifTrue: "basicAt:put: stores integers" + [[ :idx | destination basicAt: idx put: (getBlock value: idx)]] - [[ :idx | dest basicAt: idx put: (getBlock value: idx)]] ifFalse: + [destination class == ByteArray ifTrue: + [[ :idx | destination at: idx put: (getBlock value: idx)]]]] - [dest class == ByteArray ifTrue: - [[ :idx | dest at: idx put: (getBlock value: idx)]]]] ifFalse: + [destination isInteger ifTrue: + [[ :idx | self byteAt: destination + idx - 1 put: (getBlock value: idx)]] - [dest isInteger ifTrue: - [[ :idx | self byteAt: dest + idx - 1 put: (getBlock value: idx)]] ifFalse: + [destination isCArray ifTrue: + [[ :idx | destination at: idx - 1 put: (getBlock value: idx)]]]]. - [dest isCArray ifTrue: - [[ :idx | dest at: idx - 1 put: (getBlock value: idx)]]]]. setBlock ifNil: [self error: 'unhandled type of destination string']. 1 to: bytes do: setBlock. + ^destination! - ^dest! |
Free forum by Nabble | Edit this page |