expressions
The infix method used to write expressions in AVT, i.e. binary operations are written between operands, as in most other programming languages. Unary operations can have both prefix and postfix form. The operands can be identifiers of constants, variables, functions, namespaces, as well as numeric, character and string literals.
In 16-bit and 32-bit programmes, this or that operations become unavailable if the data type to which it can be applied is not available.
Before compiling a binary operation, the AVT defines a common data type for both operands in accordance with these tables and then both operands implicitly casts to that type.
Common data types of operands in 16-bit programmes:
Common data types of operands in 32-bit programmes:
Common data types of operands in 64-bit programmes:
An empty cell in this table indicates incompatibility of types. If you apply an operation to data of such pair of types, then you will get a compilation error.
There are quite a lot of operations in AVT, and this section describes them.
Unary postfix operations
Notation | Name | Description |
. |
Dot | Used to access the structure field or the namespace element. After dot the identifier of structure field or namespace element usually follows. If you want to get the array length, then after dot should be the length identifier.Applicable to types: reference to a structure, reference to array descriptor Also applicable to: namespace identifier |
++ |
Increment | Performs an increase variable value by 1, but the value of variable in expression is a value before the increase. Applicable to types: char , byte , short , int , long , float , double , real |
-- |
Decrement | Performs a decrease variable value by 1, but the value of variable in expression is a value before the decrease. Applicable to types: char , byte , short , int , long , float , double , real |
[index] |
Access to element of array or vector | Access an arbitrary element of array or vector by index. The index is of int type (or short type in 16-bit programmes). All indexes are zero-based.Applicable to types: ultra , xvector , reference to array descriptor |
(arguments) |
Calling a function | Call a function. Arguments are separated by comma. Applicable to types: reference to a function Also applicable to: a function |
new
operations
Notation | Name | Description |
new <structure identifier> |
Create an instance of structure in heap |
Creates a new structure in heap and returns reference to it. It is possible to initialize fields of created structure, for example: Window wnd = new Window { visible = true, enabled = true, width = 240, height = 320, caption = "New window", paint = wndPaint }; |
new type[length][][]…[] |
Create an instance of array in heap |
Creates a new array in heap and returns reference to its descriptor. It is possible to initialize elements of created array instead specifying the length. Examples: short[] a = new short[5]; byte[] b = new byte[] { -3, /*[0]*/ 2, /*[1]*/ 10 /*[2]*/ }; int[][] c = new int[b[1]][]; int[][] d = new int[][] { new int[5], /*[0]*/ null, /*[1]*/ c[1], /*[2]*/ new int[b[2]], /*[3]*/ new int[] { 5, -999 } /*[4]*/ }; |
new ultra {…} new xvector {…} |
Vector literal |
This particular kind of ultra e = new ultra { -5, /*[0]*/ -b[0], /*[1]*/ 0, /*[2]*/ 6 /*[3]*/ }; xvector f = new xvector { 5f, /*[0]*/ -3.3f, /*[1]*/ -2.6f, /*[2]*/ 3.15f /*[3]*/ }; |
Unary prefix operations
Notation | Name | Description |
(type) |
Type cast |
Changes data in such a way that they become another type. For example: float g = -3.94f; int h = (int) g; /* h = -3 */ Applicable to types: any |
~ |
Bitwise NOT | Changes all bits to opposite. Applicable to types: char , byte , short , int , long , ultra |
! |
Logical NOT | Changes boolean value to opposite.Applicable to types: boolean |
+ |
Unary plus | Can be used to change type of expression from char , byte , short to int . In 16-bit programmes, expression type changes to short .Applicable to types: char , byte , short , int , long , float , double , real |
- |
Unary minus | Changes number sign to opposite. Applicable to types: char , byte , short , int , long , float , double , real |
++ |
Increment | Performs an increase variable value by 1. Applicable to types: char , byte , short , int , long , float , double , real |
-- |
Decrement | Performs a decrease variable value by 1. Applicable to types: char , byte , short , int , long , float , double , real |
@@@@ |
Packing of 4-element vector | Performs packing with unsigned saturation of four-element vector. Applicable to types: long , ultra Result type: int , long Requirements: SSE4.1 required for packing an ultra value. |
#### |
Lower unpacking into a 4-element vector | Performs unpacking of bytes or words into lower bits of a four-element vector. Applicable to type: int , long Result type: long , ultra |
^^^^ |
Upper unpacking into a 4-element vector | Performs unpacking of bytes or words into upper bits of a four-element vector. Applicable to type: int , long Result type: long , ultra |
++++ |
Unary plus for 4-element vector | Can be used to change type of expression from char , byte , short , int to long or from float to xvector .Applicable to type: char , byte , short , int , long , ultra , float , xvector |
---- |
Unary minus for 4-element vector | Changes sign of all four elements of vector to opposite. Applicable to type: long , ultra , xvector |
@@..@@ |
Packing of 8-element vector | Performs packing with unsigned saturation of eight-element vector. Applicable to types: ultra Result type: long |
##..## |
Lower unpacking into a 8-element vector | Performs unpacking of bytes into lower bits of a eight-element vector. Applicable to type: long Result type: ultra |
^^..^^ |
Upper unpacking into a 8-element vector | Performs unpacking of bytes into upper bits of a eight-element vector. Applicable to type: long Result type: ultra |
++..++ |
Unary plus for 8-element vector | Can be used to change type of expression from char , byte , short , int , long to ultra Applicable to type: char , byte , short , int , long , ultra |
--..-- |
Unary minus for 8-element vector | Changes sign of all eight elements of vector to opposite. Applicable to type: ultra |
Binary operations
Notation | Name | Description |
= |
Assigning a value | Writes expression value (in second operand) to variable (in first operand). Applicable to types: all |
* *= |
Multiplication | Performs multiplication of two operands without assigning or with value assigning. Applicable to types: short , int , long , float , double , real |
/ /= |
Division | Performs division of first operand by second operand without assigning or with value assigning. For integer data types, the result is rounded toward zero. Applicable to types: short , int , long , float , double , real |
// //= |
Unsigned division | Performs division of first operand by second operand without assigning or with value assigning. If operands have an integer data type, then their values are considered unsigned. Applicable to types: short , int , long , float , double , real |
% %= |
Remainder | Calculates the remainder of dividing first operand by second operand without assigning or with value assigning. Applicable to types: short , int , long , float , double , real |
%% %%= |
Unsigned remainder | Calculates the remainder of dividing first operand by second operand without assigning or with value assigning. If operands have an integer data type, then their values are considered unsigned. Applicable to types: short , int , long , float , double , real |
+ += |
Addition | Adds two operands without assigning or with value assigning. Applicable to types: short , int , long , float , double , real |
- -= |
Subtraction | Performs subtraction of second operand from first operand without assigning or with value assigning. Applicable to types: short , int , long , float , double , real |
>> >>= |
Arithmetic right shift | Performs arithmetic right shift of first operand by number of bits equal second operand without assigning or with value assigning. This operation is equivalent to an integer division by a power of two with rounding towards minus infinity. Type of first operand: short , int , long Type of second operand: short , int |
>>> >>>= |
Unsigned right shift | Performs unsigned right shift of first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: short , int , long Type of second operand: short , int |
<< <<= |
Left shift | Performs left shift of first operand by number of bits equal second operand without assigning or with value assigning. This operation is equivalent to multiplying by a power of two. Type of first operand: short , int , long Type of second operand: short , int |
< > <= >= == != |
Comparison | Compares two operands and returns a boolean value. Each of these six comparison operations performs follows:< : first operand is less than second;> : first operand is greater than second;<= : first operand is less than or equal to second;>= : first operand is greater than or equal to second;== : first operand is equal to second;!= : first operand is not equal to second.Note: when comparing a real number with a «Not-a-Number» (or two «Not-a-Numbers»), the true result takes != only, otherwise is false .Applicable to types: short , int , long , float , double , real == and != applicable to any compatible types. |
& &= |
Bitwise AND | Performs bitwise AND of two operands without assigning or with value assigning. Applicable to types: boolean , short , int , long , ultra |
^ ^= |
Bitwise XOR | Performs bitwise XOR of two operands without assigning or with value assigning. Applicable to types: boolean , short , int , long , ultra |
| |= |
Bitwise OR | Performs bitwise OR of two operands without assigning or with value assigning. Applicable to types: boolean , short , int , long , ultra |
&& |
Logical AND | Performs logical AND of two boolean operands. If first operand given false , then second operand will be omitted (i.e. not computed).Applicable to types: boolean |
|| |
Logical OR | Performs logical OR of two boolean operands. If first operand given true , then second operand will be omitted (i.e. not computed).Applicable to types: boolean |
**** ****= |
Multiplication of 4-element vectors | Performs multiplication of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. Applicable to types: long , ultra , xvector |
***^ ***^= |
Unsigned multiplication of 4-element vectors | Performs unsigned multiplication with saving upper part of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. This operation is equivalent to multiplying vectors with elements in numerical interval [0, 1). Applicable to types: long , ultra |
***| ***|= |
Signed multiplication of 4-element vectors | Performs signed multiplication with saving upper part of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. This operation is equivalent to multiplying vectors with elements in numerical interval [–1, 1). Instruction set: if you allow SSSE3 code generation, then this operation will be done in one assembly instruction. Applicable to types: long |
//// ////= |
Division of 4-element vectors | Performs division of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. Applicable to types: xvector |
++++ ++++= |
Addition of 4-element vectors | Performs addition of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. Applicable to types: long , ultra , xvector |
+++| +++|= |
Addition with signed saturation of 4-element vectors | Performs addition with signed saturation of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. Applicable to types: long |
+++# +++#= |
Addition with unsigned saturation of 4-element vectors | Performs addition with unsigned saturation of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. Applicable to types: long |
---- ----= |
Subtraction of 4-element vectors | Performs subtraction of each vector element in second operand from corresponding vector element in first operand without assigning or with value assigning. Applicable to types: long , ultra , xvector |
---| ---|= |
Subtraction with signed saturation of 4-element vectors | Performs subtraction with signed saturation of each vector element in second operand from corresponding vector element in first operand without assigning or with value assigning. Applicable to types: long |
---# ---#= |
Subtraction with unsigned saturation of 4-element vectors | Performs subtraction with unsigned saturation of each vector element in second operand from corresponding vector element in first operand without assigning or with value assigning. Applicable to types: long |
>>>> >>>>= |
Arithmetic right shift of 4-element vector | Performs arithmetic right shift of each vector element in first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: long , ultra Type of second operand: int |
>>>>> >>>>>= |
Unsigned right shift of 4-element vector | Performs unsigned right shift of each vector element in first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: long , ultra Type of second operand: int |
<<<< <<<<= |
Left shift of 4-element vector | Performs left shift of each vector element in first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: long , ultra Type of second operand: int |
<<|| >>|| <=|| >=|| ==|| !=|| |
Comparison of 4-element vectors | Performs comparison of each vector element in first operand with corresponding vector element in second operand. If comparison condition is true , then value -1 written to corresponding result element, otherwise value 0 .Applicable to types: long , ultra , xvector Result type: long , ultra |
<<||= >>||= <=||= >=||= ==||= !=||= |
Comparison of 4-element vectors with value assigning | Performs comparison of each vector element in first operand with corresponding vector element in second operand with value assigning. If comparison condition is true , then value -1 written to corresponding result element, otherwise value 0 .Applicable to types: long , ultra |
**..** **..**= |
Multiplication of 8-element vectors | Performs multiplication of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. Applicable to types: ultra |
**..*^ **..*^= |
Unsigned multiplication of 8-element vectors | Performs unsigned multiplication with saving upper part of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. This operation is equivalent to multiplying vectors with elements in numerical interval [0, 1). Applicable to types: ultra |
**..*| **..*|= |
Signed multiplication of 8-element vectors | Performs signed multiplication with saving upper part of each vector element in first operand by corresponding vector element in second operand without assigning or with value assigning. This operation is equivalent to multiplying vectors with elements in numerical interval [–1, 1). Instruction set: if you allow SSSE3 code generation, then this operation will be done in one assembly instruction. Applicable to types: ultra |
++..++ ++..++= |
Addition of 8-element vectors | Performs addition of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. Applicable to types: ultra |
++..+| ++..+|= |
Addition with signed saturation of 8-element vectors | Performs addition with signed saturation of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. Applicable to types: ultra |
++..+# ++..+#= |
Addition with unsigned saturation of 8-element vectors | Performs addition with unsigned saturation of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. Applicable to types: ultra |
--..-- --..--= |
Subtraction of 8-element vectors | Performs subtraction of each vector element in second operand from corresponding vector element in first operand without assigning or with value assigning. Applicable to types: ultra |
--..-| --..-|= |
Subtraction with signed saturation of 8-element vectors | Performs subtraction with signed saturation of each vector element in second operand from corresponding vector element in first operand without assigning or with value assigning. Applicable to types: ultra |
--..-# --..-#= |
Subtraction with unsigned saturation of 8-element vectors | Performs subtraction with unsigned saturation of each vector element in second operand from corresponding vector element in first operand without assigning or with value assigning. Applicable to types: ultra |
>>..>> >>..>>= |
Arithmetic right shift of 8-element vector | Performs arithmetic right shift of each vector element in first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: ultra Type of second operand: int |
>>..>>> >>..>>>= |
Unsigned right shift of 8-element vector | Performs unsigned right shift of each vector element in first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: ultra Type of second operand: int |
<<..<< <<..<<= |
Left shift of 8-element vector | Performs left shift of each vector element in first operand by number of bits equal second operand without assigning or with value assigning. Type of first operand: ultra Type of second operand: int |
<<|..| >>|..| <=|..| >=|..| ==|..| !=|..| <<|..|= >>|..|= <=|..|= >=|..|= ==|..|= !=|..|= |
Comparison of 8-element vectors | Performs comparison of each vector element in first operand with corresponding vector element in second operand without assigning or with value assigning. If comparison condition is true , then value -1 written to corresponding result element, otherwise value 0 .Applicable to types: ultra |
Ternary operations
Notation | Name | Description |
?: |
Conditional ternary operation | Writes asa ? b : c and is interpreted as «if a , then b , else c «. The a expression have boolean type, the b and c expressions have compatible types. The a expression computed first. If it is true , then b computed and c omitted. If a expression is false , then b omitted and c computed. |
[Next]