This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dev:crosscompiler:strings [2015/04/06 16:14] – [Erzeugung] ursgraf | dev:crosscompiler:strings [2016/02/25 13:33] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 20: | Line 20: | ||
The field //size// holds the number of bytes of the whole object. This is analogous to other objects (see [[dev: | The field //size// holds the number of bytes of the whole object. This is analogous to other objects (see [[dev: | ||
- | ===== Erzeugung | + | ===== Creation |
The Bytecode for the creation of a string is | The Bytecode for the creation of a string is | ||
< | < | ||
Line 44: | Line 44: | ||
* initialize the string. | * initialize the string. | ||
Finally, the reference to the newly created string has to be put into the result register of the //sCnew// instruction. | Finally, the reference to the newly created string has to be put into the result register of the //sCnew// instruction. | ||
- | ===== Feldzugriffe | + | ===== Access to Fields |
- | Sobald auf Felder des Stringarrays zugegriffen werden soll, muss das im Codegenerator speziell berücksichtigt werden. Ein solcher Zugriff hat in der SSA die Form | + | When accessing fields of a string, the code generator has to modify the code. Such an access shows up in the SSA as follows |
< | < | ||
1: MonadicRef[sCloadFromField] {0} < | 1: MonadicRef[sCloadFromField] {0} < | ||
Line 51: | Line 51: | ||
3: Dyadic[sCloadFromArray] {1, 2} (Char) | 3: Dyadic[sCloadFromArray] {1, 2} (Char) | ||
</ | </ | ||
- | Zuerst wird also das Feld // | + | The field // |
- | Analog muss auch das Schreiben auf die Stringzeichen angepasst werden. Hier gibt es aber noch eine Besonderheit. Weil Strings immutable sind, werden nur beim Initialisieren | + | Similarly, writing to a string must be customized. However, strings in java are immutable. Writing to strings happens only in the factory methods during initialization. Checking for array index out of bounds may be ommited as well. |
===== Constant String ===== | ===== Constant String ===== | ||
- | Constant strings are stored in the constant block of a class, see [[Linker32]]. The layout there must be identical to the layout on the heap as given above. | + | Constant strings are stored in the constant block of a class, see [[dev: |
===== Special Linking ===== | ===== Special Linking ===== | ||
The type descriptor of the class //String// must have its field // | The type descriptor of the class //String// must have its field // |