本文整理汇总了C#中Mono.CSharp.EmitContext类的典型用法代码示例。如果您正苦于以下问题:C# EmitContext类的具体用法?C# EmitContext怎么用?C# EmitContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmitContext类属于Mono.CSharp命名空间,在下文中一共展示了EmitContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(EmitContext ec)
{
if (Value)
ec.Emit (OpCodes.Ldc_I4_1);
else
ec.Emit (OpCodes.Ldc_I4_0);
}
示例2: DoResolve
public override Expression DoResolve (EmitContext ec)
{
//
// We are born fully resolved
//
return this;
}
示例3: CloseCompilerGeneratedBlock
public static void CloseCompilerGeneratedBlock(EmitContext ec)
{
if (symwriter != null) {
int offset = symwriter.GetILOffset (ec.ig);
symwriter.CloseCompilerGeneratedBlock (offset);
}
}
示例4: Resolve
public override bool Resolve (EmitContext ec)
{
expr = expr.Resolve (ec);
if (expr == null)
return false;
Report.Debug (64, "RESOLVE YIELD #1", this, ec, expr, expr.GetType (),
ec.CurrentAnonymousMethod, ec.CurrentIterator);
if (!CheckContext (ec, loc))
return false;
Iterator iterator = ec.CurrentIterator;
if (expr.Type != iterator.OriginalIteratorType) {
expr = Convert.ImplicitConversionRequired (
ec, expr, iterator.OriginalIteratorType, loc);
if (expr == null)
return false;
}
if (!ec.CurrentBranching.CurrentUsageVector.IsUnreachable)
unwind_protect = ec.CurrentBranching.AddResumePoint (this, loc, out resume_pc);
return true;
}
示例5: Emit
public override void Emit (EmitContext ec)
{
//
// Emits null pointer
//
ec.Emit (OpCodes.Ldc_I4_0);
ec.Emit (OpCodes.Conv_U);
}
示例6: Emit
public override void Emit (EmitContext ec)
{
if (args != null)
Invocation.EmitArguments (ec, mi, args);
ec.ig.Emit (OpCodes.Call, mi);
return;
}
示例7: Emit
public override void Emit (EmitContext ec)
{
ec.ig.Emit (OpCodes.Ldnull);
#if GMCS_SOURCE
// Only to make verifier happy
if (TypeManager.IsGenericParameter (type))
ec.ig.Emit (OpCodes.Unbox_Any, type);
#endif
}
示例8: Emit
public override void Emit(EmitContext ec)
{
if (statement != null) {
statement.EmitStatement (ec);
ec.Emit (OpCodes.Ret);
return;
}
base.Emit (ec);
}
示例9: Error_ValueCannotBeConverted
public override void Error_ValueCannotBeConverted (EmitContext ec, Location loc, Type target, bool expl)
{
if (!expl && IsLiteral &&
(TypeManager.IsPrimitiveType (target) || type == TypeManager.decimal_type) &&
(TypeManager.IsPrimitiveType (type) || type == TypeManager.decimal_type)) {
Report.Error (31, loc, "Constant value `{0}' cannot be converted to a `{1}'",
AsString (), TypeManager.CSharpName (target));
} else {
base.Error_ValueCannotBeConverted (ec, loc, target, expl);
}
}
示例10: Error_ValueCannotBeConverted
public override void Error_ValueCannotBeConverted (EmitContext ec, Location loc, Type t, bool expl)
{
if (TypeManager.IsGenericParameter (t)) {
Report.Error(403, loc,
"Cannot convert null to the type parameter `{0}' because it could be a value " +
"type. Consider using `default ({0})' instead", t.Name);
} else {
Report.Error(37, loc, "Cannot convert null to `{0}' because it is a value type",
TypeManager.CSharpName(t));
}
}
示例11: CreateExpressionTree
public override Expression CreateExpressionTree (EmitContext ec)
{
if (expr_tree != null)
return expr_tree (ec, mg);
ArrayList args = new ArrayList (arguments.Count + 1);
args.Add (new Argument (new NullLiteral (loc)));
args.Add (new Argument (mg.CreateExpressionTree (ec)));
foreach (Argument a in arguments) {
args.Add (new Argument (a.Expr.CreateExpressionTree (ec)));
}
return CreateExpressionFactoryCall ("Call", args);
}
示例12: DoEmit
protected override void DoEmit(EmitContext ec)
{
if (statement != null) {
statement.EmitStatement (ec);
if (unwind_protect)
ec.Emit (OpCodes.Leave, ec.CreateReturnLabel ());
else {
ec.Emit (OpCodes.Ret);
}
return;
}
base.DoEmit (ec);
}
示例13: MakeSimpleCall
static public Expression MakeSimpleCall (EmitContext ec, MethodGroupExpr mg,
Expression e, Location loc)
{
ArrayList args;
MethodBase method;
args = new ArrayList (1);
args.Add (new Argument (e, Argument.AType.Expression));
method = Invocation.OverloadResolve (ec, (MethodGroupExpr) mg, args, loc);
if (method == null)
return null;
return new StaticCallExpr ((MethodInfo) method, args, loc);
}
示例14: ResolveParameters
protected override Parameters ResolveParameters (EmitContext ec, TypeInferenceContext tic, Type delegateType)
{
if (!TypeManager.IsDelegateType (delegateType))
return null;
AParametersCollection d_params = TypeManager.GetDelegateParameters (delegateType);
if (HasExplicitParameters) {
if (!VerifyExplicitParameters (delegateType, d_params, ec.IsInProbingMode))
return null;
return Parameters;
}
//
// If L has an implicitly typed parameter list we make implicit parameters explicit
// Set each parameter of L is given the type of the corresponding parameter in D
//
if (!VerifyParameterCompatibility (delegateType, d_params, ec.IsInProbingMode))
return null;
Type [] ptypes = new Type [Parameters.Count];
for (int i = 0; i < d_params.Count; i++) {
// D has no ref or out parameters
if ((d_params.FixedParameters [i].ModFlags & Parameter.Modifier.ISBYREF) != 0)
return null;
Type d_param = d_params.Types [i];
#if MS_COMPATIBLE
// Blablabla, because reflection does not work with dynamic types
if (d_param.IsGenericParameter)
d_param = delegateType.GetGenericArguments () [d_param.GenericParameterPosition];
#endif
//
// When type inference context exists try to apply inferred type arguments
//
if (tic != null) {
d_param = tic.InflateGenericArgument (d_param);
}
ptypes [i] = d_param;
((ImplicitLambdaParameter) Parameters.FixedParameters [i]).Type = d_param;
}
Parameters.Types = ptypes;
return Parameters;
}
示例15: GetAttributableValue
public override bool GetAttributableValue (EmitContext ec, Type value_type, out object value)
{
if (value_type == TypeManager.object_type) {
value = GetTypedValue ();
return true;
}
Constant c = ImplicitConversionRequired (ec, value_type, loc);
if (c == null) {
value = null;
return false;
}
value = c.GetTypedValue ();
return true;
}