PAG/WWW Logo

© 1998-2004 Saarland University, Germany


 How to build your own analysis: The SUPPORT section
 

» Back to overview

In the SUPPORT section you can write FULA functions for use in the TRANSFER section. Also any SUPPORT function can be used when specifying information in the PROBLEM section.

The definition of a support function always consists of two steps:

  1. declaring the function (that is specifying its FULA type)
  2. implementing the function
The declaration of a support function with n arguments looks like this:
functionname :: argtype1 * ... * argtypen -> returntype
where argtypei is a type name defined in the TYPE section or a built-in type.
The implementation should look like this:
functionname ( param1, ... , paramn ) = FULA-expression
In both cases, n may be any number >= 0; even for n=0, the arrow -> and the parentheses are mandatory, e.g.
five :: -> snum
five() = 5

In the implementation you can use pattern matching to implement functions depending on the arguments.
For example
listlength :: ExpressionList -> snum //definition
listlength ( [] ) = 0 // empty list has length 0
listlength ( head:tail ) = 1 + listlength (tail) // 1 + length of the restlist
listlength ( _ ) = error("listlength called for non list") // error else

defines and implements a function that calculates recursively the length of a list of expressions. For each call the argument is matched first against [], and then against head:tail, and the function is calculated according to which pattern matched.
The third pattern (the anonymous variable "_") matches any expression, so this part of the function definition is evaluated whenever none of the above patterns could be matched. For the case of listlength we produce an error. On the other hand we could just as well drop the third pattern altogether since the type checker would already note an error if we tried to call listlength with an argument that is not a list.

Next step

Contents

  1. Overview
  2. Specifying datatypes in the TYPE section
  3. Specifying the framework of your analysis in the PROBLEM section
  4. The FULA language
  5. Global FULA variables
  6. Specifying the TRANSFER section
  7. The SUPPORT section
  8. Built-in PAG/WWW functions
  9. A formal description of the analysis specification syntax

Search

 

for 

 

 

Please send any suggestions, comments or questions to Martin@cs.uni-sb.de.