本文整理汇总了C#中CodeGenContext.ldc_i4方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGenContext.ldc_i4方法的具体用法?C# CodeGenContext.ldc_i4怎么用?C# CodeGenContext.ldc_i4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenContext
的用法示例。
在下文中一共展示了CodeGenContext.ldc_i4方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenSimple
public void GenSimple(CodeGenContext context)
{
if (value is string)// T_STRING,
{
context.ldstr((string)(value));
context.newobj(Runtime.String.ctor);
return;
}
if (value is int) // T_FIXNUM
{
context.ldc_i4((int)(value));
context.box(PrimitiveType.Int32);
return;
}
if (value is double)// T_FLOAT
{
context.ldc_r8((double)(value));
context.newobj(Runtime.Float.ctor);
return;
}
if (value is ID) // T_SYMBOL
{
context.ldstr(((ID)value).ToString());
context.newobj(Runtime.Symbol.ctor);
return;
}
if (value is BigNum)
{
BigNum num = (BigNum) value;
context.ldc_i4(num.sign);
context.ldstr(num.ToString());
context.ldc_i4(num.bas);
context.newobj(Runtime.Bignum.ctor);
return;
}
throw new System.NotImplementedException("VALUE " + value.GetType().ToString());
}
示例2: GenCode0
internal override void GenCode0(CodeGenContext context)
{
MethodDef BlockN_constructor = GenerateClassForMethod(context);
// new Ruby.Proc(recv, block, new BlockN(locals, this.locals1, this.locals2 ...), arity);
context.ldarg("recv"); // recv
LoadBlock(context);
context.ldloc(0); // locals
if (block_parent is BLOCK)
foreach (FieldDef field in ((BLOCK)block_parent).frameFields)
{
// this.localsN
context.ldarg(0);
context.ldfld(field);
}
context.newobj(BlockN_constructor);
context.ldc_i4(arity);
context.newobj(Runtime.Proc.ctor);
}
示例3: 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();
}
示例4: Defined
internal override void Defined(CodeGenContext context)
{
CILLabel endLabel = context.NewLabel();
context.ldloc(0);
context.call(Runtime.Frame.get_Tilde);
context.dup();
context.brfalse(endLabel);
context.ldc_i4(nth);
context.callvirt(Runtime.Match.defined_nth);
context.CodeLabel(endLabel);
}
示例5: SetLine
internal void SetLine(CodeGenContext context)
{
if (location != null)
{
// frame.line = thisline
context.ldloc(0);
context.ldc_i4(this.location.first_line);
context.stfld(Runtime.Frame.line);
}
}
示例6: 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);
}
}
示例7: CopyNormalFormals
private void CopyNormalFormals(CodeGenContext context, Scope scope)
{
PERWAPI.CILLabel OKLabel = context.NewLabel();
if (min_args > 0)
{
// if (args.Length < min_args)
context.ldarg("args");
context.callvirt(Runtime.ArgList.get_Length);
int length = context.StoreInTemp("length", PrimitiveType.Int32, location);
context.ldloc(length);
context.ldc_i4(min_args);
context.bge(OKLabel);
//context.Inst(Op.clt);
//context.brfalse(OKLabel);
// context.Branch(BranchOp.bge, OKLabel);
// throw new ArgumentError(string.Format("wrong number of arguments ({0} for {1})", args.Length, arity).raise(caller);
// FIXME: next line needs a String
context.ldstr("wrong number of arguments ({0} for {1})");
context.ldloc(length);
context.box(PrimitiveType.Int32);
context.ldc_i4(min_args);
context.box(PrimitiveType.Int32);
context.call(Runtime.SystemString.Format);
context.newobj(Runtime.ArgumentError.ctor);
context.ldloc(0);
context.callvirt(Runtime.Exception.raise);
context.throwOp();
context.ReleaseLocal(length, true);
// OKLabel:
context.CodeLabel(OKLabel);
}
// Copy parameters to locals
for (Node f = normal; f != null; f = f.nd_next)
{
string name = ID.ToDotNetName(((VAR)f).vid);
// local.f = args.GetNext();
context.ldloc(0);
context.ldarg("args");
context.callvirt(Runtime.ArgList.GetNext);
context.stfld(scope.GetFrameField(name));
}
}
示例8: GenCode0
internal override void GenCode0(CodeGenContext context)
{
// new Regexp(pattern, options);
if (pattern is VALUE)
context.ldstr(((VALUE)pattern).value.ToString());
else
{
pattern.GenCode(context);
context.callvirt(Runtime.String.ToString);
}
context.ldc_i4(options);
context.newobj(Runtime.Regexp.ctor);
}