PAT only
supports integer, Boolean and
integer arrays for the purpose of efficient verification.
However, advanced data structures (e.g., stack, queue, hashtable and so
on) are necessary for some models. To support arbitary data structures, PAT
provides an interface to create user defined data type by inheriting an
abstract classes
ExpressionValue.
The
following is one simple example showing how to create a hashtable
in C#.
using System.Collections; //the namespace must be PAT.Lib, the class and method names can /// Default public public void Add(int public int /// Return the /// Return a deep /// Return the |
Note the
following requirements when you create your own data structure
objects:
- The
namespace must be “PAT.Lib”, otherwise it will not be recognized. There is no
restriction for class names and method
names. - Importing the PAT Expression name
space using “using
PAT.Common.Classes.Expressions.ExpressionClass;“.
- Only
public methods can be used in PAT models - The
parameters must be of type “bool”, “int”, “int[]” (int array) or object
(object type allow user to pass user defined data type as
parameter). - The
number of parameters can be 0 or many. - The
return type must be of type “void”, “bool”, “int”, “int[]” (int
array) or user defined data type. - The
method names are case sensitive. - Put
the compiled dlls in “Lib” folder of the PAT installation directory to make
the linking easy by using #import
“DLL_Name”;
if your
methods need to handle exceptional cases, you can throw PAT runtime
exceptions as illustrated as the following example.
public static int StackPeek(int[] array) //throw PAT Runtime |
To
import the libraries in your model, users can using following
syntax:
#import “PAT.Lib.Hashtable”; //to import a library under
Lib folder of PAT installation path
#import
“C:Program FilesIntelHashtable.dll”; //to import a library using absolute
path
To
declar the user defined types in your models, please use the following
syntax:
var<HashTable> table; //use the class name here
as the type of the varaible.
To
invoke the public methods in your models, please use the
following syntax:
- table.Add(10, 2);
- if(table.ContainsKey(10))…
Copyright © 2007-2009 School of Computing, National University of
Singapore