Intrinsic Parameter-Checking

Top  Previous  Next

Using the wrong number or types of parameters for an intrinsic call can cause catastrophic bugs that are difficult to find. Intrinsic Parameter-Checking allows the compiler to test if an intrinsic is being called with the right type and number of arguments.


Code Declarations. In order to test intrinsic arguments, the compiler needs to know the types and number of parameters used in for an intrinsic call. To accomplish this, the compiler now accepts arguments for each intrinsic declared in the code declaration.


These arguments are called "prototypes".  Prototypes are optional. If an intrinsic is declared without prototypes, the compiler doesn't check argument for that intrinsic. That makes the option backward compatible.


Here is an example of intrinsic declarations with argument prototypes:



       Abs(int:int)=0,                Ran(int:int)=1,                Rem(int:int)=2,

       Reserve(int:int)=3,        Swap(int:int)=4,                Extend(int:int)=5,

       Restart(void:)=6,                ChIn(int:int)=7,                ChOut(void:int,int)=8,

       CrLf(void:int)=9,                IntIn(int:int)=10,        IntOut(void:int,int)=11,

       Text(void:int,int)=12,        OpenI(void:int)=13,        OpenO(void:int)=14,


Argument Syntax. To specify arguments types for an intrinsic, the argument types are placed inside parenthesis after the intrinsic name. The first argument specifies the type of value returned by the intrinsic. Arguments after the colon are the parameter types for each argument. Here is the general syntax


<return type>:<arg type>,<arg type>,<arg type>...


The kinds of types symbols that can be used are as follows:


1. int - Indicates that the argument is a 32-bit integer.


2. char - Indicates that the argument is  a character or byte-sized argument. Since XPL only has one integer type, this is the same as an integer argument.


3. real - Indicates that the argument is  a 64-bit real.


4. void - Indicates no argument. This option is only used for the Return-Type.

4. addr = This symbol appears before a variable type to indicate that the argument is an integer pointer to the underlying data type.


5. @ = This symbol appears before a variable type to indicate that the argument is a pointer to the underlying data type. If the underlying data types is a real, the pointer is a 64-bit real number with the address packed into the first 32-bits. If the underlying data type is an integer, the pointer is a 32-bit integer. Here is an example of a more complex declaration:







Generating Intrinsics. The Intrinsic Code-Generator supports parameter checking. You have the option of generating a code-declaration file that includes prototype arguments.  The argument-checking feature only works if your code contains prototypes. This means you can disable the feature by using a code-declaration files without argument types.


Auto Generating. EXPL also supports automatically including an intrinsic code declaration file if the user doesn't provide one. This feature also include the option of including prototypes.