Skip to content

Commit

Permalink
[Truffle] Remove abstract non-DSL execute methods in cast and coerce …
Browse files Browse the repository at this point in the history
…nodes.

* They are generated by the DSL anyway and likely remnants when they were not yet DSL nodes.
* execute() is the same when generated, with just an extra try/catch.
* Keep the execute with evaluated values above specializations for consistency.
  • Loading branch information
eregon committed Apr 21, 2015
1 parent 06c53b9 commit b24e393
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 34 deletions.
Expand Up @@ -32,6 +32,8 @@ public BooleanCastNode(BooleanCastNode copy) {
super(copy.getContext(), copy.getSourceSection());
}

public abstract boolean executeBoolean(VirtualFrame frame, Object value);

@Specialization
public boolean doNil(RubyNilClass nil) {
return false;
Expand Down Expand Up @@ -62,14 +64,4 @@ public boolean doBasicObject(RubyBasicObject object) {
return true;
}

@Override
public abstract boolean executeBoolean(VirtualFrame frame);

public abstract boolean executeBoolean(VirtualFrame frame, Object value);

@Override
public final Object execute(VirtualFrame frame) {
return executeBoolean(frame);
}

}
Expand Up @@ -58,6 +58,8 @@ public CmpIntNode(CmpIntNode prev) {
ltNode = prev.ltNode;
}

public abstract int executeCmpInt(VirtualFrame frame, Object value, Object receiver, Object other);

@Specialization
public int cmpInt(int value, Object receiver, Object other) {
if (value > 0) {
Expand Down Expand Up @@ -126,5 +128,4 @@ public int cmpObject(VirtualFrame frame, Object value, Object receiver, Object o
return 0;
}

public abstract int executeIntegerFixnum(VirtualFrame frame, Object value, Object receiver, Object other);
}
Expand Up @@ -74,9 +74,4 @@ public RubyString toSFallback(VirtualFrame frame, Object object) {
}
}

@Override
public final Object execute(VirtualFrame frame) {
return executeRubyString(frame);
}

}
Expand Up @@ -76,11 +76,4 @@ public String coerceObject(VirtualFrame frame, Object object) {
}
}

@Override
public abstract String executeString(VirtualFrame frame);

@Override
public final Object execute(VirtualFrame frame) {
return executeString(frame);
}
}
Expand Up @@ -40,6 +40,8 @@ public ToIntNode(ToIntNode prev) {
super(prev);
}

public abstract int executeInt(VirtualFrame frame, Object object);

@Specialization
public int coerceInt(int value) {
return value;
Expand Down Expand Up @@ -104,5 +106,4 @@ private Object coerceObject(VirtualFrame frame, Object object) {
}
}

public abstract int executeInt(VirtualFrame frame, Object object);
}
Expand Up @@ -37,6 +37,8 @@ public ToStrNode(ToStrNode prev) {
toStrNode = prev.toStrNode;
}

public abstract RubyString executeRubyString(VirtualFrame frame, Object object);

@Specialization
public RubyString coerceRubyString(RubyString string) {
return string;
Expand Down Expand Up @@ -71,13 +73,4 @@ public RubyString coerceObject(VirtualFrame frame, Object object) {
}
}

@Override
public abstract RubyString executeRubyString(VirtualFrame frame);

public abstract RubyString executeRubyString(VirtualFrame frame, Object object);

@Override
public final Object execute(VirtualFrame frame) {
return executeRubyString(frame);
}
}
Expand Up @@ -301,7 +301,7 @@ public Object compare(VirtualFrame frame, RubyString a, Object b) {
cmpIntNode = insert(CmpIntNodeFactory.create(getContext(), getSourceSection(), null, null, null));
}

return -(cmpIntNode.executeIntegerFixnum(frame, cmpResult, a, b));
return -(cmpIntNode.executeCmpInt(frame, cmpResult, a, b));
}

return nil();
Expand Down

0 comments on commit b24e393

Please sign in to comment.