Skip to content

Commit

Permalink
cut -- Call
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 2, 2023
1 parent fd55018 commit d99a0cf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 3 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# type

`cut` -- `Call`
`cut` -- `PortPush`
`cut` -- `PortReconnect`

`cutDefinition`
`cutDefinition` -- NodeDefinition
`cutDefinition` -- NetDefinition
`cutDefinition` -- OperatorDefinition

`freshenTypes` -- consistently add subscript to type variable names

Expand Down
5 changes: 4 additions & 1 deletion src/lang/cut/cut.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Ctx } from "../ctx"
import { NodeDefinition } from "../definition"
import { Mod } from "../mod"
import { lookupDefinitionOrFail } from "../mod/lookupDefinitionOrFail"
import { Word } from "../word"
import { cutDefinition } from "./cutDefinition"

export interface CutOptions {
current?: {
Expand All @@ -24,7 +26,8 @@ export function cut(
ctx.localSignedTypes.delete(word.name)
return
} else {
//
const definition = lookupDefinitionOrFail(mod, word.name)
cutDefinition(ctx, definition)
return
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/lang/cut/cutDefinition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Ctx } from "../ctx"
import { Definition } from "../definition"

export function cutDefinition(ctx: Ctx, definition: Definition): void {
switch (definition.kind) {
case "NodeDefinition": {
//
return
}

case "NetDefinition": {
//
return
}

case "OperatorDefinition": {
//
return
}

case "TypeDefinition": {
throw new Error(`[cutDefinition] Can not cut a type: ${definition.name}`)
}
}
}

0 comments on commit d99a0cf

Please sign in to comment.