本文整理汇总了C#中Pchp.CodeAnalysis.CodeGen.CodeGenerator.EmitLoadDefault方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenerator.EmitLoadDefault方法的具体用法?C# CodeGenerator.EmitLoadDefault怎么用?C# CodeGenerator.EmitLoadDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.CodeAnalysis.CodeGen.CodeGenerator
的用法示例。
在下文中一共展示了CodeGenerator.EmitLoadDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
internal override void Emit(CodeGenerator cg)
{
cg.EmitSequencePoint(this.PhpSyntax);
var rtype = cg.Routine.ReturnType;
var rvoid = rtype.SpecialType == SpecialType.System_Void;
//
if (this.Returned == null)
{
if (rvoid)
{
// <void>
}
else
{
// <default>
cg.EmitLoadDefault(rtype, cg.Routine.ResultTypeMask);
}
}
else
{
if (rvoid)
{
// <expr>;
cg.EmitPop(this.Returned.Emit(cg));
}
else
{
// return (T)<expr>;
cg.EmitConvert(this.Returned, rtype);
}
}
// .ret
cg.EmitRet(rtype);
}
示例2: EmitInit
void EmitInit(Emit.PEModuleBuilder module, DiagnosticBag diagnostic, PhpCompilation compilation, SynthesizedStaticLocHolder holder, BoundExpression initializer)
{
var loctype = holder.ValueField.Type;
bool requiresContext = initializer != null && initializer.RequiresContext;
if (requiresContext)
{
// emit Init only if it needs Context
holder.EmitInit(module, (il) =>
{
var cg = new CodeGenerator(il, module, diagnostic, OptimizationLevel.Release, false,
holder.ContainingType, new ArgPlace(compilation.CoreTypes.Context, 1), new ArgPlace(holder, 0));
var valuePlace = new FieldPlace(cg.ThisPlaceOpt, holder.ValueField);
// Template: this.value = <initilizer>;
valuePlace.EmitStorePrepare(il);
cg.EmitConvert(initializer, valuePlace.TypeOpt);
valuePlace.EmitStore(il);
//
il.EmitRet(true);
});
}
// default .ctor
holder.EmitCtor(module, (il) =>
{
if (!requiresContext)
{
// emit default value only if it won't be initialized by Init above
var cg = new CodeGenerator(il, module, diagnostic, OptimizationLevel.Release, false,
holder.ContainingType, null, new ArgPlace(holder, 0));
var valuePlace = new FieldPlace(cg.ThisPlaceOpt, holder.ValueField);
// Template: this.value = default(T);
valuePlace.EmitStorePrepare(il);
if (initializer != null)
{
cg.EmitConvert(initializer, valuePlace.TypeOpt);
}
else
{
cg.EmitLoadDefault(valuePlace.TypeOpt, 0);
}
valuePlace.EmitStore(il);
}
//
il.EmitRet(true);
});
}