blob: 1b6cf248b6f6eb607a8fa330c408f727cf21ad52 [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>5.6.1.&nbsp;Predefined Function Call</title><link href="style.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.72.0" name="generator"><link rel="start" href="index.html" title="The VIATRA2 Model Transformation Framework"><link rel="up" href="sec_PredefinedFunctions.html" title="5.6.&nbsp;Predefined Functions"><link rel="prev" href="sec_PredefinedFunctions.html" title="5.6.&nbsp;Predefined Functions"><link rel="next" href="sec_NamingVariables.html" title="5.7.&nbsp;Naming and Variables"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><th align="center" colspan="3">5.6.1.&nbsp;Predefined Function Call</th></tr><tr><td align="left" width="20%"><a accesskey="p" href="sec_PredefinedFunctions.html">Prev</a>&nbsp;</td><th align="center" width="60%">5.6.&nbsp;Predefined Functions</th><td align="right" width="20%">&nbsp;<a accesskey="n" href="sec_NamingVariables.html">Next</a></td></tr></table><hr></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="def_PredefinedFunctionCall"></a>5.6.1.&nbsp;Predefined Function Call</h4></div></div></div><div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip: Description"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Tip]" src="images/tip.png"></td><th align="left"><a name="def_PredefinedFunctionCall_Description"></a>Description</th></tr><tr><td valign="top" align="left"><p>
VIATRA provides a set of predefined functions: a part of it is
<span class="emphasis"><em>built-in function</em></span> that is interpreted by the VIATRA engine and
another part is defined as an Eclipse plug-in; these later ones are called
<span class="emphasis"><em>native functions</em></span>.
</p></td></tr></table></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Important: Syntax"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Important]" src="images/important.png"></td><th align="left"><a name="def_PredefinedFunctionCall_Syntax"></a>Syntax</th></tr><tr><td valign="top" align="left"><pre class="programlisting">
PredefinedFunctionCallAST ::= BuiltInFunctionNameAST <span class="token">(</span> <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">ArithmeticTermAST</a> <span class="token">)</span>
| ConversionFunctionNameAST <span class="token">(</span> <a href="def_ArithmeticTerm.html" title="5.3.1.&nbsp;Arithmetic Term">ArithmeticTermAST</a> <span class="token">)</span>
BuiltInFunctionNameAST$BuiltInFunctionNameAST ::=
ref | fqn | name | value | source | target |
multiplicity | aggregation | inverse
ConversionFunctionNameAST$ConversionFunctionNameAST ::=
toBoolean | toString | toInteger | toDouble | toMultiplicity
</pre><p>
The predefined functions are identified by their <a href="def_ModelElementName.html" title="5.7.1.&nbsp;Model Element Name">names</a>
and they are called with an <a href="def_ActualParameter.html" title="5.8.3.&nbsp;Actual Parameters">actual parameter list</a>.
</p><p>
For <span class="strong"><strong>native functions</strong></span>,
<a name="N12D1C" class="indexterm"></a>
<a name="N12D21" class="indexterm"></a>
the name and the formal parameter list is determined by an Eclipse plug-in. The objects returned by native
functions should be treated by the interpreter according to the followings:
<div class="itemizedlist"><ul type="disc"><li><p>
for <span class="emphasis"><em>built-in types</em></span> (String, Double, Boolean, Integer, IModelElement),
the interpreter should recognize the type and provide auto-conversion,
</p></li><li><p>
<span class="emphasis"><em>unknown types</em></span> are handled as "native function objects" that can be passed to other native functions as parameters,
but if the transformation tries to use them as a normal VTCL value, a runtime exception is thrown.
</p></li></ul></div>
</p><p>
<span class="emphasis"><em>Built-in functions</em></span>are the followings:
<div class="itemizedlist"><ul type="disc"><li><p><span class="emphasis"><em>Element reference functions</em></span>
<div class="itemizedlist"><ul type="circle"><li><p><span class="strong"><strong>ref(s)</strong></span>- This function returns a reference to the model element corresponding to string
<span class="emphasis"><em>s</em></span>, where <span class="emphasis"><em>s</em></span>is the string representation of the model element name.
</p></li><li><p><span class="strong"><strong>fqn(e)</strong></span>- Returns the fully qualified name of the model element <span class="emphasis"><em>e</em></span> as string.
</p></li><li><p><span class="strong"><strong>name(e)</strong></span>- Returns the local name of the model element <span class="emphasis"><em>e</em></span> as string.
</p></li><li><p><span class="strong"><strong>value(e)</strong></span>- Returns the value associated to the model entity <span class="emphasis"><em>e</em></span> as string.
</p></li><li><p><span class="strong"><strong>source(r)</strong></span>- Returns the source element of the relation <span class="emphasis"><em>r</em></span> as model element reference.
</p></li><li><p><span class="strong"><strong>target(r)</strong></span>- Returns the target element of the relation <span class="emphasis"><em>r</em></span> as model element reference.
</p></li></ul></div>
</p></li><li><p><span class="emphasis"><em>Conversion functions</em></span>
<div class="itemizedlist"><ul type="circle"><li><p>
<span class="strong"><strong>toBoolean(r)</strong></span>- Converts the value <code class="computeroutput">r</code> to boolean (if possible).
</p></li><li><p>
<span class="strong"><strong>toString(r)</strong></span>- Converts the value <code class="computeroutput">r</code> to string (if possible).
</p></li><li><p>
<span class="strong"><strong>toInteger(r)</strong></span>- Converts the value <code class="computeroutput">r </code> to integer number (if possible).
</p></li><li><p>
<span class="strong"><strong>toDouble(r)</strong></span>- Converts the value <code class="computeroutput">r </code> to double precision floating point
number (if possible).
</p></li></ul></div>
</p></li></ul></div>
</p></td></tr></table></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note: Semantics"><tr><td valign="top" align="center" rowspan="2" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left"><a name="def_PredefinedFunctionCall_Semantics"></a>Semantics</th></tr><tr><td valign="top" align="left"><p>
The native function handling mechanism provides a powerful extension to the
framework. Defining a native function is the way how can be
extended with arbitrary functionality even by the transformation developers.
</p><p>
Note that currently, native functions are stateless, i.e. they do not
preserve their internal state along subsequent calls.
</p></td></tr></table></div><div class="highlights"><a name="def_PredefinedFunctionCall_UsedBy"></a><p><b>Used By:&nbsp;</b>
<a href="def_BaseArithmeticTerm.html" title="5.3.4.&nbsp;Base Arithmetic Term">base arithmetic term</a>
</p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="sec_PredefinedFunctions.html">Prev</a>&nbsp;</td><td align="center" width="20%"><a accesskey="u" href="sec_PredefinedFunctions.html">Up</a></td><td align="right" width="40%">&nbsp;<a accesskey="n" href="sec_NamingVariables.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%">5.6.&nbsp;Predefined Functions&nbsp;</td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%">&nbsp;5.7.&nbsp;Naming and Variables</td></tr></table></div></body></html>