@Override public LocalVariable getImplicitBlockArg() { return getLocalVariable(Variable.BLOCK, 0); }
public static IRScope createScope(IRManager manager, IRScopeType type, RubySymbol name, int line, IRScope lexicalParent, Signature signature, StaticScope staticScope) { switch (type) { case CLASS_BODY: return new IRClassBody(manager, lexicalParent, name, line, staticScope); case METACLASS_BODY: return new IRMetaClassBody(manager, lexicalParent, manager.getMetaClassName(), line, staticScope); case INSTANCE_METHOD: return new IRMethod(manager, lexicalParent, null, name, true, line, staticScope, false); case CLASS_METHOD: return new IRMethod(manager, lexicalParent, null, name, false, line, staticScope, false); case MODULE_BODY: return new IRModuleBody(manager, lexicalParent, name, line, staticScope); case SCRIPT_BODY: return new IRScriptBody(manager, name, staticScope); case FOR: return new IRFor(manager, lexicalParent, line, staticScope, signature); case CLOSURE: return new IRClosure(manager, lexicalParent, line, staticScope, signature); case EVAL_SCRIPT: // SSS FIXME: This is broken right now -- the isModuleEval arg has to be persisted and then read back. return new IREvalScript(manager, lexicalParent, lexicalParent.getFileName(), line, staticScope, EvalType.NONE); } throw new RuntimeException("No such scope type: " + type); } }
public static IRScope createScope(IRManager manager, IRScopeType type, RubySymbol name, int line, IRScope lexicalParent, Signature signature, StaticScope staticScope) { switch (type) { case CLASS_BODY: return new IRClassBody(manager, lexicalParent, name, line, staticScope); case METACLASS_BODY: return new IRMetaClassBody(manager, lexicalParent, manager.getMetaClassName(), line, staticScope); case INSTANCE_METHOD: return new IRMethod(manager, lexicalParent, null, name, true, line, staticScope, false); case CLASS_METHOD: return new IRMethod(manager, lexicalParent, null, name, false, line, staticScope, false); case MODULE_BODY: return new IRModuleBody(manager, lexicalParent, name, line, staticScope); case SCRIPT_BODY: return new IRScriptBody(manager, name, staticScope); case FOR: return new IRFor(manager, lexicalParent, line, staticScope, signature); case CLOSURE: return new IRClosure(manager, lexicalParent, line, staticScope, signature); case EVAL_SCRIPT: // SSS FIXME: This is broken right now -- the isModuleEval arg has to be persisted and then read back. return new IREvalScript(manager, lexicalParent, lexicalParent.getFileName(), line, staticScope, EvalType.NONE); } throw new RuntimeException("No such scope type: " + type); } }
public Operand buildSClass(SClassNode sclassNode) { Operand receiver = build(sclassNode.getReceiverNode()); // FIXME: metaclass name should be a bytelist IRModuleBody body = new IRMetaClassBody(manager, scope, manager.getMetaClassName(), sclassNode.getLine(), sclassNode.getScope()); Variable sClassVar = addResultInstr(new DefineMetaClassInstr(createTemporaryVariable(), receiver, body)); // sclass bodies inherit the block of their containing method Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, scope.getYieldClosureVariable())); newIRBuilder(manager, body).buildModuleOrClassBody(sclassNode.getBodyNode(), sclassNode.getLine(), sclassNode.getEndLine()); return processBodyResult; }
@Override public LocalVariable getImplicitBlockArg() { return getLocalVariable(Variable.BLOCK, 0); }
public Operand buildSClass(SClassNode sclassNode) { Operand receiver = build(sclassNode.getReceiverNode()); // FIXME: metaclass name should be a bytelist IRModuleBody body = new IRMetaClassBody(manager, scope, manager.getMetaClassName(), sclassNode.getLine(), sclassNode.getScope()); Variable sClassVar = addResultInstr(new DefineMetaClassInstr(createTemporaryVariable(), receiver, body)); // sclass bodies inherit the block of their containing method Variable processBodyResult = addResultInstr(new ProcessModuleBodyInstr(createTemporaryVariable(), sClassVar, scope.getYieldClosureVariable())); newIRBuilder(manager, body).buildModuleOrClassBody(sclassNode.getBodyNode(), sclassNode.getLine(), sclassNode.getEndLine()); return processBodyResult; }
public Operand buildSClass(SClassNode sclassNode, IRScope s) { // class Foo // ... // class << self // ... // end // ... // end // // Here, the class << self declaration is in Foo's body. // Foo is the class in whose context this is being defined. Operand receiver = build(sclassNode.getReceiverNode(), s); // Create a dummy meta class and record it as being lexically defined in scope s IRModuleBody mc = new IRMetaClassBody(manager, s, manager.getMetaClassName(), sclassNode.getPosition().getLine(), sclassNode.getScope()); Variable classBody = s.getNewTemporaryVariable(); s.addInstr(new DefineMetaClassInstr(classBody, receiver, mc)); Variable ret = s.getNewTemporaryVariable(); s.addInstr(new ProcessModuleBodyInstr(ret, classBody)); mc.addInstr(new ReceiveSelfInstr(mc.getSelf())); // Set %current_scope = <current-scope> // Set %current_module = <current-module> mc.addInstr(new ReceiveClosureInstr(mc.getImplicitBlockArg())); mc.addInstr(new CopyInstr(mc.getCurrentScopeVariable(), new CurrentScope(mc))); mc.addInstr(new CopyInstr(mc.getCurrentModuleVariable(), new ScopeModule(mc))); // Create a new nested builder to ensure this gets its own IR builder state Operand rv = newIRBuilder(manager).build(sclassNode.getBodyNode(), mc); if (rv != null) mc.addInstr(new ReturnInstr(rv)); return ret; }
public Operand buildSClass(SClassNode sclassNode, IRScope s) { // class Foo // ... // class << self // ... // end // ... // end // // Here, the class << self declaration is in Foo's body. // Foo is the class in whose context this is being defined. Operand receiver = build(sclassNode.getReceiverNode(), s); // Create a dummy meta class and record it as being lexically defined in scope s IRModuleBody mc = new IRMetaClassBody(manager, s, manager.getMetaClassName(), sclassNode.getPosition().getLine(), sclassNode.getScope()); Variable classBody = s.getNewTemporaryVariable(); s.addInstr(new DefineMetaClassInstr(classBody, receiver, mc)); Variable ret = s.getNewTemporaryVariable(); s.addInstr(new ProcessModuleBodyInstr(ret, classBody)); mc.addInstr(new ReceiveSelfInstr(mc.getSelf())); // Set %current_scope = <current-scope> // Set %current_module = <current-module> mc.addInstr(new ReceiveClosureInstr(mc.getImplicitBlockArg())); mc.addInstr(new CopyInstr(mc.getCurrentScopeVariable(), new CurrentScope(mc))); mc.addInstr(new CopyInstr(mc.getCurrentModuleVariable(), new ScopeModule(mc))); // Create a new nested builder to ensure this gets its own IR builder state Operand rv = newIRBuilder(manager).build(sclassNode.getBodyNode(), mc); if (rv != null) mc.addInstr(new ReturnInstr(rv)); return ret; }