Skip to content

Commit

Permalink
wip(interpreter:transformer)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Valeev committed Jul 29, 2023
1 parent aef0351 commit 84148f3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
20 changes: 20 additions & 0 deletions internal/interpreter/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ func (t transformer) Transform(ctx context.Context, ll shared.LowLvlProgram) (ru
})
}

rFuncs := make([]runtime.FuncRoutine, len(ll.Funcs))
for _, f := range ll.Funcs {
io := runtime.FuncIO{
In: map[string][]chan runtime.Msg{},
Out: map[string][]chan runtime.Msg{},
},

rFuncs = append(rFuncs, runtime.FuncRoutine{
Ref: runtime.FuncRef{
Pkg: f.Ref.Pkg,
Name: f.Ref.Name,
},
IO: runtime.FuncIO{
In: map[string][]chan runtime.Msg{},
Out: map[string][]chan runtime.Msg{},
},
Msg: nil,
})
}

return runtime.Program{
Ports: rPorts,
Connections: rConns,
Expand Down
18 changes: 9 additions & 9 deletions internal/shared/highlevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Package struct {
type Entity struct {
Exported bool
Kind EntityKind
Msg Msg
Msg HLMsg
Type ts.Def // FIXME https://github.com/nevalang/neva/issues/186
Interface Interface
Component Component
Expand Down Expand Up @@ -76,19 +76,19 @@ func (e EntityRef) String() string {
return fmt.Sprintf("%s.%s", e.Pkg, e.Name)
}

type Msg struct {
type HLMsg struct {
Ref *EntityRef // if nil then use value
Value MsgValue
}

type MsgValue struct {
TypeExpr ts.Expr // type of the message
Bool bool // only for messages with `bool` type
Int int // only for messages with `int` type
Float float64 // only for messages with `float` type
Str string // only for messages with `str` type
Vec []Msg // only for types with `vec` type
Map map[string]Msg // only for types with `map` type
TypeExpr ts.Expr // type of the message
Bool bool // only for messages with `bool` type
Int int // only for messages with `int` type
Float float64 // only for messages with `float` type
Str string // only for messages with `str` type
Vec []HLMsg // only for types with `vec` type
Map map[string]HLMsg // only for types with `map` type
}

type IO struct {
Expand Down
13 changes: 6 additions & 7 deletions internal/shared/lowlevel.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package shared

type LowLvlProgram struct {
Funcs []LLFunc // what functions to spawn and how
Net []LLConnection // how ports are connected to each other
Consts map[string]LLMsg // predefined data that can be referred by funcs
Ports map[LLPortAddr]uint8 // ports and their buffers size
Funcs []LLFunc // what functions to spawn and how
Net []LLConnection // how ports are connected to each other
Ports map[LLPortAddr]uint8 // ports and their buffers size
}

type LLPortAddr struct {
Expand All @@ -29,9 +28,9 @@ type LLSelector struct {

// LLFunc is a instantiation object that runtime will use to spawn a function
type LLFunc struct {
Ref LLFuncRef // runtime will use this reference to find the function to spawn
IO LLFuncIO // this is the ports function will use to receive and send data
MsgRef string // function can receive predefined message at instantiation time
Ref LLFuncRef // runtime will use this reference to find the function to spawn
IO LLFuncIO // this is the ports function will use to receive and send data
Msg LLMsg // function can receive predefined message at instantiation time
}

type LLFuncRef struct {
Expand Down

0 comments on commit 84148f3

Please sign in to comment.