Skip to content

Commit

Permalink
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/proc/allocate_tags.txt

This file was deleted.

17 changes: 17 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/ProcNodes.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
import org.jruby.truffle.nodes.core.array.ArrayNodes;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.nodes.objects.AllocateObjectNode;
import org.jruby.truffle.nodes.objects.AllocateObjectNodeGen;
import org.jruby.truffle.nodes.yield.YieldDispatchHeadNode;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyArguments;
@@ -78,6 +80,21 @@ public enum Type {
PROC, LAMBDA
}

@CoreMethod(names = "allocate", constructor = true)
public abstract static class AllocateNode extends CoreMethodArrayArgumentsNode {

public AllocateNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject allocate(DynamicObject rubyClass) {
throw new RaiseException(getContext().getCoreLibrary().typeErrorAllocatorUndefinedFor(rubyClass, this));
}

}

@CoreMethod(names = "new", constructor = true, needsBlock = true, rest = true)
public abstract static class ProcNewNode extends CoreMethodArrayArgumentsNode {

Original file line number Diff line number Diff line change
@@ -909,6 +909,12 @@ public DynamicObject typeError(String message, Node currentNode) {
return ExceptionNodes.createRubyException(typeErrorClass, StringNodes.createString(context.getCoreLibrary().getStringClass(), message), RubyCallStack.getBacktrace(currentNode));
}

public DynamicObject typeErrorAllocatorUndefinedFor(DynamicObject rubyClass, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
String className = Layouts.MODULE.getFields(rubyClass).getName();
return typeError(String.format("allocator undefined for %s", className), currentNode);
}

public DynamicObject typeErrorCantDefineSingleton(Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return typeError("can't define singleton", currentNode);

0 comments on commit 539e83a

Please sign in to comment.