Site Menu Project Specification Implementation Recommendations Reference Needs Updating Work in Progress Wastebasket Wiki Manual |
Synthesis Of Non Scalar Type ConversionWiP.SynthesisOfNonScalarTypeConversion HistoryHide minor edits - Show changes to markup 2010-04-07 16:10
by -
Changed line 18 from:
should be synthesised by the compiler in the event that no direct conversion path exists from type to:
should be synthesised by the compiler in the event that no direct conversion path exists from type 2010-04-07 16:09
by -
Changed line 3 from:
The objective of the facility described here is to facilitate synthesis of type conversion between non-scalar types even if no direct conversion path exists between their component types. to:
The objective of the facility described here is to facilitate synthesis of type conversion between non-scalar types even if no direct conversion path exists between them or their component types. 2010-04-07 16:08
by -
Changed lines 56-57 from:
V.toASCII( (index, v), FALSE, significand, exponent ); (index, w, W.fromASCII( TRUE, significand, exponent )); to:
V.toASCII( (index, v), , significand, exponent ); (index, w, W.fromASCII( , significand, exponent )); Changed line 61 from:
where to:
where 2010-04-07 16:04
by -
Changed line 63 from:
NB: For the compiler to save stack space for the intermediate strings significand and exponent a means to obtain the exact required number of digits for a scalar type could be introduced. This is an optimisation issue and it has no impact on the semantics of the synthesis. to:
NB: For the compiler to save stack space for the intermediate strings 2010-04-07 16:04
by -
Changed line 22 from:
The key to synthesising such a conversion is to decompose to:
The key to synthesising such a conversion is to decompose 2010-04-07 16:03
by -
Changed lines 50-52 from:
index : CARDINAL;
significand,
exponent : ARRAY OF CHAR;
to:
index : CARDINAL;
significand,
exponent : ARRAY OF CHAR;
2010-04-07 16:03
by -
Changed lines 44-45 from:
[@ VAR v : V; w : W; to:
[@VAR v : V; w : W; Changed lines 49-54 from:
[@ VAR v : V; w : W; index : CARDINAL;
significand,
exponent : ARRAY OF CHAR;
to:
[@VAR v : V; w : W; index : CARDINAL;
significand,
exponent : ARRAY OF CHAR;
Changed lines 59-60 from:
END; (* IF *) @] to:
END; (* IF *)@] 2010-04-07 16:00
by -
Changed line 22 from:
The key to synthesising such a conversion is to decompose to:
The key to synthesising such a conversion is to decompose 2010-04-07 15:57
by -
Changed line 5 from:
Given variables to:
Given 2010-04-07 15:56
by -
Added lines 1-66:
ObjectiveThe objective of the facility described here is to facilitate synthesis of type conversion between non-scalar types even if no direct conversion path exists between their component types. Given variables TYPE V = OPAQUE RECORD ("V-Type") v1, v2, v3 : T1 END; W = OPAQUE RECORD ("V-Type") v1, v2, v3 : T2 END; VAR v : V; w : W; the conversion from
should be synthesised by the compiler in the event that no direct conversion path exists from type ApproachThe key to synthesising such a conversion is to decompose To facilitate this, the non-scalar types must provide
The component type can be deduced form the return type of the accessor function. This could be done using the following bindings: PROCEDURE [HIGH] highestComponentIndex ( v : VECTOR ) : CARDINAL; PROCEDURE [.] componentN ( n : CARDINAL; v : VECTOR ) : ComponentType; PROCEDURE [!] setComponentN ( n : CARDINAL; VAR v : VECTOR; c : ComponentType ); An example is given in TypeSampleVector The generalised synthesis algorithm is: VAR v : V; w : W; w := v :: W; synthesises to => VAR v : V; w : W; index : CARDINAL; significand, exponent : ARRAY %MAX_LITERAL_LENGTH% OF CHAR; IF HIGH(v) = HIGH(w) THEN FOR index := 0 TO HIGH(v) DO V.toASCII( %ACCESSOR%(index, v), FALSE, significand, exponent ); %MUTATOR%(index, w, W.fromASCII( TRUE, significand, exponent )); END; (* FOR *) END; (* IF *) where NB: For the compiler to save stack space for the intermediate strings significand and exponent a means to obtain the exact required number of digits for a scalar type could be introduced. This is an optimisation issue and it has no impact on the semantics of the synthesis. |