Inference/src/CodeGeneration/Operations/CGRuntimeFreshTEPromotionOperation.cs
/// <summary>
/// Tries a promotion to a double. We have to generate the promotion code for a char and a int, as both can be
/// promoted to a double
/// </summary>
/// <param name="operand"></param>
/// <returns></returns>
Tries a promotion to a double. We have to generate the promotion code for a char and a int, as both can be
promoted to a double
Tries a promotion to a double . We have to generate the promotion code for a char and a int as both can be promoted to a double
public override object Exec(DoubleType operand, object arg) {
            this.codeGenerator.dup(this.indent);
            this.codeGenerator.isinst(this.indent, CharType.Instance);
            string notACharLabel = this.codeGenerator.NewLabel;
            this.codeGenerator.brfalse(this.indent, notACharLabel);
            this.codeGenerator.UnboxAny(this.indent, CharType.Instance);
            this.codeGenerator.convToDouble(this.indent);
            string endLabel = codeGenerator.NewLabel;
            this.codeGenerator.br(this.indent, endLabel);
            this.codeGenerator.WriteLabel(this.indent, notACharLabel);
            this.codeGenerator.dup(this.indent);
            this.codeGenerator.isinst(this.indent, IntType.Instance);
            string notAInt32Label = this.codeGenerator.NewLabel;
            this.codeGenerator.brfalse(this.indent, notAInt32Label);
            this.codeGenerator.UnboxAny(this.indent, IntType.Instance);
            this.codeGenerator.convToDouble(this.indent);
            this.codeGenerator.br(this.indent, endLabel);
            this.codeGenerator.WriteLabel(this.indent, notAInt32Label);
            this.codeGenerator.UnboxAny(this.indent, DoubleType.Instance);
            this.codeGenerator.WriteLabel(this.indent, endLabel);
            return null;
        }
public override object Exec ( DoubleType operand , object arg ) { this . codeGenerator . dup ( this . indent ) ; this . codeGenerator . isinst ( this . indent , CharType . Instance ) ; string notACharLabel = this . codeGenerator . NewLabel ; this . codeGenerator . brfalse ( this . indent , notACharLabel ) ; this . codeGenerator . UnboxAny ( this . indent , CharType . Instance ) ; this . codeGenerator . convToDouble ( this . indent ) ; string endLabel = codeGenerator . NewLabel ; this . codeGenerator . br ( this . indent , endLabel ) ; this . codeGenerator . WriteLabel ( this . indent , notACharLabel ) ; this . codeGenerator . dup ( this . indent ) ; this . codeGenerator . isinst ( this . indent , IntType . Instance ) ; string notAInt32Label = this . codeGenerator . NewLabel ; this . codeGenerator . brfalse ( this . indent , notAInt32Label ) ; this . codeGenerator . UnboxAny ( this . indent , IntType . Instance ) ; this . codeGenerator . convToDouble ( this . indent ) ; this . codeGenerator . br ( this . indent , endLabel ) ; this . codeGenerator . WriteLabel ( this . indent , notAInt32Label ) ; this . codeGenerator . UnboxAny ( this . indent , DoubleType . Instance ) ; this . codeGenerator . WriteLabel ( this . indent , endLabel ) ; return null ; }
Tries a promotion to a double.
Tries a promotion to a double .
// * char to double or int to double // * If we must promote to an double, a Char or a Int32 could be on the stack
None
operand
DoubleType
None
arg
object