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)); } }