-
Notifications
You must be signed in to change notification settings - Fork 8
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
Lower functions to FuTIL's invoke
.
#340
Conversation
So, I think there is a top-level confusion about Components defined by FuTIL (currently) do not support parameters. This means when you see something like:
it should become:
Few code related things that are tripping you up:
Let me know if that makes sense. FuTIL has an invoke test in |
In your example:
This is why I created an The bit about it being a Control is helpful!
Lowered to:
In the following line:
I'm just passing in the emitted ports from the inputs to the |
You will have to walk over the definitions in the program and build a mapping from name to the signature. The |
We should probably remove the magic compilation for |
We should attempt to fix #333 while we're at this. |
Please forgive the Scala lack-of-knowledge hackups. Here's current progress:
=>
Question: How does one write a return type in Dahlia? |
This is looking good! Dahlia return types are written as:
There is going to be some impedance mismatch between To "return" values, |
Ok noted. I've added signatures for the invoked components.
So the above case is hit when I have an expression such as |
Hm, this is going to require some deeper thinking. I think we'll have to make some assumptions. For example, we can say that
And throw an error if we encounter Extra compilers sermon: In general, when building compiler backends, we can make these sorts of assumptions and then write "lowering" passes that bring programs in a desired format. A good way to visualize compilers is a funnel: as we continue compiling programs, they become restricted to smaller and smaller languages and have stronger and stronger assumptions. |
Great thanks Rachit! Compiler sermons are welcome here. |
Progress:
=>
There's one TODO that needs some more thinking.
Perhaps we should have another store for component port definitions? |
Super cool. Just wanted to endorse @rachitnigam's idea here:
Indeed, since we already have in-Dahlia pass infrastructure to hoist these things into something approximating A-normal form, it makes sense to do it again for invocations. This frees us from needing to invent names for the intermediate state when generating the FuTIL. 👍 |
Can you provide some context about this? I don't remember the details of |
Ah, I see. The problem is that function arguments are treated as just another let bound variable and the compiler tries to hook up their One possible trick is to make the case class Store(localVars: Map[CompVar, CompVar], args: Map[CompVar, CompVar]) and change the EVar handling code. An alternative design could be changing sealed trait VType
case object LocalVar extends VType
case object Arg extends VType
type Store = Map[CompVar, (CompVar, VType)] One thing to do regardless is to make I misunderstood your question initially so I wrote a long explanation of how Let me clarify: There is no way to "return" values from an
|
Ok great, that's what I'm doing. I initially was using an object that extends an Enumeration; I'll look into sealed traits after I get that functioning. I think the example of progress I provided above is aligned with what you're saying above. My logic says that if the return value is non-void, add an |
Oh interesting! I didn't know about Enumeration. Scala 2 (current version of Scala), annoyingly, does not have proper Enumerations with pattern match exhaustive checking. Instead people use the The soon-to-be-released Scala 3 has proper enumerations. |
invoke
.invoke
.
We need to do a few things before merging:
|
Corresponding error:
|
For If I'm understanding @sampsyo correctly, A naive approach would just be the preprocessor way of copy-and-paste into the outputted Futil. However, we'd have to take into account the different types. For example, if e.g.
|
While this statement obviously requires further discussion, what we want is parametric polymorphism. |
@cgyurgyik once #346 is implemented, can you add support for generating |
Sure thing. |
Supports Futil imports, making two assumptions:
|
Fixes #339. |
So I've spent some time going over the
FuTIL
backend for Dahlia, as well as Scala. There's still a few things I'm unsure about. I'll try to lay out my thoughts below, and hopefully receive some guidance.invoke
, we need to connectPorts
andPortDefs
, e.g.param = x.out
. I've created a new classInvokeConnect
for this, sinceConnect
is only forPorts
. I'm not entirely sure what the comparisons are for either.Invoke
class, which takes in aCompVar
and aList[InvokeConnect]
.However, this still doesn't do two things. First, give us the input parameters to a function. For example,
List(PortDef(CompVar("x"), 32))
.foo
(or import it iffoo
is imported).I've created a toy program with void output since I'm unsure of the syntax for returning anything other than void:
This lowers to:
Thanks for the help :)