3.2 astproperties.pl -- Properties of abstract syntax trees

Adrian Prantl <adrian@complang.tuwien.ac.at>
Copyright (C) 2008-2009 Adrian Prantl
See COPYING in the root folder of the SATIrE project

This module defines commonly-used queries about C/C++/Objective C ASTs given in the TERMITE term representation as exported by SATIrE.


The user has to define the type predicates [type_info/3, type_interval/2]

[semidet]ast_equiv(+Expr1, +Expr2)
Compare two expressions disregarding the file information Expects compact form.

Todo: rewrite this!

is_transp(+Expr, +Var, +Scope)
Goal succeeds if Var is not written to by Expr.

Goal succeeds if Node introduces new edges into the control flow graph (CFG).
guarantee(+Node, +Pred)
guarantee(+List, +Pred)
Recursively test a predicate Pred on an AST Node or List of AST Nodes, respectively.
strip_file_info(_, _, _, +Term1, -Term2)
Replace file_info(...) with null in all VarRefExps. This facilitates the comparison of AST nodes.

Use this with transformed_with/4

var_stripped(+VarRefExp, -VarRefExpStripped)
Non-traversal version of strip_file_info/5.
get_variable_id(+AnalysisInfo, -Id)
Extract the numerical variable Id from the Analysis Information
var_interval(+AnalysisInfo, +VarRefExp, -Interval)
Employ the analysis result/type info to yield an interval for the VarRefExp.
term_stripped(+Term, -StrippedTerm)
Recursively strip all VarRefExps in Term
[noned]isIntVal(?IntVal, ?Value)
Convert between int_val nodes and integer values.
new_intval(+Value, -IntVal)
Create a new int_val(Value, ...) data structure with default annotations.
[nondet]isVar(?VarRefExp, ?Name)
True if VarRefExp is a var_ref_exp or a cast_exp. Name is the name of the variable.
[nondet]var_type(?VarRefExp, ?Type)
Allows access to the Type of VarRefExp.
[nondet]var_typemod(?VarRefExp, ?ConstVolatile)
Allows access to the ConstVolatile modifier of VarRefExp. Values for ConstVolatile are 'const' and 'volatil' (sic!).
[semidet]isBinNode(+Node, -Name, -E1, -E2, -Annot, -Ai, -Fi)
Decompose a binary node Node. % isBinNode(-Node, +Name, +E1, +E2, +Annot, +Ai, +Fi) is det. Compose a binary node Node.
isBinOpLhs(?BinOp, ?Lhs)
Bind Lhs to the left-hand-side (1) operator of BinOp.
isBinOpRhs(?BinOp, ?Rhs)
Bind Rhs to the right-hand-side (2) operator of BinOp.
True, if Node is a scope statement.
Scope statements are basic_block, catch_option_stmt, class_definition, do_while_stmt, for_statement,function_definition, global, if_stmt, namespace_definition_statment, switch_statement, while_stmt
analysis_info(+Term, -Ai)
Extract the analysis info Ai from Term.
file_info(+Term, -Fi)
Extract the file info Fi from Term.
function_signature(?FunctionDecl, ?Type, ?Name, ?Modifier)
Convert between signatures and terms.
is_function_call(?Term, ?Name, ?Type)
(De-)construct a function call.
is_function_call_exp(?Term, -Name, -Type)
(De-)construct a function call expression.
function_body(?FuncDecl, ?Body)
Get the function body Body from a function declaration FuncDecl.
pragma_text(?Pragma, ?Text)
pragma_text/2 defines the relation between a pragma statement and the String Text inside the "#pragma Text" Statement.
get_annot(+Stmts, -Annotterm, -Pragma)
Find Pragma in Stmts and treat its contents as a Prolog term. If successuful, unify AnnotTerm with the parsed term.
get_annot_term(?Stmts, ?Annotterm, ?Pragma)
Quicker version of get_annot/3 without term parsing.
get_preprocessing_infos(+Node, -PPIs)
Todo: move to annot.pl!
type_interval(+Type, -Interval)
Use the user-defined type_info/2 to return an Interval (Min..Max) denoting the maximum value range of Type