internal override void GenCode0(CodeGenContext context) { PERWAPI.CILLabel elseLabel = context.NewLabel(); PERWAPI.CILLabel endLabel = context.NewLabel(); // if (Eval.Test(cond)) context.newLine(cond.location); cond.GenCode(context); context.call(Runtime.Eval.Test); context.brfalse(elseLabel); if (body != null) { context.newStartPoint(body.location); body.GenCode(context); } else context.ldnull(); if (context.Reachable()) context.br(endLabel); context.CodeLabel(elseLabel); if (_else != null) { context.newStartPoint(_else.location); _else.GenCode(context); } else context.ldnull(); context.CodeLabel(endLabel); context.newEndPoint(location); }
internal override void GenCode0(CodeGenContext context) { int receiverLocal = 0; // singleton_class(caller, receiver).define_method(...); context.newStartPoint(location); if (!(receiver is AST.CALL)) { context.ldloc(0); receiver.GenCode(context); } else { receiver.GenCode(context); receiverLocal = context.CreateLocal("receiverLocal", PrimitiveType.Object); context.stloc(receiverLocal); context.ldloc(0); context.ldloc(receiverLocal); } context.call(Runtime.Class.singleton_class); DefineMethod(context); if (receiver is AST.CALL) context.ReleaseLocal(receiverLocal, true); }
internal override void GenCode0(CodeGenContext context) { // ruby_class.define_method(...); context.newStartPoint(location); context.ruby_class(parent_scope); DefineMethod(context); if (CLASS_OR_MODULE.interopClasses.Count > 0) { // BBTAG: remove existing interop method string methodName = Translate(this.method_id); if (CLASS_OR_MODULE.CurrentInteropClass().GetMethod(methodName) != null) CLASS_OR_MODULE.CurrentInteropClass().RemoveMethod(methodName); if (methodName == "initialize") AddInteropConstructor(context); else AddInteropMethod(context); } }
internal void GenCode(CodeGenContext context, PERWAPI.CILLabel endLabel) { PERWAPI.CILLabel elseLabel = context.NewLabel(); context.newLine(comparison.location); // if (comparision.ToRubyArray().includes(true, caller)) bool created; ISimple list = comparison.GenArgList(context, out created); list.GenSimple(context); context.ReleaseLocal(list, created); context.callvirt(Runtime.ArgList.ToRubyArray); new TRUE(comparison.location).GenCode(context); context.ldloc(0); context.callvirt(Runtime.Array.includes); context.brfalse(elseLabel); if (body != null) { context.newStartPoint(body.location); body.GenCode(context); } else context.ldnull(); context.br(endLabel); context.CodeLabel(elseLabel); }
internal override void GenCode0(CodeGenContext context) { Labels original = context.labels; // ---------------- Create new label context for loop ---------------------- context.labels = new Labels(); context.labels.Next = context.NewLabel(); context.labels.Break = context.NewLabel(); context.labels.Redo = context.NewLabel(); context.labels.Retry = context.NewLabel(); context.labels.Return = original.Return; context.CodeLabel(context.labels.Retry); context.newStartPoint(location); context.ldnull(); context.stloc(parent_scope.returnTemp); context.CodeLabel(context.labels.Redo); if (body != null) { body.GenCode(context); if (context.Reachable()) context.pop(); } context.CodeLabel(context.labels.Next); // if (Eval.Test(cond)) context.newLine(cond.location); cond.GenCode(context); context.call(Runtime.Eval.Test); if (whileTrue) context.brtrue(context.labels.Retry); else context.brfalse(context.labels.Retry); context.CodeLabel(context.labels.Break); context.newEndPoint(location); context.ldloc(parent_scope.returnTemp); // --------------------- Restore Label context ------------------------- context.labels = original; }