• Aucun résultat trouvé

Order on scalar and external types

The order on scalar and external types of the SIGNAL language is described in the figureC–V.1. A downward solid arrow (

) links a type with a type directly superior from the same domain (two types of a same domain are comparable); the other arrows represent basic conversions, the semantics of which is described below. The other conversions are obtained by composition of conversions. The partial order is denotedv.

The notion of “comparable types” is extended to arrays and tuples.

event

short

integer

long

real

dreal

complex

dcomplex boolean

char string EXTERNAL_TYPE

Figure C–V.1: Order and conversions on scalar and external types Order on arrays

The order on scalar and external types is extended to arrays:

([0..m11]×. . .×[0..mk1])→µv([0..n11]×. . .×[0..nl1])→ν if and only if

k=l

∗ ∀i 1≤i≤k⇒mi≤ni

andµvν

Order on tuples

A product of types is a type, called tuple type with unnamed fields, which preserves the structuring.

There is no syntactic designation of such a type (it is not possible to declare some object of type tuple with unnamed fields); however, it is possible to manipulate objects of type tuple with unnamed fields (product of types). A tuple with unnamed fields with a single element is considered as isomorphic to this element.

The product of typesµ1, . . . ,µn(in this order) is denoted(µ1×. . .×µn). The order on the types of signals is extended as follows on tuples:

V–6. STRUCTURE OF THE SET OF TYPES 81

The notationµtνis used to designate the upper bound of two comparable typesµandν.

V–6.3 Conversions

A conversion is a function for which the image of an object of the typeµof the argument is an object of the typeνrequired by the context of utilization. The conversion functions for the types defined in the SIGNALlanguage have the name of the reserved designation of the expected type or in general the name of the expected type. In this document, these functions are denoted as follows, in order to describe their semantics:

Cνµ : µ→ν

Direct conversion functions are available in the language, even if their semantics is described in terms of composition of conversions.

3-a Conversions between comparable types

Between two directly comparable types µvν, the two following conversions are defined:

1. the conversionCνµfrom a smaller typeµto a greater typeνlets the values unchanged;

2. the conversionCµν : ν →µwhich is the inverse of the previous one for the values of typeµ.

The conversion functions are extended to any pair of comparable types:

ifν1 vµvν2thenCνν21 = Cνµ2◦ Cµν1 ;

• Cµµis the identity function.

Implicit conversions

The only implicit conversions are the conversions Cνµfor whichµvν. Implicit conversions do not need to be explicited in the language.

3-b Conversions toward the domain “Synchronization-type”

The conversions Ceventµ are defined for eachµ(except ifµis a polychronous tuple); Trivially, they deliver the single value of typeevent.

the conversions Cbooleanµ depend of the implementation while respecting the following rules:

The conversionCbooleanlong verifies:

Cbooleanlong (0) = f alse Cbooleanlong (1) = true

For a Scalar-typeµdistinct fromevent Cbooleanµ = Cbooleanlong ◦ Clongµ

3-c Conversions toward the domain “Integer-type”

The conversions Cshortµ depend of the implementation while respecting the following rules:

• Cshortinteger(v) = vifvis greater thanmin shortand smaller thanmax short(non strictly in both cases),

• Cshortlong = Cshortinteger◦ Clonginteger

for a Scalar-type or ENUMERATED-TYPEµ Cshortµ = Cshortlong ◦ Clongµ

The conversions Cintegerµ depend of the implementation while respecting the following rules:

• Cintegerlong (v) = v ifv is greater thanmin integer and smaller thanmax integer (non strictly in both cases),

for a Scalar-typeµwhich is not smaller thaninteger(for the order defined on the types), or for µan ENUMERATED-TYPE

Cintegerµ = Cintegerlong ◦ Clongµ

The conversions Clongµ depend of the implementation while respecting the following rules:

the conversionClongbooleanis defined by the following rules:

Clongboolean(f alse) = 0 Clongboolean(true) = 1

the value ofClongcharacter(C)is the numerical value of the code of the characterC,

the value ofClongdreal(v) is the integer part nof v ifn is greater thanmin long and smaller than max long(non strictly in both cases),

for a Scalar-typeµwhich is not smaller thanlong(for the order defined on the types) Clongµ = Clongdreal◦ Cdrealµ

for an ENUMERATED-TYPEµequal toA× {a1, . . . , am}, the conversionClongµ is defined by:

Clongµ (a1) = 0, . . . ,Clongµ (am) = m−1.

V–6. STRUCTURE OF THE SET OF TYPES 83

3-d Conversions toward the domain “Real-type”

For each Real-type, a given implementation distinguihes the safe numbers (in the same sense as in Ada), which have an exact representation.

The conversions Crealµ depend of the implementation while respecting the following rules:

ifv, of typedreal, is a safe number in the typereal,Crealdreal(v) = v

the conversion preserves the order on the real numbers included between the smallest and the greatest safe number in the typereal,

for a Scalar-typeµ Crealµ = Crealdreal◦ Cdrealµ

The conversions Cdrealµ depend on the implementation while respecting the following rules:

the conversion preserves the order on the real numbers included between the smallest and the greatest safe number in the typedreal,

• Cdrealdcomplex(re@im) = re

• Cdrealcomplex = Cdrealdcomplex◦ Cdcomplexcomplex

ifv, of typelong, is a safe number in the typedreal,Cdreallong(C) =v

for a Scalar-type distinct of the previous ones, Cdrealµ = Cdreallong ◦ Clongµ

3-e Conversions toward the domain “Complex-type”

There are no conversions toward the domain Complex-type except those internal to that domain. How-ever, a given implementation can provide such conversion functions. Note that the conversion of areal reinto acomplex(respectively, of adreal reinto adcomplex) can be obtained byre@0.0.

The conversion Ccomplexdcomplex depends on the implementation while respecting the following rule:

• Ccomplexdcomplex(re@im) ={Cdrealreal (re),Crealdreal(im)}

3-f Conversions toward the typescharacterandstring

The conversions Ccharacterµ depend on the implementation while respecting the following rules:

the value ofClongcharacter(v)is the character (if it exists) whose decimal value of its code is equal to v,

for a Scalar-typeµCcharacterµ = Ccharacterlong ◦ Clongµ There is no conversion toward the typestring.

3-g Conversions of arrays

For any tuple of strictly positive integersn1, . . . ,nm, and any conversionCνµ, the conversionC(([0..n[0..n1111]]××. . .. . .××[0..n[0..nmm11])])νµis defined by:

C(([0..n[0..n1111]]××. . .. . .××[0..n[0..nmm11])])νµ(T) = Cµν ◦T

3-h Conversions of tuples

Conversions of tuples with unnamed fields

For any conversionsCνµ11, . . . ,Cνµnn, the conversionC((µν11××. . .. . .××νµnn))is defined by:

C((µν11××. . .. . .××νµnn))(x1, . . . , xn)=(Cνµ11(x1), . . . ,Cνµnn(xn))

Conversions of tuples with unnamed fields toward tuples with named fields

For any conversionsCνµ11, . . . ,Cνµnn and any tuple with named fields of type

bundle({X1} →ν1×. . .× {Xm} →νm)that defines a functionΞ(cf. sectionV–5, page76), the conversionCbundle(µ1×. . .({X×1} →µn)ν1×. . .× {Xm} →νm)is defined by:

Cbundle(µ1×. . .({X×1} →µn) ν1×. . .× {Xm} →νm)◦ C((νµ11××. . .. . .××νµnn))

Documents relatifs