• Aucun résultat trouvé

TYPE CHAR(), REC ,

Dans le document IBM System/360 Operating System PL/I (F) (Page 118-122)

DCL I FIXED BIN(31,S) INIT(1);

2 TYPE CHAR(), REC ,

3 A CHAR(S), 3 B CHAR(7), 3 C CHAR(66);

GET EDIT(IN) (A(2) ,A(S) ,A(7) ,A(66»;

In the above example, each format-item/data-field pair is matched separately, code being generated for each matching oper.ation. It would be more efficient to define a character string" on the structure and apply the GET statement to the string:

DCL STRNG CHAR(SO) DEF IN;

GET EDIT (STRNG) (A(SO»;

(Input/output is also discussed in item 2.e., below.)

(27) Many operations which, in earlier versions of the PL/I (F) compiler, were handled by calls to PL/I library routines, are now handled in-line.

The consequent saving in execution time for these operations can be of the order of ten to one or more; the overall effect on program execution will obviously depend on the number of times these operations are used in a program. It will repay the user, therefore* to recognise which opera-tions are performed in-line and which require a library call, and to arrange his program to use the former wherever possible. The majority of these in-line operations are concerned with data conversion and string handling.

Data Conversion:

performed-in-line 25. A conversion condition given, is performed by a

The data conversions are shown in Figure outside the range or or marked 'Not done' library call ..

Not all the picture characters available may be used in a picture involved in an arithmetic converSlono The only ones permitted are:

1.. V and 9

2.. Drifting or non-drifting characters $~

S,+,

-3. Zero suppression characters Z, * 4. Punctuation characters I ' . , / , B

1.

For in-line conversions, pictures with this subset of characters are divided into three types:

Pictures of all 9s with (optionally) a V and a leading or trailing sign.

~xa~le: '99V999', '99', 'S99V9' , '99V+', '$999'

2. Pictures with zero suppresion charac-ters and (optionally) punctuation characters and a sign character.

Also, type 1 pictures with punctuation characters.

~xample: 'ZZZ', '**/**9', 'ZZ9V.99'"

'+ZZ.ZZZ', '$///99', '9.9' 3. Pictures with drifting strings and

(optionally) punctuation characters and a sign character.

Exa~l~: '$$$$', '-,--9', 'S/SS/S9'"

'+++9V.9~,'$$$9-'

r---T---T---,

I Conversion I I Minimum Opti- I

I I I mization Code I

~---T---~ Comnents and Conditions ~---T---~

I Source 1 Target 1 1 SIZE I SIZE I

I I I \Disabled I Enabled 1

~---+---+---+---+---~

FIXED BINARY I 0 0

FIXED DECIMAL If either s~ale factor

=

0 and the! I 1 1 other scale factor ~ 0, then the opt. I

code may be 0

,

I

FIXED BINARY FLOAT If s~urce scale factor

=

0, then thel 1 1 opt. code may be O(whether SIZE isl

enabled or not} I

Bit string String must be fixe1-length, ALIGNED,l I 0 Not done and with length <256 I

Character string Source scale factor must be ~ 0 I I 1 Not done or Picture string must be fixed-length with 1

length <256 Picture types 1, 2 or 3 ,

~---+---+---+---+---~

I IFIXED BINARY IIf source and target scales have thel 0 1

I I Isame sign and are non-zero, then thel

I \ lopt. code (SIZE disabled) must be 1 I

1 1 I I

I I FIXED DECIHAL I I 0 0

1 I 1 I

I FIXED DECIMAL FLOAT Isource precision must be <10 I 1 1

I I I

I Bit string ISource scale factor must be zerol 0 Not done

I ,String must be fixed-length, ALIGNED, I

1 land with length <256 I

I I I

, Character string ISource scale factor must be ~ 01 1 1

I IString must be fixed-length andl

I Ilength <256 I

I I I

1 Picture IPicture types 1, 2 and 3 For picture I 1 Not done

1 I types 1 and 2 with no sign, the Opt. I

, I code may be 0 I

~---+---+---+---+---~

1 I FIXED BINARY I I 1 1 Not done,

I \ I I I 1

, IFIXED DECIMAL ITarget precision must be ~9 I 1 'Not done 1

, I ' I , ,

I FLOAT I FLOAT Isource and target may be single orl 0 I 0 I

I I !1ouble length I 1 1

I I I I I I

I IBit string Istring must be fixed-length, ALIGNED, I 1 INot done 1

I ! land with length <256 I 1 ,

~---+---+---+---+---~

I IFIXED BINARY ISource string must be fixed-length, \ 0 INot done,

I , \ ALIGNED, and with length <256 I I 1

1 I I I 1 1

IBit string \ FIXED DECIMAL \Source must be fixed-length, ALIGNED, \ 1 I Not done I

I \ land I 1 I

I land FLOAT Iwith length <32 I I 1

, ' I I I 1

I I Bit string I Source and target must be ALIGNED I 0 I 0 1

1 I Iwith length <2040 ' "

L _____________ ~ _________________ ~ _____________________________________ ~ ________ ~ ________ J

Figure 25. Implicit Data Conversions Performed In-Line

r---T---T---,

I Conversion I I Minimum Opti- I

I I I mization Code I

~---T---~ Comments and Conditions ~---T---~

I Source I Target I I SIZE I SIZE I

I I I IDisabledlEnabled I

~---+---+---+---+---~

I Character I I I I I

I str ing: I I I I I

IFixed-length ICharacter string: I I I I

I I Fixed-length ITarget length must be ~256 I 0 I 0 I I I VARYING Isource and target lengths must bel 0 I 0 I

I I I ~256 I I I

I I I I I I

I VARYING ICharacter string ISource and target lengths must bel 0 I 0 I

I I 1~256 I I I

I I (VARYING) I I I I

~---+---+---+---+---~

I ICharacter string IString must be fixed-length withl 0 I 0 I

I I Ilength <256 I I I

I P ict ure I I I I I

I I Picture IPictures must be identical I 0 I 0 I

~---+---+---+---+---~

I IFIXED BINARY ISource precision must be <10 I 1 INot done I I I FIXED DECIMAL I I f picture has a sign., then the opt. I 0 I Not done I

I I Icode must be 1 I I I

I Picture I I I I I

I type 1 I I I I I

I I FLOAT ISource precision must be <10 I 1 I Not done I

I I I I I I

I I Picture IPicture types 1, 2 or 3 I 1 I Not done I

~---+---+---+---+---~

I Label ILabel I I 0 I 0 I

~---+---+---+---+---~

I I Pointer/Offset I Pointer/Offset I 0 I 0 I

L _____________ ~ _________________ ~ _____________________________________ ~ ________ ~ ________ J

Figure 25. Implicit Data Conversions Performed In-Line (continued) Sometimes a picture conversion is not

performed in-line even though the pic-ture is one of the above types. This may be because:

1. The optimization code value (OPT=nn) is too low,

2. SIZE is enabled,

3. There is no overlap between the digit positions in the source and target.

Example: DECIMAL (6,8) or DECIMAL (5, -3) to PIC '999V99' will not be performed

4. The picture may have certain charac-teristics that make it difficult to handle in-line.

Example: 'ZZ.99'

a. Punctuation between a drifting Z or a drifting

*

and the first 9 is not preceded by a V

b. Drifting or zero expression char-acters to the right of the decimal point

Example: 'ZZV.ZZ', '++V++'

String Handling: The string functions and operations performed in-line are shown in Figures 26 and 27. It should be noted that even the string func-tions indicated as always being per-formed in-line may sometimes call a library routine. For example, if the expression in the 'BIT or CHAR func-tions requires an implicit conversion not handled in-line, the appropriate library routines will be called.

(27) If a file is declared DIRECT INDEXED, then the ENVIRONMENT options INDEXAREA and NOWRITE should be applied if pos-sible.

c. Decreasing Size of Dictionary

If a compilation overflows the dictiona-ry, the immediate solution is to subdivide the program, recompiling internal proce-dures as separate external proceproce-dures. If this is impracticable or undesirable, the dictionary requirements of the compilation must be reduced. The following cause large

r---T---,

1 String Operation 1 comments and Conditions 1

~---+---T---~

1 Source 1 Target 1

~---+---~

Assign INon-adjustable, ALIGNED. fixed- Non-adjustable, ALIGNED,

fixed-(OPT=O)

length bit string <2048 bits long length bit string <2048 bits long Non-adjustable, ALIGNED, bit

string <2048 bits long

Non-adjustable, UNALIGNED, fixed-length bit string that is a scalar element of an AUTOMATIC, BASED or STATIC structure with no adjustable bounds or extents

Non-adjustable, ALIGNED, VARY-ING bit string <2048 bits long Non-adjustable, UNALIGNED, fixed-length bit string that is a scalar element of an AUTOMATIC, BASED or STATIC structure with no adjustable bounds or extents. The string must be 1 bit long.

Note: The assign- Fixed-length or VARYIN3 Fixed-length or VARYING character ment VARYING string character string <256 characters string <256 characters long

to fixed-length long string is not

handled in-line

~---+---~---~

'And', 'Not', 'Or' 1 Non-adjustable, ALIGNED, fixed-length or VA.qYING bit strings, with

1 length:

1

1 1

fixed-length - <2048 bits VARYING - ~32 bits

Compare INon-adjustable fixed-length character strings <256 characters long

!Non-adjustable, ALIGNED, fixed-length or VARYING bit strings, with Ilength:

1 1

I

fixed-length - <2048 bits VARYING - ~32 bits

Concatenate !Non-adjustable fixej-length or VARYING character strings <256 Icharacters long

1 Non-adjustable, ALIGNED, fixed-length or VARYING bit strings ~32

Ibits long

ISTRING function ! IScalars and non-adjustable contiguous array or structure variables 1

~---~---~

INotes: I

11. Operations with VARYING strings require OPT=l. I

12. If the expression in an IF statement is a bit string satisfying the conditions for I I the source string when OPT=O, then, if the string is <10 bits long, in-line code I

I is generated to test the value of the string. I

L _______________________________________________________________________________________ J

Figure 26. Conditions under which the String Operations are Handled In-Line dictionary requirements, and should

avoided if possible:

(1) Excessive use of labels.

be

(2) Use of structures rather than separate scalar variables.

(3) The LIKE attribute.

(4) CONTROLLED identifiers. If they are necessary, min1m1ze the number of ALLOCATE statements in the program.

(5) Adjustable bounds and string lengths.

(6) The DEFINED attribute.

(7) secon~ary entry points.

(8) Long BCD identifiers.

(9) Expressions as function arguments.

(10) iSUB defining.

(11) Passing subscripted structures or cross-sections of arrays as arguments to procedures.

(12) Explicitly qualified BASED variables.

If i t is necessary to use explicit pointer qualification, m1n1m1ze the number of different pointer variables

used as explicit qualifiers of the same BASED variable.

r---T---,

I String I comments and Conditions I

I Function I I

~---+---~

BIT Always I

BOOL Non-adjustable, ALIGNED bitl I strings, where the third argu-I ment is one of the logical oper-I ators 'and', 'not', 'or' orl

exclusive 'or' I

CHAR Always 1 1

INDEX Second argument must be a non-I I adjustable character string <2561

characters long I

1

LENGTH Always I

SUBSTR STRINGRANGE must be disabled I I

I UNSPEC Always I I

L ________ ~ ________________________________ J

Figure 27. Connitions under which the string Functions are Handled In-Line

(1) Wherever possible, data for computa-tion should be binary, rather than

~lecirnal.

(2) The following character string assign-ment causes a constant of 250 blanks to be generated at compile-time:

DCL A CHAR(250) A='b' ;

To avoid generating such a large con-stant, the coding could be as follows:

DCL A CHAR(250) DCL B CHAR(l);

B=' b' ; A=B;

B is padded, and no constant is gener-ated.

If A had a length of 256 or more, then the assignment would be handled by a library call and a constant with only one blank would be generated at compile-time. In this case, the first coding example would be satisfactory.

(3) If a file declared as INDEXED is to be used for DIRECT UPDATE but will not

have records added to it, the use of the ENVIRONMENT option NOWRITE will save data management about 5000 bytes of storage.

(4) The Alignment Attributes: These allow the user to provide alignment for string and arithmetic data as follows:

ALIGNED: Arithmetic:

FIXED DECIMAL: byte

FLOAT(DOUBLE): doubleword Other: word

String: byte

UNALIGNED: Arithmetic and character string: byte

Bit string: bit

Thus the UNALIGNED attribute can be used to obtain denser packing of data in main storage, with the minimum of padding.

Area, pointer, offset, label, task and event data are always aligned on word or doubleword boundaries (see Figure 49). They can never be UNALIGNED.

In data aggregates, the explicitly declared alignment for the aggregate applies to each element in the aggre-gate. In structures, however, this alignment can be overridden by an alignment specified for a particular base element.

For example:

DCL 1 STR UNALIGNED,

Dans le document IBM System/360 Operating System PL/I (F) (Page 118-122)

Documents relatifs