本文整理汇总了C#中Pchp.CodeAnalysis.CodeGen.CodeGenerator.IsClassOnly方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.IsClassOnly方法的具体用法?C# CodeGenerator.IsClassOnly怎么用?C# CodeGenerator.IsClassOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.CodeAnalysis.CodeGen.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.IsClassOnly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EmitLoad
public TypeSymbol EmitLoad(CodeGenerator cg)
{
Debug.Assert(_access.IsRead);
var type = _place.TypeOpt;
// Ensure Object ($x->.. =)
if (_access.EnsureObject)
{
if (type == cg.CoreTypes.PhpAlias)
{
_place.EmitLoad(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpAlias.EnsureObject)
.Expect(SpecialType.System_Object);
}
else if (type == cg.CoreTypes.PhpValue)
{
_place.EmitLoadAddress(cg.Builder);
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.EnsureObject)
.Expect(SpecialType.System_Object);
if (_thint.IsSingleType && cg.IsClassOnly(_thint))
{
var tref = cg.Routine.TypeRefContext.GetTypes(_thint)[0];
var clrtype = (TypeSymbol)cg.DeclaringCompilation.GetTypeByMetadataName(tref.QualifiedName.ClrName());
if (clrtype != null && !clrtype.IsErrorType() && clrtype != cg.CoreTypes.Object)
{
cg.EmitCastClass(clrtype);
return clrtype;
}
}
return cg.CoreTypes.Object;
}
else if (type.IsOfType(cg.CoreTypes.IPhpArray))
{
// PhpArray -> stdClass
// PhpString -> stdClass (?)
// otherwise keep the instance on stack
throw new NotImplementedException();
}
else
{
if (type.IsReferenceType)
{
if (type == cg.CoreTypes.Object)
{
// Operators.EnsureObject(ref <place>)
_place.EmitLoadAddress(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Operators.EnsureObject_ObjectRef)
.Expect(SpecialType.System_Object);
}
else
{
// <place>
return _place.EmitLoad(cg.Builder);
}
}
else
{
// return new stdClass(ctx)
throw new NotImplementedException();
}
}
}
// Ensure Array ($x[] =)
else if (_access.EnsureArray)
{
if (type == cg.CoreTypes.PhpAlias)
{
// <place>.EnsureArray()
_place.EmitLoad(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpAlias.EnsureArray)
.Expect(cg.CoreTypes.IPhpArray);
}
else if (type == cg.CoreTypes.PhpValue)
{
if (cg.IsArrayOnly(_thint))
{
// uses typehint and accesses .Array directly if possible
// <place>.Array
_place.EmitLoadAddress(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.get_Array)
.Expect(cg.CoreTypes.PhpArray);
}
else
{
// <place>.EnsureArray()
_place.EmitLoadAddress(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.EnsureArray)
.Expect(cg.CoreTypes.IPhpArray);
}
}
else if (type.IsOfType(cg.CoreTypes.IPhpArray))
{
// Operators.EnsureArray(ref <place>)
_place.EmitLoadAddress(cg.Builder);
if (type == cg.CoreTypes.PhpArray)
{
//.........这里部分代码省略.........