HPInc / HP-Digital-Microfluidics

HP Digital Microfluidics Software Platform and Libraries
MIT License
2 stars 0 forks source link

`is` expressions with attributes/built-ins #250

Open EvanKirshenbaum opened 5 months ago

EvanKirshenbaum commented 5 months ago

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.