本文整理汇总了C#中CodeGenContext.ReleaseLocal方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenContext.ReleaseLocal方法的具体用法?C# CodeGenContext.ReleaseLocal怎么用?C# CodeGenContext.ReleaseLocal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenContext
的用法示例。
在下文中一共展示了CodeGenContext.ReleaseLocal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Assign
internal override void Assign(CodeGenContext context, Node rhs)
{
// object value = rhs;
bool created;
ISimple value = context.PreCompute(rhs, "rhs", out created);
// thisblock.localsN.SetDynamic("vid", value);
context.ldarg(0);
context.ldfld(block.frameFields[depth - 1]);
context.ldstr(Name);
value.GenSimple(context);
context.call(Runtime.Frame.SetDynamic);
value.GenSimple(context);
context.ReleaseLocal(value, created);
}
示例2: GenCode0
internal override void GenCode0(CodeGenContext context)
{
// String.Concat(String.Concat(arg1, arg2), args, ...);
head.GenCode0(context);
if (head.nd_next != null)
{
int first = context.StoreInTemp("head", Runtime.StringRef, head.location);
for (Node n = head.nd_next; n != null; n = n.nd_next)
{
n.GenCode0(context);
int second = context.StoreInTemp("tail", Runtime.StringRef, n.location);
context.ldloc(first);
context.ldloc(second);
context.callvirt(Runtime.String.Concat);
context.stloc(first);
context.ReleaseLocal(second, true);
}
context.ldloc(first);
context.ReleaseLocal(first, true);
}
}
示例3: GenCall
internal void GenCall(CodeGenContext context)
{
int result = context.CreateLocal("result", PrimitiveType.Object);
PERWAPI.CILLabel endLabel = context.NewLabel();
PERWAPI.CILLabel retryLabel = context.NewLabel();
context.CodeLabel(retryLabel);
context.StartBlock(Clause.Try);
{
// object result = Call(...)
GenCall0(context);
context.stloc(result);
context.Goto(endLabel);
}
PERWAPI.TryBlock tryBlock = context.EndTryBlock();
context.StartBlock(Clause.Catch);
{
CatchBreakException(context, result, endLabel);
}
context.EndCatchBlock(Runtime.BreakExceptionRef, tryBlock);
context.StartBlock(Clause.Catch);
{
CatchRetryException(context, retryLabel);
}
context.EndCatchBlock(Runtime.RetryExceptionRef, tryBlock);
context.CodeLabel(endLabel);
context.ldloc(result);
context.ReleaseLocal(result, true);
}
示例4: GenCode0
internal override void GenCode0(CodeGenContext context)
{
bool created;
ISimple list = GenArgList(context, out created);
list.GenSimple(context);
context.callvirt(Runtime.ArgList.ToRubyObject);
context.ReleaseLocal(list, created);
}
示例5: GenCode0
internal override void GenCode0(CodeGenContext context)
{
bool created;
ISimple left = context.PreCompute(lhs, "lhs", out created);
new COND((Node)left, rhs, (Node)left, location).GenCode(context);
context.ReleaseLocal(left, created);
}
示例6: GenCode0
internal override void GenCode0(CodeGenContext context)
{
if (args != null)
{
bool created;
ISimple list = args.GenArgList(context, out created);
list.GenSimple(context);
context.callvirt(Runtime.ArgList.ToRubyArray);
context.ReleaseLocal(list, created);
}
else
context.newobj(Runtime.Array.ctor);
}
示例7: GenCode0
internal override void GenCode0(CodeGenContext context)
{
PERWAPI.CILLabel finalLabel = context.NewLabel();
int RescueTemp = context.CreateLocal("rescueTemp", PERWAPI.PrimitiveType.Object);
context.ldnull();
context.stloc(RescueTemp);
if (ensure != null)
{
context.StartBlock(Clause.Try); // outer try block with finally
context.StartBlock(Clause.Try); // inner try block with catch
}
GenInnerBlock(context, RescueTemp);
if (ensure != null)
{
context.Goto(finalLabel);
PERWAPI.TryBlock innerTry = context.EndTryBlock();
context.StartBlock(Clause.Catch);
GenRescue(context, null, 0, null);
context.EndCatchBlock(Runtime.SystemExceptionRef, innerTry);
PERWAPI.TryBlock outerTry = context.EndTryBlock();
// Fixme: reset labels to prevent branches out of finally block.
context.StartBlock(Clause.Finally);
ensure.GenCode(context);
if (context.Reachable())
context.pop();
context.endfinally();
context.EndFinallyBlock(outerTry);
context.CodeLabel(finalLabel);
context.newEndPoint(location);
}
context.ldloc(RescueTemp);
context.ReleaseLocal(RescueTemp, true);
}
示例8: CopyOptionalFormals
private void CopyOptionalFormals(CodeGenContext context, Scope scope)
{
for (ASSIGNMENT opt = (ASSIGNMENT)optional; opt != null; opt = (ASSIGNMENT)opt.nd_next)
{
PERWAPI.CILLabel runout_label = context.NewLabel();
PERWAPI.CILLabel end_label = context.NewLabel();
string name = ID.ToDotNetName(((VAR)(opt.lhs)).vid);
Node defaultValue = opt.rhs;
// if (args.RunOut()) goto RunOut
context.ldarg("args");
context.callvirt(Runtime.ArgList.RunOut);
context.brtrue(runout_label);
// locals.name = args.GetNext();
context.ldloc(0);
context.ldarg("args");
context.callvirt(Runtime.ArgList.GetNext);
context.br(end_label);
// RunOut:
context.CodeLabel(runout_label);
// object def = defaultValue;
bool created;
ISimple def = context.PreCompute(defaultValue, "default", out created);
// locals.name = defaultValue
context.ldloc(0);
def.GenSimple(context);
context.ReleaseLocal(def, created);
context.CodeLabel(end_label);
// locals.name = ...
context.stfld(scope.GetFrameField(name));
}
}
示例9: GenArgList
internal override ISimple GenArgList(CodeGenContext context, out bool created)
{
bool single = true;
// ArgList arglist = new ArgList();
context.newobj(Runtime.ArgList.ctor);
int arglist = context.StoreInTemp("arglist", Runtime.ArgListRef, location);
int added = 0;
for (Node arg = parameters; arg != null; arg = arg.nd_next)
{
//object argument = arg;
bool argument_created;
ISimple argument = context.PreCompute0(arg, "arg", out argument_created);
// arglist.Add(argument);
context.ldloc(arglist);
argument.GenSimple(context);
context.callvirt(Runtime.ArgList.Add);
added++;
context.ReleaseLocal(argument, argument_created);
}
if (added != 1)
single = false;
if (hashlist != null)
{
// object hash = hashlist;
bool hash_created;
ISimple hash = context.PreCompute(new HASH(hashlist, hashlist.location), "hashlist", out hash_created);
// arglist.Add(hash);
context.ldloc(arglist);
hash.GenSimple(context);
context.callvirt(Runtime.ArgList.Add);
single = false;
context.ReleaseLocal(hash, hash_created);
}
if (array != null)
{
// object list = array;
bool list_created;
ISimple list = context.PreCompute(array, "array", out list_created);
// arglist.AddArray(list, caller);
context.ldloc(arglist);
list.GenSimple(context);
context.ldloc(0);
context.callvirt(Runtime.ArgList.AddArray);
single = false;
context.ReleaseLocal(list, list_created);
}
if (block != null)
{
// object b = block;
bool b_created;
ISimple b = context.PreCompute(block, "block", Runtime.ProcRef, out b_created);
// arglist.block = b;
context.ldloc(arglist);
b.GenSimple(context);
context.stfld(Runtime.ArgList.block);
context.ReleaseLocal(b, b_created);
}
if (single)
{
context.ldloc(arglist);
context.PushTrue();
context.stfld(Runtime.ArgList.single_arg);
}
created = true;
return new LOCAL(arglist, location);
}
示例10: AddScopeBody
internal void AddScopeBody(CodeGenContext context)
{
returnTemp = context.CreateLocal("returnTemp", PrimitiveType.Object);
context.labels = new Labels();
context.labels.Redo = context.NewLabel();
context.labels.Return = context.NewLabel();
// try { ... }
context.StartBlock(Clause.Try);
{
if (BEGIN != null)
BEGIN.GenCode(context);
context.CodeLabel(context.labels.Redo);
if (body != null)
{
body.GenCode(context);
if (context.Reachable())
context.stloc(returnTemp);
}
context.Goto(context.labels.Return);
}
PERWAPI.TryBlock tryBlock = context.EndTryBlock();
CatchReturnException(context, tryBlock);
// ReturnLabel:
// return returnTemp;
context.CodeLabel(context.labels.Return);
context.newEndPoint(location);
if (context.Method.GetRetType() != PERWAPI.PrimitiveType.Void)
context.ldloc(returnTemp);
context.ret();
context.ReleaseLocal(returnTemp, true);
}
示例11: Assign
internal override void Assign(CodeGenContext context, Node rhs)
{
// Gen right hand sides
ListGen mrhs;
if (rhs is ListGen && !(rhs is MultipleRHS))
mrhs = (ListGen)rhs;
else
mrhs = new ARGS(null, null, rhs, null, location, true);
bool created;
ISimple list = mrhs.GenArgList(context, out created);
list.GenSimple(context);
context.callvirt(Runtime.ArgList.CheckSingleRHS);
int array = context.StoreInTemp("mrhs", Runtime.ArgListRef, location);
context.ReleaseLocal(list, created);
// Gen assignments to left hand sides
for (LVALUE l = elements; l != null; l = (LVALUE)l.nd_next)
{
l.Assign(context, new MultipleRHS(array, l.location));
context.pop();
}
context.ldloc(array);
context.callvirt(Runtime.ArgList.ToRubyArray);
context.ReleaseLocal(array, true);
}
示例12: ArgsPlusRHS
// append rhs to args array
private ISimple ArgsPlusRHS(CodeGenContext context, out bool created)
{
// ArgList temp = args;
ISimple temp = args.GenArgList(context, out created);
// object value = rhs;
bool value_created;
ISimple value = context.PreCompute(rhs, "rhs", out value_created);
// temp.Add(value);
temp.GenSimple(context);
value.GenSimple(context);
context.callvirt(Runtime.ArgList.Add);
context.ReleaseLocal(value, value_created);
return temp;
}
示例13: 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);
}
}
示例14: 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);
}
示例15: 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);
}
}