-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Ibis] Add ibis.this
#5794
[Ibis] Add ibis.this
#5794
Conversation
- Adds an `ibis.this` operation to define the current scope. - Renames `!ibis.classref` to `!ibis.scoperef` since this type must now be able to support both classes and containers - Adds a `ScopeOpInterface` - `ibis.get_parent_of_ref` now can take an explicit type to cast the parent ref to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
parser.parseArgument(thisArg, /*allowType=*/false) || | ||
parser.parseRParen()) | ||
return failure(); | ||
if (std::next(thisOps.begin()) != thisOps.end()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use thisOps.size()
rather than comparing iterators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOps
returns an iterator_range
which has begin, end, empty
. So one can either use std::distance
or the above... went with the above, although std::distance
is probably the better, more readable, option to infer the size.
auto parentScope = | ||
dyn_cast_or_null<ScopeOpInterface>(getOperation()->getParentOp()); | ||
if (!parentScope) | ||
return emitOpError() << "thisOp must be nested in a scope op"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you express this in ODS with HasParent<ScopeOpInterface>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, generated code expects a static getOperationName
to be defined for the type.
ibis.this
operation to define the current scope.!ibis.classref
to!ibis.scoperef
since this type must now be able to support both classes and containersScopeOpInterface
ibis.get_parent_of_ref
now takes an explicit type to cast the parent ref to. In mostclass
cases, this will be an opaque type, but forcontainer
s these will reference the explicit parent type. The obvious benefit of this is that you're able to performget_port
on resolvedscoperef
types.