Skip to content

Commit b413589

Browse files
committed
Add support for GetTypeKind intrinsic
1 parent 971d2d0 commit b413589

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Support for `AtomicCmpExchange128` intrinsic.
13+
- Support for `GetTypeKind` intrinsic.
1314

1415
### Changed
1516

delphi-checks-testkit/src/main/java/au/com/integradev/delphi/checks/verifier/CheckVerifierImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,12 @@ private Path createStandardLibrary() {
793793
+ " TVarArgList = record\n"
794794
+ " end;\n"
795795
+ "\n"
796+
+ " TTypeKind = (\n"
797+
+ " tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat, tkString, tkSet,\n"
798+
+ " tkClass, tkMethod, tkWChar, tkLString, tkWString, tkVariant, tkArray,\n"
799+
+ " tkClassRef, tkPointer, tkProcedure, tkMRecord\n"
800+
+ " );\n"
801+
+ "\n"
796802
+ "implementation\n"
797803
+ "\n"
798804
+ "end.");

delphi-frontend/src/main/java/au/com/integradev/delphi/type/intrinsic/IntrinsicsInjector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ private void buildRoutines() {
262262
routine("FreeMem").varParam(ANY_POINTER).param(type(INTEGER)).required(1);
263263
routine("GetDir").param(type(BYTE)).varParam(ANY_STRING);
264264
routine("GetMem").varParam(ANY_POINTER).param(type(INTEGER));
265+
routine("GetTypeKind").param(TypeFactory.untypedType()).returns(systemType("TTypeKind"));
265266
routine("Halt").param(type(INTEGER)).required(0);
266267
routine("HasWeakRef").param(ANY_CLASS_REFERENCE).returns(type(BOOLEAN));
267268
routine("Hi").param(type(INTEGER)).returns(type(BYTE));

delphi-frontend/src/test/java/au/com/integradev/delphi/executor/DelphiSymbolTableExecutorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,12 @@ void testVarArgIntrinsics() {
605605
verifyUsages(15, 2, reference(18, 21));
606606
}
607607

608+
@Test
609+
void testGetTypeKindIntrinsic() {
610+
execute("intrinsics/GetTypeKindIntrinsic.pas");
611+
verifyUsages(7, 10, reference(14, 2), reference(15, 2));
612+
}
613+
608614
@Test
609615
void testBinaryOperatorIntrinsics() {
610616
execute("operators/BinaryOperatorIntrinsics.pas");
@@ -1642,6 +1648,7 @@ private static Path createStandardLibrary(Path baseDir) {
16421648
+ " end;\n"
16431649
+ " TVarArgList = record\n"
16441650
+ " end;\n"
1651+
+ " TTypeKind = (tkUnknown);\n"
16451652
+ "implementation\n"
16461653
+ "end.");
16471654

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
unit GetTypeKindIntrinsic;
2+
3+
interface
4+
5+
implementation
6+
7+
procedure Proc(Arg: TTypeKind); overload;
8+
begin
9+
// Do nothing
10+
end;
11+
12+
procedure Test;
13+
begin
14+
Proc(GetTypeKind(123));
15+
Proc(GetTypeKind(TObject));
16+
end;
17+
18+
end.

0 commit comments

Comments
 (0)