Intrinsics are the primitive building block data types common across source and target platforms:
- any (auto)
We can define the intrinsic data types for a given target platform by aliasing to one of the above types in stub APIs.
Sempiler will treat each of these type definitions as the intrinsic role they represent when type checking and validating input.
In many programming languages these intrinsic data types are autoboxed objects rather than just raw primitives.
As such, we may want to model instance methods on an intrinsic data type. How we achieve this depends on the source language we are using.
To model OOP intrinsics in TypeScript stub APIs we can use the following decorators:
||Permit instances of this type to type check as a boolean|
||Permit instances of this type to type check as numeric|
||Permit instances of this type to type check as a string|
These decorators give us the ability to concisely represent intrinsic types that have instance properties, like in Swift:
Older versions of Sempiler model OOP intrinsics differently. Take this example in TypeScript for modelling a Swift
__internal$$ prefix adds unfortunate noise, but Sempiler will detect this prefix and remove it internally.
__internal$$Foo will be treated simply as
Foo, hence a declaration for
Foo must exist in scope.
You can now follow the approach described above to define your own intrinsic types.
This is useful if said types are missing from the symbols available from the repository (be sure to submit them if so!).
The intrinsics available to your code depend on the symbols available on the target platform.