本文整理汇总了C#中Pchp.CodeAnalysis.CodeGen.CodeGenerator.EmitConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.EmitConvertToString方法的具体用法?C# CodeGenerator.EmitConvertToString怎么用?C# CodeGenerator.EmitConvertToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.CodeAnalysis.CodeGen.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.EmitConvertToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitAdd
//.........这里部分代码省略.........
{
// r8 + value : r8
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_double_value)
.Expect(SpecialType.System_Double);
}
//
throw new NotImplementedException($"Add(double, {ytype.Name})");
}
else if (xtype.SpecialType == SpecialType.System_Int64)
{
var ytype = cg.EmitConvertIntToLong(cg.Emit(Right)); // int|bool -> long
if (ytype.SpecialType == SpecialType.System_Int64)
{
if (resultTypeOpt != null)
{
if (resultTypeOpt.SpecialType == SpecialType.System_Int64)
{
// (long)(i8 + i8 : number)
il.EmitOpCode(ILOpCode.Add);
return cg.CoreTypes.Long;
}
}
// i8 + i8 : number
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_long_long)
.Expect(cg.CoreTypes.PhpNumber);
}
else if (ytype.SpecialType == SpecialType.System_Double)
{
// i8 + r8 : r8
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_long_double)
.Expect(SpecialType.System_Double);
}
else if (ytype == cg.CoreTypes.PhpNumber)
{
// i8 + number : number
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_long_number)
.Expect(cg.CoreTypes.PhpNumber);
}
else if (ytype == cg.CoreTypes.PhpValue)
{
// i8 + value : number
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_long_value)
.Expect(cg.CoreTypes.PhpNumber);
}
//
throw new NotImplementedException($"Add(int64, {ytype.Name})");
}
else if (xtype == cg.CoreTypes.PhpValue)
{
var ytype = cg.EmitConvertIntToLong(cg.Emit(Right)); // int|bool -> long
// PhpString -> String
if (ytype == cg.CoreTypes.PhpString)
{
cg.EmitConvertToString(ytype, 0);
// continue ...
}
if (ytype.SpecialType == SpecialType.System_Int64)
{
// value + i8 : number
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_value_long)
.Expect(cg.CoreTypes.PhpNumber);
}
else if (ytype.SpecialType == SpecialType.System_Double)
{
// value + r8 : r8
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_value_double)
.Expect(SpecialType.System_Double);
}
else if (ytype == cg.CoreTypes.String)
{
// value + string : number
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_value_string)
.Expect(cg.CoreTypes.PhpNumber);
}
else if (ytype == cg.CoreTypes.PhpNumber)
{
// value + number : number
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_value_number)
.Expect(cg.CoreTypes.PhpNumber);
}
else if (ytype == cg.CoreTypes.PhpValue)
{
// value + value : value
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpNumber.Add_value_value)
.Expect(cg.CoreTypes.PhpValue);
}
//
throw new NotImplementedException($"Add(PhpValue, {ytype.Name})");
}
//
throw new NotImplementedException($"Add({xtype.Name}, ...)");
}