本文整理汇总了C#中CodeGenContext.ldsfld方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenContext.ldsfld方法的具体用法?C# CodeGenContext.ldsfld怎么用?C# CodeGenContext.ldsfld使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenContext
的用法示例。
在下文中一共展示了CodeGenContext.ldsfld方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineMethod
internal void DefineMethod(CodeGenContext context)
{
// ... .define_method("MyMethod", MyMethod.singleton, arity, caller);
context.ldstr(method_id.ToString());
context.ldsfld(GenerateClassForMethod(context));
context.ldc_i4(formals.arity);
context.ldloc(0);
context.callvirt(Runtime.Class.define_method);
context.ldnull();
}
示例2: GenCode0
internal override void GenCode0(CodeGenContext context)
{
if (qualified)
if (scope != null)
scope.GenCode(context);
else
context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
else
context.ruby_cbase(parent_scope);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.get_const);
}
示例3: Defined
internal override void Defined(CodeGenContext context)
{
if (qualified)
if (scope != null)
{
// object result;
int result = context.CreateLocal("result", PrimitiveType.Object);
PERWAPI.CILLabel endLabel = context.NewLabel();
// try {
context.StartBlock(Clause.Try);
{
// result = Eval.const_defined(scope, vid, caller);
scope.GenCode(context);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.const_defined);
context.stloc(result);
context.leave(endLabel);
}
TryBlock block = context.EndTryBlock();
// catch (System.Exception) {
context.StartBlock(Clause.Catch);
{
// result = null;
context.ldnull();
context.stloc(result);
context.leave(endLabel);
}
context.EndCatchBlock(Runtime.SystemExceptionRef, block);
context.CodeLabel(endLabel);
context.ldloc(result);
context.ReleaseLocal(result, true);
}
else
{
context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.const_defined);
}
else
{
context.ruby_cbase(parent_scope);
context.ldstr(vid.ToString());
context.ldloc(0);
context.call(Runtime.Eval.const_defined);
}
}
示例4: GenSimple
public void GenSimple(CodeGenContext context)
{
context.ldsfld(field);
}
示例5: GenCode
internal void GenCode(CodeGenContext context, PERWAPI.CILLabel endLabel, int RescueTemp, int exception)
{
for (RESCUE_CLAUSE clause = this; clause != null; clause = clause.next)
{
PERWAPI.CILLabel nextClause = context.NewLabel();
PERWAPI.CILLabel thisClause = context.NewLabel();
context.ldc_i4(0);
LOCAL exceptionCaught = context.StoreInLocal("caught", PERWAPI.PrimitiveType.Boolean, this.location);
for (Node type = clause.types; type != null; type = type.nd_next)
{
PERWAPI.CILLabel label1 = context.NewLabel();
// Precompute each separately to avoid computing a list of types
type.GenCode0(context);
LOCAL tt = context.StoreInLocal("type", PERWAPI.PrimitiveType.Object, type.location);
new METHOD_CALL(tt, ID.intern(Tokens.tEQQ), new AST.LOCAL(exception, type.location), type.location).GenCode(context);
context.ReleaseLocal(tt.local, true);
context.call(Runtime.Eval.Test);
context.brfalse(label1);
context.PushTrue();
context.stloc(exceptionCaught.local);
context.CodeLabel(label1);
}
context.ldloc(exceptionCaught.local);
context.brtrue(thisClause);
context.ReleaseLocal(exceptionCaught.local, true);
context.br(nextClause);
context.CodeLabel(thisClause);
if (clause.var != null)
{
clause.var.Assign(context, new AST.LOCAL(exception, clause.var.location));
context.pop();
}
if (clause.body != null)
clause.body.GenCode(context);
else
context.ldnull();
if (context.Reachable())
context.stloc(RescueTemp);
// reset $!
//Eval.ruby_errinfo.value = null;
context.ldsfld(Runtime.Eval.ruby_errinfo);
context.ldnull();
context.stfld(Runtime.global_variable.value);
context.Goto(endLabel);
context.CodeLabel(nextClause);
}
}
示例6: GenRescue
internal void GenRescue(CodeGenContext context, PERWAPI.CILLabel endLabel, int RescueTemp, RESCUE_CLAUSE clauses)
{
// catch (System.Exception e) {
int e = context.StoreInTemp("e", Runtime.SystemExceptionRef, location);
//if (e is Ruby.ControlException)
PERWAPI.CILLabel else1 = context.NewLabel();
context.ldloc(e);
context.isinst(Runtime.ControlExceptionRef);
context.brfalse(else1);
// throw e;
context.rethrow();
context.CodeLabel(else1);
// Ruby.Exception exception;
int exception = context.CreateLocal("exception", Runtime.ExceptionRef);
//if (!(e is Ruby.RubyException))
PERWAPI.CILLabel else2 = context.NewLabel();
PERWAPI.CILLabel end = context.NewLabel();
context.ldloc(e);
context.isinst(Runtime.RubyExceptionRef);
context.brtrue(else2);
// exception = new Ruby.CLRException(frame, e);
context.ldloc(0);
context.ldloc(e);
context.newobj(Runtime.CLRException.ctor);
context.stloc(exception);
context.br(end);
//else
context.CodeLabel(else2);
// exception = (Ruby.RubyException)e.parent;
context.ldloc(e);
context.cast(Runtime.RubyExceptionRef);
context.ldfld(Runtime.RubyException.parent);
context.stloc(exception);
context.CodeLabel(end);
//Eval.ruby_errinfo.value = exception;
context.ldsfld(Runtime.Eval.ruby_errinfo);
context.ldloc(exception);
context.stfld(Runtime.global_variable.value);
if (clauses != null)
clauses.GenCode(context, endLabel, RescueTemp, exception);
context.rethrow();
context.ReleaseLocal(e, true);
context.ReleaseLocal(exception, true);
}