Skip to content

Commit

Permalink
feat(analyzer): "flow" -> "component" in err msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Oct 27, 2024
1 parent dd73124 commit 75e9d49
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion internal/compiler/analyzer/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (a Analyzer) analyzeComponent(

if isRuntimeFunc && len(runtimeFuncArgs) == 0 {
return src.Component{}, &compiler.Error{
Message: "Flow that use #extern directive must provide at least one argument",
Message: "Component that use #extern directive must provide at least one argument",
Location: &scope.Location,
Meta: &component.Meta,
}
Expand Down
14 changes: 7 additions & 7 deletions internal/compiler/analyzer/main_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ func (a Analyzer) analyzeMainComponent(cmp src.Component, scope src.Scope) *comp
func (a Analyzer) analyzeMainFlowIO(io src.IO) *compiler.Error {
if len(io.In) != 1 {
return &compiler.Error{
Message: fmt.Sprintf("Main flow must have exactly 1 inport: got %v", len(io.In)),
Message: fmt.Sprintf("Main component must have exactly 1 inport: got %v", len(io.In)),
}
}
if len(io.Out) != 1 {
return &compiler.Error{
Message: fmt.Sprintf("Main flow must have exactly 1 outport: got %v", len(io.Out)),
Message: fmt.Sprintf("Main component must have exactly 1 outport: got %v", len(io.Out)),
}
}

enterInport, ok := io.In["start"]
if !ok {
return &compiler.Error{Message: "Main flow must have 'start' inport"}
return &compiler.Error{Message: "Main component must have 'start' inport"}
}

if err := a.analyzeMainComponentPort(enterInport); err != nil {
Expand All @@ -49,7 +49,7 @@ func (a Analyzer) analyzeMainFlowIO(io src.IO) *compiler.Error {

exitOutport, ok := io.Out["stop"]
if !ok {
return &compiler.Error{Message: "Main flow must have 'stop' outport"}
return &compiler.Error{Message: "Main component must have 'stop' outport"}
}

if err := a.analyzeMainComponentPort(exitOutport); err != nil {
Expand All @@ -62,13 +62,13 @@ func (a Analyzer) analyzeMainFlowIO(io src.IO) *compiler.Error {
func (a Analyzer) analyzeMainComponentPort(port src.Port) *compiler.Error {
if port.IsArray {
return &compiler.Error{
Message: "Main flow's ports cannot be arrays",
Message: "Main component's ports cannot be arrays",
Meta: &port.Meta,
}
}
if !(src.Scope{}).IsTopType(port.TypeExpr) {
return &compiler.Error{
Message: "Main flow's ports must be of type any",
Message: "Main component's ports must be of type any",
Meta: &port.Meta,
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func (Analyzer) analyzeMainFlowNodes(

if nodeEntity.Kind != src.ComponentEntity {
return &compiler.Error{
Message: fmt.Sprintf("Main flow's nodes must only refer to flow entities: %v: %v", nodeName, node.EntityRef),
Message: fmt.Sprintf("Main component's nodes must only refer to component entities: %v: %v", nodeName, node.EntityRef),
Location: &loc,
Meta: nodeEntity.Meta(),
}
Expand Down
8 changes: 4 additions & 4 deletions internal/compiler/analyzer/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ func (a Analyzer) getReceiverPortType(
) (ts.Expr, bool, *compiler.Error) {
if receiverSide.Node == "in" {
return ts.Expr{}, false, &compiler.Error{
Message: "Flow cannot read from self inport",
Message: "Component cannot read from self inport",
Location: &scope.Location,
Meta: &receiverSide.Meta,
}
Expand All @@ -919,7 +919,7 @@ func (a Analyzer) getReceiverPortType(
outport, ok := outports[receiverSide.Port]
if !ok {
return ts.Expr{}, false, &compiler.Error{
Message: fmt.Sprintf("Referenced inport not found in flow's interface: %v", receiverSide.Port),
Message: fmt.Sprintf("Referenced inport not found in component's interface: %v", receiverSide.Port),
Location: &scope.Location,
Meta: &receiverSide.Meta,
}
Expand Down Expand Up @@ -1152,7 +1152,7 @@ func (a Analyzer) getPortSenderType(
) (ts.Expr, bool, *compiler.Error) {
if senderSidePortAddr.Node == "out" {
return ts.Expr{}, false, &compiler.Error{
Message: "Flow cannot read from self outport",
Message: "Component cannot read from self outport",
Location: &scope.Location,
Meta: &senderSidePortAddr.Meta,
}
Expand All @@ -1164,7 +1164,7 @@ func (a Analyzer) getPortSenderType(
inport, ok := inports[senderSidePortAddr.Port]
if !ok {
return ts.Expr{}, false, &compiler.Error{
Message: fmt.Sprintf("Referenced inport not found in flow's interface: %v", senderSidePortAddr.Port),
Message: fmt.Sprintf("Referenced inport not found in component's interface: %v", senderSidePortAddr.Port),
Location: &scope.Location,
Meta: &senderSidePortAddr.Meta,
}
Expand Down
12 changes: 6 additions & 6 deletions internal/compiler/analyzer/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (a Analyzer) analyzeNode(

// Now when we have frame made of parent type parameters constraints
// we can resolve cases like `subnode SubFlow<T>`
// where `T` refers to type parameter of the flow/interface we're in.
// where `T` refers to type parameter of the component/interface we're in.
resolvedNodeArgs, err := a.resolver.ResolveExprsWithFrame(
node.TypeArgs,
resolvedParentParamsFrame,
Expand Down Expand Up @@ -185,7 +185,7 @@ func (a Analyzer) analyzeNode(
}

// TODO probably here
// implement interface->flow subtyping
// implement interface->component subtyping
// in a way where FP possible

resolvedFlowDI := make(map[string]src.Node, len(node.Deps))
Expand Down Expand Up @@ -237,7 +237,7 @@ func (a Analyzer) getNodeInterface(

if node.Deps != nil {
return src.Interface{}, &compiler.Error{
Message: "Only flow node can have dependency injection",
Message: "Only component node can have dependency injection",
Location: &location,
Meta: entity.Meta(),
}
Expand All @@ -250,15 +250,15 @@ func (a Analyzer) getNodeInterface(

if usesBindDirective && !hasExternDirective {
return src.Interface{}, &compiler.Error{
Message: "Node can't use #bind if it isn't instantiated with the flow that use #extern",
Message: "Node can't use #bind if it isn't instantiated with the component that use #extern",
Location: &location,
Meta: entity.Meta(),
}
}

if len(externArgs) > 1 && len(resolvedNodeArgs) != 1 {
return src.Interface{}, &compiler.Error{
Message: "Flow that use #extern directive with > 1 argument, must have exactly one type-argument for overloading",
Message: "Component that use #extern directive with > 1 argument, must have exactly one type-argument for overloading",
Location: &location,
Meta: entity.Meta(),
}
Expand All @@ -275,7 +275,7 @@ func (a Analyzer) getNodeInterface(

if len(iface.IO.In) != 0 {
return src.Interface{}, &compiler.Error{
Message: "Flow that uses struct inports directive must have no defined inports",
Message: "Component that uses struct inports directive must have no defined inports",
Location: &location,
Meta: entity.Meta(),
}
Expand Down

0 comments on commit 75e9d49

Please sign in to comment.