diff options
| author | ruki <[email protected]> | 2021-09-04 00:58:26 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-09-04 00:58:26 +0800 |
| commit | c4b3c9836293e77fcfc87b3e8f788cc974b1e59a (patch) | |
| tree | ce9d93b6a99b750d31d73982e929f16e122a3cb6 /tests/projects/pascal/shared/src | |
| parent | 836284af26a6d4edb1670cd6266d31c16b43ba2c (diff) | |
add pascal shared template
Diffstat (limited to 'tests/projects/pascal/shared/src')
| -rw-r--r-- | tests/projects/pascal/shared/src/foo.pas | 24 | ||||
| -rw-r--r-- | tests/projects/pascal/shared/src/main.pas | 15 |
2 files changed, 17 insertions, 22 deletions
diff --git a/tests/projects/pascal/shared/src/foo.pas b/tests/projects/pascal/shared/src/foo.pas index d1952cf21..788950f46 100644 --- a/tests/projects/pascal/shared/src/foo.pas +++ b/tests/projects/pascal/shared/src/foo.pas @@ -1,23 +1,19 @@ library foo; -function SubStr(CString: PChar;FromPos,ToPos: Longint): PChar; cdecl; - -var - Length: Integer; +{$mode objfpc}{$H+} +function fib(n : Int64) : Int64; cdecl; begin - Length := StrLen(CString); - SubStr := CString + Length; - if (FromPos > 0) and (ToPos >= FromPos) then + if n > 1 then begin - if Length >= FromPos then - SubStr := CString + FromPos; - if Length > ToPos then - CString[ToPos+1] := #0; - end; + Result := fib(n - 1) + fib(n - 2); + end + else + Result := 1; end; exports - SubStr; - + fib; end. + + diff --git a/tests/projects/pascal/shared/src/main.pas b/tests/projects/pascal/shared/src/main.pas index ccf2e179b..02d5e88d0 100644 --- a/tests/projects/pascal/shared/src/main.pas +++ b/tests/projects/pascal/shared/src/main.pas @@ -1,14 +1,13 @@ -uses strings; +program hello; -function SubStr(const CString: PChar; FromPos, ToPos: longint): PChar; +function fib(n: Int64): Int64; cdecl; external 'foo'; var - s: PChar; - FromPos, ToPos: Integer; + Value: Integer; begin - s := strnew('TestMe'); - FromPos := 2; - ToPos := 3; - WriteLn(SubStr(s, FromPos, ToPos)); + Value := 5; + WriteLn(fib(Value)); end. + + |
