Skip to content

Commit

Permalink
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1039,6 +1039,7 @@ public DynamicObject typeErrorCantCreateInstanceOfSingletonClass(Node currentNod
return typeError("can't create instance of singleton class", currentNode, null);
}

@TruffleBoundary
public DynamicObject typeError(String message, Node currentNode) {
return typeError(message, currentNode, null);
}
Original file line number Diff line number Diff line change
@@ -34,19 +34,21 @@ public abstract class IsANode extends RubyNode {

public IsANode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
metaClassNode = MetaClassNodeGen.create(context, sourceSection, null);
}

public abstract boolean executeIsA(Object self, DynamicObject module);

@Specialization(
limit = "getCacheLimit()",
guards = { "isRubyModule(cachedModule)",
"metaClass(self) == cachedMetaClass", "module == cachedModule" },
guards = {
"isRubyModule(cachedModule)",
"getMetaClass(self) == cachedMetaClass",
"module == cachedModule"
},
assumptions = "getUnmodifiedAssumption(cachedModule)")
public boolean isACached(Object self,
DynamicObject module,
@Cached("metaClass(self)") DynamicObject cachedMetaClass,
@Cached("getMetaClass(self)") DynamicObject cachedMetaClass,
@Cached("module") DynamicObject cachedModule,
@Cached("isA(cachedMetaClass, cachedModule)") boolean result) {
return result;
@@ -58,12 +60,11 @@ public Assumption getUnmodifiedAssumption(DynamicObject module) {

@Specialization(guards = "isRubyModule(module)")
public boolean isAUncached(Object self, DynamicObject module) {
return isA(metaClass(self), module);
return isA(getMetaClass(self), module);
}

@Specialization(guards = "!isRubyModule(module)")
public boolean isATypeError(Object self, DynamicObject module) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(coreLibrary().typeError("class or module required", this));
}

@@ -72,7 +73,12 @@ protected boolean isA(DynamicObject metaClass, DynamicObject module) {
return ModuleOperations.assignableTo(metaClass, module);
}

protected DynamicObject metaClass(Object object) {
protected DynamicObject getMetaClass(Object object) {
if (metaClassNode == null) {
CompilerDirectives.transferToInterpreter();
metaClassNode = insert(MetaClassNodeGen.create(getContext(), getSourceSection(), null));
}

This comment has been minimized.

Copy link
@eregon

eregon Feb 24, 2016

Member

I prefer no empty line here, it's already enough boilerplate IMHO. What do @jruby/truffle think?

This comment has been minimized.

Copy link
@pitr-ch

pitr-ch Feb 24, 2016

Member

I prefer the empty line which separates two logical units, special case for null from the return value.

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Feb 24, 2016

Author Contributor

I think a blank line after } on a line on its own is a common part of many Java style guides.

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Feb 26, 2016

Contributor

My thoughts align with @pitr-ch's.

This comment has been minimized.

Copy link
@eregon

eregon Feb 26, 2016

Member

Damn, I guess I'll lose this one and comply with you three then 😄

return metaClassNode.executeMetaClass(object);
}

0 comments on commit 149bdf9

Please sign in to comment.