From 5ae9534e81d495e30f82438de988f3508a660d3f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 22 Oct 2024 12:57:58 +0200 Subject: [PATCH] Extend interop with BigInteger, meta parents, and readBuffer --- .../instance/interopGetMetaParents.st | 3 +++ .../instance/interopHasMetaParents.st | 3 +++ .../Behavior.extension/methodProperties.json | 2 ++ .../ForeignObject.class/instance/^equals.st | 1 + .../instance/adaptToNumber.andSend..st | 1 + .../ForeignObject.class/instance/asNumber.st | 1 + .../ForeignObject.class/instance/asSmalltalk.st | 1 + .../ForeignObject.class/instance/isZero.st | 1 + .../ForeignObject.class/methodProperties.json | 10 +++++----- .../Interop.class/class/asBigInteger..st | 6 ++++++ .../Interop.class/class/fitsInBigInteger..st | 4 ++++ .../Interop.class/class/getMetaParents..st | 6 ++++++ .../Interop.class/class/hasMetaParents..st | 6 ++++++ ...byteOffset.destination.destinationOffset.length..st | 8 ++++++++ .../Interop.class/methodProperties.json | 5 +++++ .../Java.class/class/asBigInteger..st | 4 ++++ .../Java.class/class/asHostObject..st | 2 +- .../Java.class/methodProperties.json | 3 ++- .../instance/interopAsBigInteger.st | 3 +++ .../instance/interopFitsInBigInteger.st | 3 +++ .../methodProperties.json | 6 ++++++ .../LargePositiveInteger.extension/properties.json | 2 ++ .../Object.extension/instance/interopAsBigInteger.st | 3 +++ .../instance/interopFitsInBigInteger.st | 3 +++ .../Object.extension/instance/interopGetMetaParents.st | 3 +++ .../Object.extension/instance/interopHasMetaParents.st | 3 +++ ...ReadBuffer.destination.destinationOffset.length..st | 3 +++ .../Object.extension/methodProperties.json | 5 +++++ .../instance/testJSMetadataAPIs.st | 1 + .../ForeignObjectTest.class/instance/testJSObject.st | 2 ++ .../ForeignObjectTest.class/methodProperties.json | 4 ++-- .../InteropTest.class/instance/testMetadataAPIs.st | 4 ++++ .../InteropTest.class/instance/testNumbers.st | 9 ++++++++- .../InteropTest.class/methodProperties.json | 4 ++-- .../JavaTest.class/instance/testJavaBuffers.st | 6 +++++- .../JavaTest.class/methodProperties.json | 2 +- .../instance/testVMIntrospection.st | 9 ++++++--- .../TruffleSqueakTest.class/methodProperties.json | 2 +- 38 files changed, 126 insertions(+), 18 deletions(-) create mode 100644 src/TruffleSqueak-Core.package/Behavior.extension/instance/interopGetMetaParents.st create mode 100644 src/TruffleSqueak-Core.package/Behavior.extension/instance/interopHasMetaParents.st create mode 100644 src/TruffleSqueak-Core.package/Interop.class/class/asBigInteger..st create mode 100644 src/TruffleSqueak-Core.package/Interop.class/class/fitsInBigInteger..st create mode 100644 src/TruffleSqueak-Core.package/Interop.class/class/getMetaParents..st create mode 100644 src/TruffleSqueak-Core.package/Interop.class/class/hasMetaParents..st create mode 100644 src/TruffleSqueak-Core.package/Interop.class/class/readBuffer.byteOffset.destination.destinationOffset.length..st create mode 100644 src/TruffleSqueak-Core.package/Java.class/class/asBigInteger..st create mode 100644 src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopAsBigInteger.st create mode 100644 src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopFitsInBigInteger.st create mode 100644 src/TruffleSqueak-Core.package/LargePositiveInteger.extension/methodProperties.json create mode 100644 src/TruffleSqueak-Core.package/LargePositiveInteger.extension/properties.json create mode 100644 src/TruffleSqueak-Core.package/Object.extension/instance/interopAsBigInteger.st create mode 100644 src/TruffleSqueak-Core.package/Object.extension/instance/interopFitsInBigInteger.st create mode 100644 src/TruffleSqueak-Core.package/Object.extension/instance/interopGetMetaParents.st create mode 100644 src/TruffleSqueak-Core.package/Object.extension/instance/interopHasMetaParents.st create mode 100644 src/TruffleSqueak-Core.package/Object.extension/instance/interopReadBuffer.destination.destinationOffset.length..st diff --git a/src/TruffleSqueak-Core.package/Behavior.extension/instance/interopGetMetaParents.st b/src/TruffleSqueak-Core.package/Behavior.extension/instance/interopGetMetaParents.st new file mode 100644 index 000000000..8fc10af7b --- /dev/null +++ b/src/TruffleSqueak-Core.package/Behavior.extension/instance/interopGetMetaParents.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-meta-object +interopGetMetaParents + ^ {self superclass} \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Behavior.extension/instance/interopHasMetaParents.st b/src/TruffleSqueak-Core.package/Behavior.extension/instance/interopHasMetaParents.st new file mode 100644 index 000000000..3700da13c --- /dev/null +++ b/src/TruffleSqueak-Core.package/Behavior.extension/instance/interopHasMetaParents.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-meta-object +interopHasMetaParents + ^ true \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Behavior.extension/methodProperties.json b/src/TruffleSqueak-Core.package/Behavior.extension/methodProperties.json index 22beb5400..91c0ae287 100644 --- a/src/TruffleSqueak-Core.package/Behavior.extension/methodProperties.json +++ b/src/TruffleSqueak-Core.package/Behavior.extension/methodProperties.json @@ -2,8 +2,10 @@ "class" : { }, "instance" : { + "interopGetMetaParents" : "fn 10/22/2024 12:07", "interopGetMetaQualifiedName" : "fn 3/9/2021 12:39", "interopGetMetaSimpleName" : "fn 3/9/2021 12:38", + "interopHasMetaParents" : "fn 10/22/2024 12:07", "interopInstantiate:" : "fn 3/9/2021 12:39", "interopIsInstantiable" : "fn 3/9/2021 12:39", "interopIsMetaInstance:" : "fn 3/9/2021 12:38", diff --git a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/^equals.st b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/^equals.st index d1f03bc70..634067748 100644 --- a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/^equals.st +++ b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/^equals.st @@ -4,6 +4,7 @@ comparing (Interop isBoolean: self) ifTrue: [ ^ anObject = (Interop asBoolean: self) ]. (Interop fitsInLong: self) ifTrue: [ ^ anObject = (Interop asLong: self) ]. (Interop fitsInDouble: self) ifTrue: [ ^ anObject = (Interop asDouble: self) ]. + (Interop fitsInBigInteger: self) ifTrue: [ ^ anObject = (Interop asBigInteger: self) ]. (Interop isString: self) ifTrue: [ ^ anObject = (Interop asString: self) ]. ((Interop isHostObject: self) and: [ Interop isHostObject: anObject ]) ifTrue: [ ^ self equals: anObject ]. diff --git a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/adaptToNumber.andSend..st b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/adaptToNumber.andSend..st index 9ce05a150..2b3586c68 100644 --- a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/adaptToNumber.andSend..st +++ b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/adaptToNumber.andSend..st @@ -3,4 +3,5 @@ adaptToNumber: rcvr andSend: selector "If I am involved in arithmetic with a number, convert me to a number." (Interop fitsInLong: self) ifTrue: [ ^ rcvr perform: selector with: (Interop asLong: self) ]. (Interop fitsInDouble: self) ifTrue: [ ^ rcvr perform: selector with: (Interop asDouble: self) ]. + (Interop fitsInBigInteger: self) ifTrue: [ ^ rcvr perform: selector with: (Interop asBigInteger: self) ]. self error: 'Cannot adapt foreign object to number' \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asNumber.st b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asNumber.st index 9c6887e1c..eea86a754 100644 --- a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asNumber.st +++ b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asNumber.st @@ -2,4 +2,5 @@ converting asNumber (Interop fitsInLong: self) ifTrue: [ ^ Interop asLong: self ]. (Interop fitsInDouble: self) ifTrue: [ ^ Interop asDouble: self ]. + (Interop fitsInBigInteger: self) ifTrue: [ ^ Interop asBigInteger: self ]. self error: 'Unable to interpret foreign value as number' \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asSmalltalk.st b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asSmalltalk.st index 58d13dd35..7ec321b16 100644 --- a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asSmalltalk.st +++ b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/asSmalltalk.st @@ -4,4 +4,5 @@ asSmalltalk (Interop isString: self) ifTrue: [ ^ Interop asString: self ]. (Interop fitsInLong: self) ifTrue: [ ^ Interop asLong: self ]. (Interop fitsInDouble: self) ifTrue: [ ^ Interop asDouble: self ]. + (Interop fitsInBigInteger: self) ifTrue: [ ^ Interop asBigInteger: self ]. self error: 'Unable to convert to Smalltalk object' \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/isZero.st b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/isZero.st index cc83a01cd..42155a815 100644 --- a/src/TruffleSqueak-Core.package/ForeignObject.class/instance/isZero.st +++ b/src/TruffleSqueak-Core.package/ForeignObject.class/instance/isZero.st @@ -2,4 +2,5 @@ testing isZero (Interop fitsInLong: self) ifTrue: [ ^ (Interop asLong: self) isZero ]. (Interop fitsInDouble: self) ifTrue: [ ^ (Interop asDouble: self) isZero ]. + (Interop fitsInBigInteger: self) ifTrue: [ ^ (Interop asBigInteger: self) isZero ]. self error: 'Unable to interpret foreign value as number' \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/ForeignObject.class/methodProperties.json b/src/TruffleSqueak-Core.package/ForeignObject.class/methodProperties.json index 4a020d759..5c2c16ff3 100644 --- a/src/TruffleSqueak-Core.package/ForeignObject.class/methodProperties.json +++ b/src/TruffleSqueak-Core.package/ForeignObject.class/methodProperties.json @@ -12,14 +12,14 @@ "/" : "fn 8/2/2019 08:59", "<" : "fn 8/2/2019 09:20", "<=" : "fn 8/2/2019 09:14", - "=" : "fn 5/29/2020 15:15", + "=" : "fn 10/22/2024 10:48", "==" : "fn 11/18/2020 15:45", ">" : "fn 8/2/2019 09:14", ">=" : "fn 8/2/2019 09:14", "_dispatch:arguments:ifFail:" : "fn 5/25/2021 13:52", "_dispatch:ifFail:" : "fn 8/2/2019 17:02", "_redirect:" : "fn 8/2/2019 17:02", - "adaptToNumber:andSend:" : "fn 11/11/2019 22:07", + "adaptToNumber:andSend:" : "fn 10/22/2024 10:49", "allInstVarNames" : "fn 6/25/2021 10:32", "and:" : "fn 2/11/2021 10:35", "asArray" : "fn 1/26/2021 15:51", @@ -28,8 +28,8 @@ "asDate" : "fn 3/4/2021 16:48", "asDateAndTime" : "fn 12/12/2019 23:05", "asDuration" : "fn 12/12/2019 22:41", - "asNumber" : "fn 11/11/2019 22:07", - "asSmalltalk" : "fn 11/11/2019 22:06", + "asNumber" : "fn 10/22/2024 10:49", + "asSmalltalk" : "fn 10/22/2024 10:50", "asString" : "fn 2/22/2021 12:40", "asSymbol" : "fn 6/25/2021 13:26", "asTime" : "fn 12/13/2019 12:28", @@ -61,7 +61,7 @@ "isKindOf:" : "fn 6/25/2021 22:46", "isNil" : "fn 11/11/2019 22:14", "isString" : "fn 11/11/2019 22:14", - "isZero" : "fn 11/11/2019 22:07", + "isZero" : "fn 10/22/2024 10:50", "longPrintOn:" : "fn 6/25/2021 09:39", "notNil" : "fn 11/11/2019 19:51", "or:" : "fn 2/11/2021 10:35", diff --git a/src/TruffleSqueak-Core.package/Interop.class/class/asBigInteger..st b/src/TruffleSqueak-Core.package/Interop.class/class/asBigInteger..st new file mode 100644 index 000000000..665926dcf --- /dev/null +++ b/src/TruffleSqueak-Core.package/Interop.class/class/asBigInteger..st @@ -0,0 +1,6 @@ +primitives numbers +asBigInteger: anObject + + ^ (self fitsInBigInteger: anObject) + ifTrue: [ anObject interopAsBigInteger ] + ifFalse: [ self error: 'Object does not fit in BigInteger' ] \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Interop.class/class/fitsInBigInteger..st b/src/TruffleSqueak-Core.package/Interop.class/class/fitsInBigInteger..st new file mode 100644 index 000000000..e779bab5d --- /dev/null +++ b/src/TruffleSqueak-Core.package/Interop.class/class/fitsInBigInteger..st @@ -0,0 +1,4 @@ +primitives numbers +fitsInBigInteger: anObject + + ^ anObject interopFitsInBigInteger \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Interop.class/class/getMetaParents..st b/src/TruffleSqueak-Core.package/Interop.class/class/getMetaParents..st new file mode 100644 index 000000000..162443125 --- /dev/null +++ b/src/TruffleSqueak-Core.package/Interop.class/class/getMetaParents..st @@ -0,0 +1,6 @@ +primitives meta-data +getMetaParents: anObject + + ^ (self hasMetaParents: anObject) + ifTrue: [ anObject interopGetMetaParents ] + ifFalse: [ self error: 'Object has no meta parents' ] \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Interop.class/class/hasMetaParents..st b/src/TruffleSqueak-Core.package/Interop.class/class/hasMetaParents..st new file mode 100644 index 000000000..637341108 --- /dev/null +++ b/src/TruffleSqueak-Core.package/Interop.class/class/hasMetaParents..st @@ -0,0 +1,6 @@ +primitives meta-data +hasMetaParents: anObject + + ^ (self isMetaObject: anObject) + ifTrue: [ anObject interopHasMetaParents ] + ifFalse: [ self error: 'Object is not a meta object' ] \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Interop.class/class/readBuffer.byteOffset.destination.destinationOffset.length..st b/src/TruffleSqueak-Core.package/Interop.class/class/readBuffer.byteOffset.destination.destinationOffset.length..st new file mode 100644 index 000000000..56351e310 --- /dev/null +++ b/src/TruffleSqueak-Core.package/Interop.class/class/readBuffer.byteOffset.destination.destinationOffset.length..st @@ -0,0 +1,8 @@ +primitives buffers +readBuffer: anObject byteOffset: byteOffset destination: destination destinationOffset: destinationOffset length: length + + ^ (self hasBufferElements: anObject) + ifTrue: [ anObject isForeignObject + ifTrue: [ PolyglotError signal ] + ifFalse: [ anObject interopReadBuffer: byteOffset - 1 destination: destination destinationOffset: destinationOffset - 1 length: length ] ] + ifFalse: [ self error: 'Object does not have buffer elements' ] \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Interop.class/methodProperties.json b/src/TruffleSqueak-Core.package/Interop.class/methodProperties.json index 81ff1f68e..22b56f6f5 100644 --- a/src/TruffleSqueak-Core.package/Interop.class/methodProperties.json +++ b/src/TruffleSqueak-Core.package/Interop.class/methodProperties.json @@ -1,5 +1,6 @@ { "class" : { + "asBigInteger:" : "fn 10/22/2024 09:46", "asBoolean:" : "fn 3/5/2021 14:39", "asDate:" : "fn 12/12/2019 20:42", "asDouble:" : "fn 3/5/2021 14:41", @@ -11,6 +12,7 @@ "asTime:" : "fn 12/12/2019 20:42", "asTimeZone:" : "fn 12/12/2019 23:09", "execute:with:" : "fn 6/26/2021 14:33", + "fitsInBigInteger:" : "fn 10/22/2024 11:54", "fitsInDouble:" : "fn 3/5/2021 14:41", "fitsInLong:" : "fn 3/5/2021 14:40", "getArraySize:" : "fn 3/5/2021 14:35", @@ -35,6 +37,7 @@ "getMembers:" : "fn 1/24/2020 14:50", "getMembers:includeInternal:" : "fn 6/26/2021 14:35", "getMetaObject:" : "fn 3/5/2021 14:48", + "getMetaParents:" : "fn 10/22/2024 12:38", "getMetaQualifiedName:" : "fn 3/5/2021 14:49", "getMetaSimpleName:" : "fn 3/5/2021 14:49", "getScopeParent:" : "fn 3/9/2021 14:58", @@ -56,6 +59,7 @@ "hasMemberWriteSideEffects:member:" : "fn 3/5/2021 14:26", "hasMembers:" : "fn 3/5/2021 14:33", "hasMetaObject:" : "fn 3/5/2021 14:43", + "hasMetaParents:" : "fn 10/22/2024 12:46", "hasScopeParent:" : "fn 3/9/2021 14:57", "hasSourceLocation:" : "fn 3/5/2021 14:43", "hostIdentityHashCode:" : "fn 2/11/2021 12:04", @@ -108,6 +112,7 @@ "memberToSelector:for:" : "fn 3/9/2021 12:49", "memberToSelector:for:arguments:" : "fn 8/19/2021 14:49", "readArrayElement:index:" : "fn 3/5/2021 14:52", + "readBuffer:byteOffset:destination:destinationOffset:length:" : "fn 10/22/2024 09:20", "readBufferByte:index:" : "fn 6/26/2021 14:35", "readBufferDouble:index:" : "fn 6/26/2021 14:35", "readBufferFloat:index:" : "fn 6/26/2021 14:35", diff --git a/src/TruffleSqueak-Core.package/Java.class/class/asBigInteger..st b/src/TruffleSqueak-Core.package/Java.class/class/asBigInteger..st new file mode 100644 index 000000000..476f90c41 --- /dev/null +++ b/src/TruffleSqueak-Core.package/Java.class/class/asBigInteger..st @@ -0,0 +1,4 @@ +primitives internal +asBigInteger: aLargeInteger + + ^ aLargeInteger \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Java.class/class/asHostObject..st b/src/TruffleSqueak-Core.package/Java.class/class/asHostObject..st index 5f0b8b186..459d48b51 100644 --- a/src/TruffleSqueak-Core.package/Java.class/class/asHostObject..st +++ b/src/TruffleSqueak-Core.package/Java.class/class/asHostObject..st @@ -1,6 +1,6 @@ primitives internal asHostObject: aGuestObject - (self isHostObject: self) + (Interop isHostObject: aGuestObject) ifFalse: [ self error: 'Object not a host object' ] ifTrue: [ self error: 'Unexpected error' ] \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Java.class/methodProperties.json b/src/TruffleSqueak-Core.package/Java.class/methodProperties.json index 4db5fdf11..0a7c93019 100644 --- a/src/TruffleSqueak-Core.package/Java.class/methodProperties.json +++ b/src/TruffleSqueak-Core.package/Java.class/methodProperties.json @@ -1,7 +1,8 @@ { "class" : { "addToHostClassPath:" : "fn 6/26/2021 14:36", - "asHostObject:" : "fn 3/5/2021 14:50", + "asBigInteger:" : "fn 10/22/2024 11:57", + "asHostObject:" : "fn 10/22/2024 10:07", "asInteger:" : "fn 8/20/2022 11:11", "asString:" : "fn 3/9/2021 13:59", "asTriState:" : "fn 3/4/2021 11:55", diff --git a/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopAsBigInteger.st b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopAsBigInteger.st new file mode 100644 index 000000000..890823993 --- /dev/null +++ b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopAsBigInteger.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-number +interopAsBigInteger + ^ Java asBigInteger: self \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopFitsInBigInteger.st b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopFitsInBigInteger.st new file mode 100644 index 000000000..948ad49f6 --- /dev/null +++ b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/instance/interopFitsInBigInteger.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-number +interopFitsInBigInteger + ^ true \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/methodProperties.json b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/methodProperties.json new file mode 100644 index 000000000..fc56499ee --- /dev/null +++ b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/methodProperties.json @@ -0,0 +1,6 @@ +{ + "class" : { + }, + "instance" : { + "interopAsBigInteger" : "fn 10/22/2024 11:58", + "interopFitsInBigInteger" : "fn 10/22/2024 09:13" } } diff --git a/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/properties.json b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/properties.json new file mode 100644 index 000000000..2b034b1a2 --- /dev/null +++ b/src/TruffleSqueak-Core.package/LargePositiveInteger.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "LargePositiveInteger" } diff --git a/src/TruffleSqueak-Core.package/Object.extension/instance/interopAsBigInteger.st b/src/TruffleSqueak-Core.package/Object.extension/instance/interopAsBigInteger.st new file mode 100644 index 000000000..7b925f97e --- /dev/null +++ b/src/TruffleSqueak-Core.package/Object.extension/instance/interopAsBigInteger.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-number +interopAsBigInteger + self subclassResponsibility \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Object.extension/instance/interopFitsInBigInteger.st b/src/TruffleSqueak-Core.package/Object.extension/instance/interopFitsInBigInteger.st new file mode 100644 index 000000000..de6f5bcdb --- /dev/null +++ b/src/TruffleSqueak-Core.package/Object.extension/instance/interopFitsInBigInteger.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-number +interopFitsInBigInteger + ^ false \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Object.extension/instance/interopGetMetaParents.st b/src/TruffleSqueak-Core.package/Object.extension/instance/interopGetMetaParents.st new file mode 100644 index 000000000..df6866ac4 --- /dev/null +++ b/src/TruffleSqueak-Core.package/Object.extension/instance/interopGetMetaParents.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-meta-object +interopGetMetaParents + ^ self subclassResponsibility \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Object.extension/instance/interopHasMetaParents.st b/src/TruffleSqueak-Core.package/Object.extension/instance/interopHasMetaParents.st new file mode 100644 index 000000000..e88656bef --- /dev/null +++ b/src/TruffleSqueak-Core.package/Object.extension/instance/interopHasMetaParents.st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-meta-object +interopHasMetaParents + ^ false \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Object.extension/instance/interopReadBuffer.destination.destinationOffset.length..st b/src/TruffleSqueak-Core.package/Object.extension/instance/interopReadBuffer.destination.destinationOffset.length..st new file mode 100644 index 000000000..77c55f340 --- /dev/null +++ b/src/TruffleSqueak-Core.package/Object.extension/instance/interopReadBuffer.destination.destinationOffset.length..st @@ -0,0 +1,3 @@ +*TruffleSqueak-Core-buffers +interopReadBuffer: byteOffset destination: destination destinationOffset: destinationOffset length: length + self subclassResponsibility \ No newline at end of file diff --git a/src/TruffleSqueak-Core.package/Object.extension/methodProperties.json b/src/TruffleSqueak-Core.package/Object.extension/methodProperties.json index 2bdaa28a4..e11bf8e90 100644 --- a/src/TruffleSqueak-Core.package/Object.extension/methodProperties.json +++ b/src/TruffleSqueak-Core.package/Object.extension/methodProperties.json @@ -3,6 +3,7 @@ }, "instance" : { "defaultLabelForPolyglotTools" : "fn 6/26/2021 14:43", + "interopAsBigInteger" : "fn 10/22/2024 09:58", "interopAsBoolean" : "fn 3/4/2021 11:12", "interopAsByte" : "fn 11/24/2020 12:35", "interopAsDate" : "fn 11/20/2020 16:38", @@ -17,6 +18,7 @@ "interopAsTime" : "fn 3/4/2021 16:26", "interopAsTimeZone" : "fn 11/24/2020 14:52", "interopExecute:" : "fn 11/24/2020 13:50", + "interopFitsInBigInteger" : "fn 10/22/2024 09:12", "interopFitsInByte" : "fn 11/24/2020 12:34", "interopFitsInDouble" : "fn 11/24/2020 12:34", "interopFitsInFloat" : "fn 11/24/2020 12:34", @@ -41,6 +43,7 @@ "interopGetLanguage" : "fn 3/4/2021 11:42", "interopGetMembers:" : "fn 3/9/2021 12:44", "interopGetMetaObject" : "fn 11/24/2020 16:29", + "interopGetMetaParents" : "fn 10/22/2024 09:23", "interopGetMetaQualifiedName" : "fn 11/24/2020 12:54", "interopGetMetaSimpleName" : "fn 11/24/2020 12:54", "interopGetScopeParent" : "fn 3/10/2021 09:25", @@ -60,6 +63,7 @@ "interopHasMemberWriteSideEffects:" : "fn 3/4/2021 11:11", "interopHasMembers" : "fn 3/4/2021 11:11", "interopHasMetaObject" : "fn 11/24/2020 16:29", + "interopHasMetaParents" : "fn 10/22/2024 09:23", "interopHasScopeParent" : "fn 3/9/2021 14:19", "interopHasSourceLocation" : "fn 3/4/2021 11:20", "interopIdentityHashCode" : "fn 3/9/2021 13:59", @@ -102,6 +106,7 @@ "interopIsTime" : "fn 11/20/2020 17:17", "interopIsTimeZone" : "fn 11/20/2020 17:17", "interopReadArrayElement:" : "fn 3/4/2021 11:10", + "interopReadBuffer:destination:destinationOffset:length:" : "fn 10/22/2024 09:20", "interopReadBufferByte:" : "fn 3/31/2021 13:26", "interopReadBufferDouble:" : "fn 3/31/2021 13:26", "interopReadBufferFloat:" : "fn 3/31/2021 13:26", diff --git a/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSMetadataAPIs.st b/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSMetadataAPIs.st index 33a97a924..3e6d30496 100644 --- a/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSMetadataAPIs.st +++ b/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSMetadataAPIs.st @@ -17,6 +17,7 @@ testJSMetadataAPIs self assert: 'Object' equals: (Interop getMetaQualifiedName: (Interop getMetaObject: jsObject)) asString. self assert: 'Object' equals: (Interop getMetaSimpleName: (Interop getMetaObject: jsObject)) asString. self assert: jsCode equals: (Interop toDisplayString: jsObject) asString. + "GraalJS does not support meta parents yet" self assert: (jsObject isKindOf: (Interop getMetaObject: jsObject)). self assert: (jsObject respondsTo: #a). diff --git a/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSObject.st b/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSObject.st index bfcb4656b..03d7f4b14 100644 --- a/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSObject.st +++ b/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/instance/testJSObject.st @@ -16,6 +16,8 @@ testJSObject self should: [ Interop asLong: jsObject ] raise: Error. self deny: (Interop fitsInDouble: jsObject). self should: [ Interop asDouble: jsObject ] raise: Error. + self deny: (Interop fitsInBigInteger: jsObject). + self should: [ Interop asBigInteger: jsObject ] raise: Error. self deny: (Interop hasArrayElements: jsObject). self assert: 1 equals: (Interop getMemberSize: jsObject). diff --git a/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/methodProperties.json b/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/methodProperties.json index 60e218019..6db279b4b 100644 --- a/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/methodProperties.json +++ b/src/TruffleSqueak-Tests.package/ForeignObjectTest.class/methodProperties.json @@ -7,6 +7,6 @@ "testJSBasic" : "fn 5/29/2020 10:46", "testJSDate" : "fn 5/29/2020 10:46", "testJSExecutable" : "fn 5/29/2020 10:46", - "testJSMetadataAPIs" : "fn 6/25/2021 17:36", - "testJSObject" : "fn 1/26/2021 17:54", + "testJSMetadataAPIs" : "fn 10/22/2024 12:44", + "testJSObject" : "fn 10/22/2024 11:00", "testSmalltalkFromJS" : "fn 3/9/2021 12:52" } } diff --git a/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testMetadataAPIs.st b/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testMetadataAPIs.st index 15c03dde5..bfc193718 100644 --- a/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testMetadataAPIs.st +++ b/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testMetadataAPIs.st @@ -12,6 +12,10 @@ testMetadataAPIs "All boxed objects provide their class as meta object" self assert: (Interop hasMetaObject: Smalltalk). self assert: Smalltalk class equals: (Interop getMetaObject: Smalltalk). + self assert: {ProtoObject} equals: (Interop getMetaParents: Object). + self assert: {ClassDescription} equals: (Interop getMetaParents: Class). + self assert: {ClassDescription class} equals: (Interop getMetaParents: Class class). + self assert: Smalltalk class equals: (Interop getMetaObject: Smalltalk). self assert: Smalltalk class asString equals: (Interop getMetaQualifiedName: (Interop getMetaObject: Smalltalk)) asString. self assert: Smalltalk class asString equals: (Interop getMetaSimpleName: (Interop getMetaObject: Smalltalk)) asString. self assert: ((Interop toDisplayString: Smalltalk) asString includesSubstring: Smalltalk asString) \ No newline at end of file diff --git a/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testNumbers.st b/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testNumbers.st index 9259cf239..de54f0232 100644 --- a/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testNumbers.st +++ b/src/TruffleSqueak-Tests.package/InteropTest.class/instance/testNumbers.st @@ -1,7 +1,9 @@ testing testNumbers + | li | self deny: (Interop fitsInLong: Smalltalk). self deny: (Interop fitsInDouble: Smalltalk). + self deny: (Interop fitsInBigInteger: Smalltalk). self assert: (Interop fitsInLong: 42). self assert: 42 == (Interop asLong: 42). @@ -10,4 +12,9 @@ testNumbers self deny: (Interop fitsInLong: 42.3). self assert: (Interop fitsInDouble: 42.3). - self assert: 42.3 == (Interop asDouble: 42.3) + self assert: 42.3 == (Interop asDouble: 42.3). + + li := SmallInteger maxVal + 1. + self deny: (Interop fitsInLong: li). + self assert: (Interop fitsInBigInteger: li). + self assert: li equals: (Interop asBigInteger: li) diff --git a/src/TruffleSqueak-Tests.package/InteropTest.class/methodProperties.json b/src/TruffleSqueak-Tests.package/InteropTest.class/methodProperties.json index 1fc9d6c4e..7b635c6f0 100644 --- a/src/TruffleSqueak-Tests.package/InteropTest.class/methodProperties.json +++ b/src/TruffleSqueak-Tests.package/InteropTest.class/methodProperties.json @@ -15,9 +15,9 @@ "testInstantiables" : "fn 3/9/2021 16:52", "testIterator" : "fn 3/31/2021 15:36", "testMembers" : "fn 3/9/2021 16:52", - "testMetadataAPIs" : "fn 3/9/2021 16:52", + "testMetadataAPIs" : "fn 10/22/2024 12:12", "testNulls" : "fn 3/9/2021 16:52", - "testNumbers" : "fn 3/9/2021 16:52", + "testNumbers" : "fn 10/22/2024 10:23", "testScopeAPIs" : "fn 3/9/2021 16:38", "testSmalltalkDNU" : "fn 6/30/2021 12:44", "testStrings" : "fn 3/9/2021 16:53", diff --git a/src/TruffleSqueak-Tests.package/JavaTest.class/instance/testJavaBuffers.st b/src/TruffleSqueak-Tests.package/JavaTest.class/instance/testJavaBuffers.st index 8157a7cf5..5f81c4d71 100644 --- a/src/TruffleSqueak-Tests.package/JavaTest.class/instance/testJavaBuffers.st +++ b/src/TruffleSqueak-Tests.package/JavaTest.class/instance/testJavaBuffers.st @@ -1,6 +1,6 @@ testing testJavaBuffers - | buffer | + | buffer byteArray | buffer := (Java type: 'java.nio.ByteBuffer') allocate: 32. self assert: (Interop hasBufferElements: buffer). self assert: 32 equals: (Interop getBufferSize: buffer). @@ -18,3 +18,7 @@ testJavaBuffers self assert: 2.0999999046325684 equals: (Interop readBufferFloat: buffer index: 4). self assert: 4.32198 equals: (Interop writeBufferDouble: buffer index: 5 value: 4.32198). self assert: 4.32198 equals: (Interop readBufferDouble: buffer index: 5). + + byteArray := ByteArray new: 17. + Interop readBuffer: buffer byteOffset: 0 destination: byteArray destinationOffset: 1 length: byteArray size - 1. + self assert: #[0 42 0 32 0 102 68 221 7 32 181 73 17 64 0 0 0] equals: byteArray \ No newline at end of file diff --git a/src/TruffleSqueak-Tests.package/JavaTest.class/methodProperties.json b/src/TruffleSqueak-Tests.package/JavaTest.class/methodProperties.json index cb56459b2..6b5b75aad 100644 --- a/src/TruffleSqueak-Tests.package/JavaTest.class/methodProperties.json +++ b/src/TruffleSqueak-Tests.package/JavaTest.class/methodProperties.json @@ -6,7 +6,7 @@ "testJavaAddToHostClassPath" : "fn 11/11/2019 22:16", "testJavaArray" : "fn 12/13/2019 11:43", "testJavaBasic" : "fn 3/30/2021 16:52", - "testJavaBuffers" : "fn 3/31/2021 19:31", + "testJavaBuffers" : "fn 10/22/2024 09:38", "testJavaDuration" : "fn 12/12/2019 23:15", "testJavaException" : "fn 12/12/2019 23:15", "testJavaHashes" : "fn 3/31/2021 19:09", diff --git a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testVMIntrospection.st b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testVMIntrospection.st index 406c3021f..06c1f4627 100644 --- a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testVMIntrospection.st +++ b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/instance/testVMIntrospection.st @@ -1,6 +1,6 @@ testing testVMIntrospection - | testObject metaObject squeakHashAndBits | + | testObject metaObject metaObjectParents squeakHashAndBits | (Polyglot isPolyglotEvalAllowed: Polyglot languageIdSmalltalk) ifFalse: [ ^self ]. testObject := SmalltalkImage vmObject. @@ -23,7 +23,10 @@ testVMIntrospection "Meta Object API" self assert: (Interop hasMetaObject: testObject). - metaObject := Interop getMetaObject: testObject.. + metaObject := Interop getMetaObject: testObject. self assert: (Interop isMetaObject: metaObject). - self assert: 'ClassObject' equals: (Interop getMetaSimpleName: metaObject) asString. + self assert: 'ClassObject' equals: (Interop getMetaSimpleName: metaObject) asString. + metaObjectParents := Interop getMetaParents: metaObject. + self assert: 1 equals: metaObjectParents size. + self assert: 'AbstractSqueakObjectWithClassAndHash' equals: (Interop getMetaSimpleName: (metaObjectParents at: 1)) asString. self assert: (Interop isMetaInstance: metaObject instance: testObject). diff --git a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json index d3a60703e..a9e9b45e0 100644 --- a/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json +++ b/src/TruffleSqueak-Tests.package/TruffleSqueakTest.class/methodProperties.json @@ -8,4 +8,4 @@ "testCallTarget" : "fn 10/26/2021 21:10", "testLayoutStatistics" : "fn 10/20/2024 19:39", "testTestMapConsistency" : "fn 10/20/2024 19:39", - "testVMIntrospection" : "fn 10/20/2024 19:39" } } + "testVMIntrospection" : "fn 10/22/2024 12:43" } }