Class SVM_CONVERT
SVM-INSTRUCTION: CONVERT fromType toType
Runtime Stack
..., tos →
..., result
The 'tos' is popped off the Runtime stack.
The 'result' is calculated by converting tos 'toType'.
Then the 'result' is pushed onto the Runtime Stack.
Not all conversions are valid, see the table below. An attempt to perform an invalid conversion is an error.
The conversion performed will in some cases be illegal because of the actual value;
Conversion from a GADDR to OADDR (AADDR) means: take the object address (attribute address) part of the general address and return as result. An object address OADDR may be converted to a general address GADDR. In that case the object address is extended with an empty attribute address and the pair comprises the result.
REAL (LREAL) to INT conversion is performed after the rule: INT = entier( REAL + 0.5 ).
L A O G P R
to: B C R R S A A A A A
O H I E E I D D D D D
O A N A A Z D D D D D
from: L R T L L E R R R R R
BOOL .
CHAR . +
INT ? . ? ?
REAL ? . ?
LREAL ? ? .
SIZE .
AADDR .
OADDR . +
GADDR + + .
PADDR .
RADDR .
Table of legal conversions
. - always a legal conversion, but a null operation
+ - always legal and exact
? - the legality depends on the actual value being converted.
Loss of accuracy is not considered an error when converting
from integer values to real values. In other cases execution
time checks may have to be inserted in order to avoid loss of
information due to truncation.
blank - always illegal.
Link to GitHub: Source File.
- Author:
- S-Port: Definition of S-code, Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe fromTypeprivate final intThe toTypeFields inherited from class SVM_Instruction
iADD, iADDREG, iAND, iASSIGN, iCALL, iCALLSYS, iCOMPARE, iCONVERT, iDECO, iDIST, iDIV, iDUP, iENTER, iEQV, iGETO, iGOTO, iIMP, iINCO, iINITO, iJUMP, iJUMPIF, iLINE, iLOAD, iLOADA, iMax, iMULT, iNEG, iNOOP, iNOT, iOR, iPOPK, iPRECALL, iPUSHC, iPUSHLEN, iPUSHR, iREM, iRESTORE, iRETURN, iSAVE, iSETO, iSHIFT, iSTORE, iSUB, iSWITCH, iXOR, opcode -
Constructor Summary
ConstructorsConstructorDescriptionSVM_CONVERT(int fromType, int toType) Construct a new SVM_CONVERT instruction -
Method Summary
Modifier and TypeMethodDescriptionprivate static ValueConvert a Valuevoidexecute()Execute this SVM instructionstatic SVM_Instructionread(AttributeInputStream inpt) Reads an SVM_CONVERT instruction from the given input.toString()voidwrite(AttributeOutputStream oupt) Write this SVM instruction to the given output.Methods inherited from class SVM_Instruction
edOpcode, readObject
-
Field Details
-
fromType
private final int fromTypeThe fromType -
toType
private final int toTypeThe toType
-
-
Constructor Details
-
SVM_CONVERT
public SVM_CONVERT(int fromType, int toType) Construct a new SVM_CONVERT instruction- Parameters:
fromType- the fromTypetoType- the toType
-
-
Method Details
-
execute
public void execute()Description copied from class:SVM_InstructionExecute this SVM instruction- Overrides:
executein classSVM_Instruction
-
convValue
-
toString
-
write
Description copied from class:SVM_InstructionWrite this SVM instruction to the given output.- Overrides:
writein classSVM_Instruction- Parameters:
oupt- the output stream- Throws:
IOException- if IOException occur
-
read
Reads an SVM_CONVERT instruction from the given input.- Parameters:
inpt- the input stream- Returns:
- the SVM_CONVERT instruction read
- Throws:
IOException- if IOException occur
-