Skip to content

Commit

Permalink
extract parameter/
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Nov 15, 2023
1 parent 1f4f6c8 commit 7e901bb
Show file tree
Hide file tree
Showing 22 changed files with 24 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/lang/apply/applyTypeCtor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { checkTypeTermArgs } from "../check/checkTypeTermArgs"
import { Env } from "../env"
import { EvaluateOptions } from "../evaluate"
import { formatParameters } from "../stmt/formatParameters"
import { formatParameters } from "../parameter"
import { TypeCtor, Value } from "../value"
import { formatValues } from "../value/formatValues"

Expand Down
2 changes: 1 addition & 1 deletion src/lang/check/checkFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Mod } from "../mod"
import { addEdge } from "../net/addEdge"
import { findHalfEdgeEntryOrFail } from "../net/findHalfEdgeEntryOrFail"
import { findHalfEdgePortOrFail } from "../net/findHalfEdgePortOrFail"
import { Parameter } from "../stmt/Parameter"
import { Parameter } from "../parameter"
import { unifyTypes } from "../unify/unifyTypes"
import { Value } from "../value"
import { formatValues } from "../value/formatValues"
Expand Down
3 changes: 1 addition & 2 deletions src/lang/check/checkNodeParameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Mod } from "../mod"
import { Parameter } from "../stmt/Parameter"
import { formatParameters } from "../stmt/formatParameters"
import { Parameter, formatParameters } from "../parameter"

export function checkNodeParameters(
mod: Mod,
Expand Down
3 changes: 1 addition & 2 deletions src/lang/check/checkTypeParameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Mod } from "../mod"
import { Parameter } from "../stmt/Parameter"
import { formatParameters } from "../stmt/formatParameters"
import { Parameter, formatParameters } from "../parameter"

export function checkTypeParameters(mod: Mod, input: Array<Parameter>): void {
for (const parameter of input) {
Expand Down
2 changes: 1 addition & 1 deletion src/lang/definition/Definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Env } from "../env"
import { EvaluateOptions } from "../evaluate"
import { BlockStmt } from "../exp/BlockStmt"
import { Mod } from "../mod"
import { Parameter } from "../parameter"
import { Span } from "../span"
import { Parameter } from "../stmt/Parameter"
import { Value } from "../value"

export type Definition =
Expand Down
2 changes: 1 addition & 1 deletion src/lang/evaluate/evaluateParameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Env } from "../env"
import { Mod } from "../mod"
import { Parameter, ParameterExp } from "../stmt/Parameter"
import { Parameter, ParameterExp } from "../parameter"
import { EvaluateOptions } from "./evaluate"
import { evaluateOne } from "./evaluateOne"

Expand Down
2 changes: 1 addition & 1 deletion src/lang/net/addNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Net, PortRecord } from "../net"
import { Node } from "../node"
import { createNodeId } from "../node/createNodeId"
import { nodeKey } from "../node/nodeKey"
import { Parameter } from "../stmt/Parameter"
import { Parameter } from "../parameter"

export function addNode(
net: Net,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions src/lang/parameter/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from "./Parameter"
export * from "./formatParameter"
export * from "./formatParameterExp"
export * from "./formatParameterWithoutType"
export * from "./formatParameters"
2 changes: 1 addition & 1 deletion src/lang/port/createInputPort.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Node } from "../node"
import { Parameter } from "../stmt/Parameter"
import { Parameter } from "../parameter"
import { Port } from "./Port"

export function createInputPort(node: Node, parameter: Parameter): Port {
Expand Down
2 changes: 1 addition & 1 deletion src/lang/port/createOutputPort.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Node } from "../node"
import { Parameter } from "../stmt/Parameter"
import { Parameter } from "../parameter"
import { Port } from "./Port"

export function createOutputPort(node: Node, parameter: Parameter): Port {
Expand Down
2 changes: 1 addition & 1 deletion src/lang/rule/Rule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BlockStmt } from "../exp/BlockStmt"
import { Mod } from "../mod"
import { ParameterWithoutType } from "../stmt/Parameter"
import { ParameterWithoutType } from "../parameter"

export type RuleTarget = {
name: string
Expand Down
5 changes: 2 additions & 3 deletions src/lang/rule/disconnectNodeAndMatchParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Env } from "../env"
import { defineLocals } from "../env/defineLocals"
import { disconnectNode } from "../net/disconnectNode"
import { Node, formatNode } from "../node"
import { ParameterWithoutType } from "../stmt/Parameter"
import { formatParameterWithoutType } from "../stmt/formatParameterWithoutType"
import { ParameterWithoutType, formatParameterWithoutType } from "../parameter"

export function disconnectNodeAndMatchParameters(
env: Env,
Expand All @@ -22,7 +21,7 @@ export function disconnectNodeAndMatchParameters(
``,
` node: ${formatNode(env.net, node)}`,
` index: ${index}`,
` paramenter: ${formatParameterWithoutType(parameter)}`,
` parameter: ${formatParameterWithoutType(parameter)}`,
].join("\n"),
)
}
Expand Down
6 changes: 3 additions & 3 deletions src/lang/rule/formatRuleTarget.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { formatParameterWithoutType } from "../stmt/formatParameterWithoutType"
import { formatParameterWithoutType } from "../parameter"
import { RuleTarget } from "./Rule"

export function formatRuleTarget(target: RuleTarget): string {
const paramenters = target.parameters
const parameters = target.parameters
.map(formatParameterWithoutType)
.join(", ")

return `${target.name}(${paramenters})`
return `${target.name}(${parameters})`
}
2 changes: 1 addition & 1 deletion src/lang/stmt/Stmt.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Exp } from "../exp"
import { BlockStmt } from "../exp/BlockStmt"
import { ImportBinding } from "../import/ImportBinding"
import { ParameterExp } from "../parameter"
import { RuleTarget } from "../rule"
import { Span } from "../span"
import { ParameterExp } from "./Parameter"

export type Stmt =
| DefineNode
Expand Down
10 changes: 0 additions & 10 deletions src/lang/stmt/formatRuleTarget.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/lang/stmt/formatStmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { indent } from "../../utils/indent"
import { formatExp } from "../exp"
import { formatBlockStmt } from "../exp/formatBlockStmt"
import { formatImportBinding } from "../import/formatImportBinding"
import { formatParameterExp } from "../parameter"
import { formatRuleTarget } from "../rule"
import { Stmt } from "./Stmt"
import { formatParameterExp } from "./formatParameterExp"
import { formatRuleTarget } from "./formatRuleTarget"

export function formatStmt(stmt: Stmt): string {
switch (stmt["@kind"]) {
Expand Down
2 changes: 1 addition & 1 deletion src/lang/syntax/matchers/parameter_matcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as pt from "@cicada-lang/partech"
import { ParameterExp, ParameterWithoutType } from "../../stmt/Parameter"
import { ParameterExp, ParameterWithoutType } from "../../parameter"
import * as matchers from "../matchers"

export function parameter_matcher(tree: pt.Tree): ParameterExp {
Expand Down

0 comments on commit 7e901bb

Please sign in to comment.