Thinking about being able to ask whether a pad is dead or a coordinate exists on the board (#249), the most straightforward way is to use is expressions:
if p is not dead { ... }
if (x,y) is on the board { ... }
This is currently defined as
| obj=expr ('is' NOT? | ISNT) pred=expr # is_expr
and the visitor expects the pred expression to compile to something that returns a CallableType that returns Type.BOOL and can take the obj.
There are two things we should do here.
First, if the pred expression returns a BUILTIN, we should type check its overloads and do the right thing, as if it was a function call (possibly negated).
Second, we should allow pred to be an attr, in which case, we should take its which string, prepend something like "#is " so that it won't show up in normal attribute lookups, and then do the lookup (see visitHas_expr() for a model) and possibly negate.
Migrated from internal repository. Originally created by @EvanKirshenbaum on Feb 16, 2023 at 11:09 AM PST.
Thinking about being able to ask whether a pad is dead or a coordinate exists on the board (#249), the most straightforward way is to use
is
expressions:This is currently defined as
and the visitor expects the
pred
expression to compile to something that returns aCallableType
that returnsType.BOOL
and can take theobj
.There are two things we should do here.
First, if the
pred
expression returns aBUILTIN
, we should type check its overloads and do the right thing, as if it was a function call (possibly negated).Second, we should allow
pred
to be anattr
, in which case, we should take itswhich
string, prepend something like"#is "
so that it won't show up in normal attribute lookups, and then do the lookup (seevisitHas_expr()
for a model) and possibly negate.Migrated from internal repository. Originally created by @EvanKirshenbaum on Feb 16, 2023 at 11:09 AM PST.