本文整理汇总了C#中Pchp.CodeAnalysis.CodeGen.CodeGenerator.Emit_PhpValue_MakeAlias方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.Emit_PhpValue_MakeAlias方法的具体用法?C# CodeGenerator.Emit_PhpValue_MakeAlias怎么用?C# CodeGenerator.Emit_PhpValue_MakeAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.CodeAnalysis.CodeGen.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.Emit_PhpValue_MakeAlias方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: if
void IBoundReference.EmitStore(CodeGenerator cg, TypeSymbol valueType)
{
// Template: array[index]
var isphparr = (this.Array.ResultType == cg.CoreTypes.PhpArray); // whether the target is instance of PhpArray, otherwise it is an IPhpArray and we have to use .callvirt
if (Access.IsWriteRef)
{
// PhpAlias
if (valueType != cg.CoreTypes.PhpAlias)
{
cg.EmitConvertToPhpValue(valueType, 0);
cg.Emit_PhpValue_MakeAlias();
}
// .SetItemAlias(key, alias) or .AddValue(PhpValue.Create(alias))
if (this.Index != null)
{
if (isphparr)
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpArray.SetItemAlias_IntStringKey_PhpAlias);
else
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.IPhpArray.SetItemAlias_IntStringKey_PhpAlias);
}
else
{
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.Create_PhpAlias);
if (isphparr)
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.IPhpArray.AddValue_PhpValue);
else
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpArray.AddValue_PhpValue);
}
}
else if (Access.IsUnset)
{
if (this.Index == null)
throw new InvalidOperationException();
// .RemoveKey(key)
if (isphparr)
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpArray.RemoveKey_IntStringKey);
else
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.IPhpArray.RemoveKey_IntStringKey);
}
else
{
Debug.Assert(Access.IsWrite);
cg.EmitConvertToPhpValue(valueType, 0);
// .SetItemValue(key, value) or .AddValue(value)
if (this.Index != null)
{
if (isphparr)
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.IPhpArray.SetItemValue_IntStringKey_PhpValue);
else
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpArray.SetItemValue_IntStringKey_PhpValue);
}
else
{
if (isphparr)
cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpArray.AddValue_PhpValue);
else
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.IPhpArray.AddValue_PhpValue);
}
}
}
示例2: EmitStore
public virtual void EmitStore(CodeGenerator cg, TypeSymbol valueType)
{
// STACK: <PhpArray> <key>
if (_access.IsWriteRef)
{
// PhpAlias
if (valueType != cg.CoreTypes.PhpAlias)
{
cg.EmitConvertToPhpValue(valueType, 0);
cg.Emit_PhpValue_MakeAlias();
}
// .SetItemAlias(key, alias)
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.PhpArray.SetItemAlias_IntStringKey_PhpAlias);
}
else if (_access.IsUnset)
{
Debug.Assert(valueType == null);
// .RemoveKey(key)
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.PhpArray.RemoveKey_IntStringKey);
}
else
{
Debug.Assert(_access.IsWrite);
cg.EmitConvertToPhpValue(valueType, 0);
// .SetItemValue(key, value)
cg.EmitCall(ILOpCode.Callvirt, cg.CoreMethods.PhpArray.SetItemValue_IntStringKey_PhpValue);
}
}
示例3: EmitLoad
//.........这里部分代码省略.........
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)
{
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Operators.EnsureArray_PhpArrayRef)
.Expect(cg.CoreTypes.PhpArray);
}
else
{
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.Operators.EnsureArray_IPhpArrayRef)
.Expect(cg.CoreTypes.IPhpArray);
}
}
throw new NotImplementedException("EnsureArray(" + type.Name + ")");
}
// Ensure Alias (&$x)
else if (_access.IsReadRef)
{
if (type == cg.CoreTypes.PhpAlias)
{
// TODO: <place>.AddRef()
return _place.EmitLoad(cg.Builder);
}
else if (type == cg.CoreTypes.PhpValue)
{
// return <place>.EnsureAlias()
_place.EmitLoadAddress(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.EnsureAlias)
.Expect(cg.CoreTypes.PhpAlias);
}
else if (type == cg.CoreTypes.PhpNumber)
{
throw new NotImplementedException();
}
else
{
Debug.Assert(false, "value cannot be aliased");
// new PhpAlias((PhpValue)<place>, 1)
cg.EmitConvertToPhpValue(_place.EmitLoad(cg.Builder), 0);
return cg.Emit_PhpValue_MakeAlias();
}
}
// Read Value & Dereference eventually
else
{
if (type == cg.CoreTypes.PhpAlias)
{
_place.EmitLoad(cg.Builder);
if (_access.TargetType == cg.CoreTypes.PhpArray)
{
// <place>.Value.ToArray()
cg.Builder.EmitOpCode(ILOpCode.Ldflda);
cg.EmitSymbolToken(cg.CoreMethods.PhpAlias.Value, null);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.ToArray)
.Expect(cg.CoreTypes.PhpArray);
}
return cg.Emit_PhpAlias_GetValue();
}
else if (type == cg.CoreTypes.PhpValue)
{
if (_access.TargetType == cg.CoreTypes.PhpArray)
{
// <place>.ToArray()
_place.EmitLoadAddress(cg.Builder);
return cg.EmitCall(ILOpCode.Call, cg.CoreMethods.PhpValue.ToArray)
.Expect(cg.CoreTypes.PhpArray);
}
// TODO: dereference if applicable (=> PhpValue.Alias.Value)
return _place.EmitLoad(cg.Builder);
}
else
{
return _place.EmitLoad(cg.Builder);
}
}
}