C# Class ABT.TypeCast

Inheritance: Expr
Afficher le fichier Open project: phisiart/C-Compiler Class Usage Examples

Méthodes publiques

Свойство Type Description
Expr Expr
Kind TypeCastType

Méthodes publiques

Méthode Description
CGenAddress ( CGenState state ) : void
CGenValue ( CGenState state ) : System.Reg
EqualType ( ExprType t1, ExprType t2 ) : System.Boolean
FloatToArith ( Expr expr, ExprType type ) : Expr

From: float, double To: char, uchar, short, ushort, long, ulong, float, double

According to MSDN "Conversions from Floating-Point Types", float cannot convert to unsigned char. I don't know why, but I follow it.

FromPointer ( Expr expr, ExprType type, Env env ) : Expr

From: pointer To: pointer, integral

IntegralPromotion ( Expr expr ) : ExprTypeKind>.Tuple

All integrals are converted to LongType or ULongType.

MakeCast ( Expr expr, ExprType type ) : Expr
MakeCast ( Expr expr, ExprType type, Env env ) : Expr
SignedIntegralToArith ( Expr expr, ExprType type ) : Expr

From: char, short, long To: char, uchar, short, ushort, long, ulong, float double

ToPointer ( Expr expr, ExprType type, Env env ) : Expr

From: pointer, integral To: pointer

TypeCast ( TypeCastType kind, Expr expr, ExprType type ) : System
UnsignedIntegralToArith ( Expr expr, ExprType type ) : Expr

From: uchar, ushort, ulong To: char, uchar, short, ushort, long, ulong, float, double

Aaccording to MSDN "Conversions from Unsigned Integral Types", unsigned long converts directly to double. However, I just treat unsigned long as long.

UsualArithmeticConversion ( Expr e1, Expr e2 ) : Tuple

Perform the usual arithmetic conversion on two expressions.

If either expression is DoubleType, then both are converted to DoubleType.

Else, if either expression is FloatType, then both are converted to FloatType.

Else, if either expression is ULongType, then both are converted to ULongType.

Else, both are converted to LongType.

UsualScalarConversion ( Expr e1, Expr e2 ) : Tuple

First, convert pointers to ULongType's, then do UsualArithmeticConversion.

Private Methods

Méthode Description
TypeCast ( TypeCastType kind, Expr expr, ExprType type, Env env ) : System

Method Details

CGenAddress() public méthode

public CGenAddress ( CGenState state ) : void
state CodeGeneration.CGenState
Résultat void

CGenValue() public méthode

public CGenValue ( CGenState state ) : System.Reg
state CodeGeneration.CGenState
Résultat System.Reg

EqualType() public static méthode

public static EqualType ( ExprType t1, ExprType t2 ) : System.Boolean
t1 ExprType
t2 ExprType
Résultat System.Boolean

FloatToArith() public static méthode

From: float, double To: char, uchar, short, ushort, long, ulong, float, double
According to MSDN "Conversions from Floating-Point Types", float cannot convert to unsigned char. I don't know why, but I follow it.
public static FloatToArith ( Expr expr, ExprType type ) : Expr
expr Expr
type ExprType
Résultat Expr

FromPointer() public static méthode

From: pointer To: pointer, integral
public static FromPointer ( Expr expr, ExprType type, Env env ) : Expr
expr Expr
type ExprType
env Env
Résultat Expr

IntegralPromotion() public static méthode

All integrals are converted to LongType or ULongType.
public static IntegralPromotion ( Expr expr ) : ExprTypeKind>.Tuple
expr Expr /// The integral expression to be casted. ///
Résultat ExprTypeKind>.Tuple

MakeCast() public static méthode

public static MakeCast ( Expr expr, ExprType type ) : Expr
expr Expr
type ExprType
Résultat Expr

MakeCast() public static méthode

public static MakeCast ( Expr expr, ExprType type, Env env ) : Expr
expr Expr
type ExprType
env Env
Résultat Expr

SignedIntegralToArith() public static méthode

From: char, short, long To: char, uchar, short, ushort, long, ulong, float double
public static SignedIntegralToArith ( Expr expr, ExprType type ) : Expr
expr Expr
type ExprType
Résultat Expr

ToPointer() public static méthode

From: pointer, integral To: pointer
public static ToPointer ( Expr expr, ExprType type, Env env ) : Expr
expr Expr
type ExprType
env Env
Résultat Expr

TypeCast() public méthode

public TypeCast ( TypeCastType kind, Expr expr, ExprType type ) : System
kind TypeCastType
expr Expr
type ExprType
Résultat System

UnsignedIntegralToArith() public static méthode

From: uchar, ushort, ulong To: char, uchar, short, ushort, long, ulong, float, double
Aaccording to MSDN "Conversions from Unsigned Integral Types", unsigned long converts directly to double. However, I just treat unsigned long as long.
public static UnsignedIntegralToArith ( Expr expr, ExprType type ) : Expr
expr Expr
type ExprType
Résultat Expr

UsualArithmeticConversion() public static méthode

Perform the usual arithmetic conversion on two expressions.

If either expression is DoubleType, then both are converted to DoubleType.

Else, if either expression is FloatType, then both are converted to FloatType.

Else, if either expression is ULongType, then both are converted to ULongType.

Else, both are converted to LongType.

public static UsualArithmeticConversion ( Expr e1, Expr e2 ) : Tuple
e1 Expr The first expression to be casted. Must have .
e2 Expr The second expression to be casted. Must have .
Résultat Tuple

UsualScalarConversion() public static méthode

First, convert pointers to ULongType's, then do UsualArithmeticConversion.
public static UsualScalarConversion ( Expr e1, Expr e2 ) : Tuple
e1 Expr /// The first expression to be casted. ///
e2 Expr /// The second expression to be casted. ///
Résultat Tuple

Property Details

Expr public_oe property

public Expr,ABT Expr
Résultat Expr

Kind public_oe property

public TypeCastType Kind
Résultat TypeCastType