Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Support for the `WEAK_NATIVEINT` symbol, which is defined from Delphi 12 onward.
- Support for undocumented intrinsics usable within `varargs` routines:
- `VarArgStart`
- `VarArgGetValue`
- `VarArgCopy`
- `VarArgEnd`

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public static Type slice(TypeFactory typeFactory) {
return new SliceReturnType(typeFactory);
}

public static Type classReferenceValue() {
return new ClassReferenceValueType();
public static Type classReferenceValue(int argumentIndex) {
return new ClassReferenceValueType(argumentIndex);
}

public static Type argumentByIndex(int index) {
Expand Down Expand Up @@ -179,9 +179,15 @@ public Type getReturnType(List<Type> arguments) {
}

private static final class ClassReferenceValueType extends IntrinsicReturnType {
private final int argumentIndex;

private ClassReferenceValueType(int argumentIndex) {
this.argumentIndex = argumentIndex;
}

@Override
public Type getReturnType(List<Type> arguments) {
Type type = arguments.get(0);
Type type = arguments.get(argumentIndex);
if (type.isClassReference()) {
return ((ClassReferenceType) type).classType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private void buildRoutines() {
routine("Dec").varParam(ANY_TYPED_POINTER).param(type(INTEGER)).required(1);
routine("Default")
.param(ANY_CLASS_REFERENCE)
.returns(IntrinsicReturnType.classReferenceValue());
.returns(IntrinsicReturnType.classReferenceValue(0));
routine("Delete").varParam(ANY_STRING).param(type(INTEGER)).param(type(INTEGER));
routine("Delete")
.varParam(LIKE_DYNAMIC_ARRAY)
Expand Down Expand Up @@ -312,6 +312,13 @@ private void buildRoutines() {
.param(ANY_STRING)
.varParam(TypeFactory.untypedType())
.varParam(ANY_32_BIT_INTEGER);
routine("VarArgStart").varParam(TypeFactory.untypedType());
routine("VarArgGetValue")
.varParam(TypeFactory.untypedType())
.param(ANY_CLASS_REFERENCE)
.returns(IntrinsicReturnType.classReferenceValue(1));
routine("VarArgCopy").varParam(TypeFactory.untypedType()).varParam(TypeFactory.untypedType());
routine("VarArgEnd").varParam(TypeFactory.untypedType());
routine("VarArrayRedim").varParam(ANY_VARIANT).param(type(INTEGER));
routine("VarCast").varParam(ANY_VARIANT).param(ANY_VARIANT).param(type(INTEGER));
routine("VarClear").varParam(ANY_VARIANT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void testClassReferenceValueType() {
Type classType = mock(StructType.class);
Type classReference = TYPE_FACTORY_64_ALEXANDRIA.classOf("Foo", classType);

var classReferenceValue = (IntrinsicReturnType) IntrinsicReturnType.classReferenceValue();
var classReferenceValue = (IntrinsicReturnType) IntrinsicReturnType.classReferenceValue(0);
assertThat(classReferenceValue.getReturnType(List.of(classReference))).isSameAs(classType);
assertThat(classReferenceValue.getReturnType(List.of(classType)).isUnknown()).isTrue();
}
Expand Down