Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/v2/extdeps/runtimes/v2_evaluator.dag
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module v2.extdeps.runtimes.v2_evaluator

import v2.std.grammar { node_atom_identity_optional }

import std.occurrence_identity { OccurrenceSynthetic }
import v2.std.collection {
Absent,
Expand Down Expand Up @@ -323,14 +325,14 @@ fn v2_eval_nth_child_target(node: Node, wanted: Int) -> Outcome<Node> {
fn v2_eval_transform_is_int_add(node: Node) -> Bool {
match list_at_optional(xs: node_positional_child_targets(node: node), index: 0) {
Present { value: op_node } =>
match op_node.kind {
TypeNode { connective: Atom { identity: id } } =>
match node_atom_identity_optional(node: op_node) {
Present { value: id } =>
id == ^dag_token_plus
|| canonical_operation_wire_matches_operation(
wire: op_node,
operation: canonical_operation_op_add()
)
_ => false
Absent => false
}
Absent => false
}
Expand Down
14 changes: 8 additions & 6 deletions src/v2/lens/undecidable_verdict_collapse.dag
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module v2.lens.undecidable_verdict_collapse

import v2.std.grammar { node_atom_identity_optional }

import v2.lens.common.construction_justification { ConstructionJustification, WallAfterGrounding }
import std.disposition { SingleAuthority }
import v2.std.witness { Holds, Witness }
Expand Down Expand Up @@ -95,14 +97,14 @@ fn symbol_in_roster(sym: Symbol, roster: List<Symbol>) -> Bool {
// head positional child. Both are read here so the wall does not turn on whether the author
// happened to bind a field.
fn pattern_head_identity_optional(pattern: Node) -> Optional<Symbol> {
match pattern.kind {
TypeNode { connective: Atom { identity: id } } => optional_present(value: id)
_ =>
match node_atom_identity_optional(node: pattern) {
Present { value: id } => optional_present(value: id)
Absent =>
match list_at_optional(xs: node_positional_child_targets(node: pattern), index: 0) {
Present { value: head } =>
match head.kind {
TypeNode { connective: Atom { identity: id } } => optional_present(value: id)
_ => optional_absent()
match node_atom_identity_optional(node: head) {
Present { value: id } => optional_present(value: id)
Absent => optional_absent()
}
Absent => optional_absent()
}
Expand Down
8 changes: 5 additions & 3 deletions src/v2/lens/vacuity.dag
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module v2.lens.vacuity

import v2.std.grammar { node_atom_identity_optional }

import v2.compiler.normalized_tree { NormalizedTree }
import std.dissolution { DissolutionCondition, unbound_dissolution }

Expand Down Expand Up @@ -503,9 +505,9 @@ fn vacuity_transform_operator_symbol_optional(transform: Node) -> Symbol? {
match list_at_optional(xs: node_positional_child_targets(node: transform), index: 0) {
Absent => optional_absent()
Present { value: op_node } =>
match op_node.kind {
TypeNode { connective: Atom { identity: id } } => optional_present(value: id)
_ => optional_absent()
match node_atom_identity_optional(node: op_node) {
Present { value: id } => optional_present(value: id)
Absent => optional_absent()
}
}
}
Expand Down
20 changes: 18 additions & 2 deletions src/v2/std/compilers/target_model.dag
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,23 @@ fn produced_decl_type_tokens_at(
// A function TYPE's domain is lowered two ways: a single parameter type stands as the domain itself
// (`fn(Int) -> R` lowers to Arrow(Int, R)), and several stand as a Conj of their edges. The Conj's
// edges are the parameters; a lone type is one parameter, carried as one positional edge.
// A non-Conj arrow domain is ONE positional parameter edge: the single body every non-Conj
// arm of produced_decl_function_type_domain_edges delegates to.
fn produced_decl_single_domain_edge(domain: Node) -> List<Edge> {
[Edge { label: Positional, target: domain }]
}

fn produced_decl_function_type_domain_edges(arrow: Node, params: List<Edge>) -> List<Edge> {
match list_at_optional(xs: node_positional_child_targets(node: arrow), index: 0) {
Present { value: domain } =>
match domain.kind {
TypeNode { connective: Conj } => params
_ => [Edge { label: Positional, target: domain }]
TypeNode { connective: Atom { identity: _ } } => produced_decl_single_domain_edge(domain: domain)
TypeNode { connective: Disj } => produced_decl_single_domain_edge(domain: domain)
TypeNode { connective: Arrow } => produced_decl_single_domain_edge(domain: domain)
TypeNode { connective: Cardinality } => produced_decl_single_domain_edge(domain: domain)
TypeNode { connective: Instantiation } => produced_decl_single_domain_edge(domain: domain)
ComputationNode { behavior: _ } => produced_decl_single_domain_edge(domain: domain)
}
Absent => params
}
Expand Down Expand Up @@ -15374,7 +15385,12 @@ fn arrow_domain_binder_names(arrow: Node) -> List<Symbol> {
match domain.kind {
TypeNode { connective: Conj } =>
arrow_domain_edge_names(edges: domain.children)
_ => Empty
TypeNode { connective: Atom { identity: _ } } => Empty
TypeNode { connective: Disj } => Empty
TypeNode { connective: Arrow } => Empty
TypeNode { connective: Cardinality } => Empty
TypeNode { connective: Instantiation } => Empty
ComputationNode { behavior: _ } => Empty
}
Absent => Empty
}
Expand Down
32 changes: 17 additions & 15 deletions src/v2/workflow/bash_command_fold_serialize.dag
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module v2.workflow.bash_command_fold_serialize

import v2.std.grammar { node_atom_identity_optional }

import v2.compiler.target_serialize { target_serialize_source_from_model, target_serialize_source_from_selected_row }
import v2.extdeps.languages.bash {
bash_stmt_andor_emitted,
Expand Down Expand Up @@ -86,9 +88,9 @@ fn bash_fold_serialize_emit_from_node(emitted: Node, target: TargetModel) -> Out
fn bash_fold_built_stmt_production_binding(stmt: Node) -> Symbol {
match list_at_optional(xs: node_positional_child_targets(node: stmt), index: 0) {
Present { value: tag } =>
match tag.kind {
TypeNode { connective: Atom { identity: binding } } => binding
_ => ^bash_production_fold_unsupported
match node_atom_identity_optional(node: tag) {
Present { value: binding } => binding
Absent => ^bash_production_fold_unsupported
}
Absent => ^bash_production_fold_unsupported
}
Expand Down Expand Up @@ -182,8 +184,8 @@ fn bash_fold_serialize_with_redir_node(stmt: Node) -> Outcome<String> {
Present { value: inner } =>
match list_at_optional(xs: node_positional_child_targets(node: stmt), index: 2) {
Present { value: redir_tag } =>
match redir_tag.kind {
TypeNode { connective: Atom { identity: redir_binding } } =>
match node_atom_identity_optional(node: redir_tag) {
Present { value: redir_binding } =>
bind_outcome(
o: bash_fold_serialize_node(stmt: inner),
f: fn(stmt_spelling) {
Expand Down Expand Up @@ -241,7 +243,7 @@ fn bash_fold_serialize_with_redir_node(stmt: Node) -> Outcome<String> {
}
}
)
_ => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
}
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_positional_child_absent)
}
Expand All @@ -252,8 +254,8 @@ fn bash_fold_serialize_with_redir_node(stmt: Node) -> Outcome<String> {
fn bash_fold_serialize_word_node(word: Node) -> Outcome<String> {
match list_at_optional(xs: node_positional_child_targets(node: word), index: 0) {
Present { value: kind_node } =>
match kind_node.kind {
TypeNode { connective: Atom { identity: kind } } =>
match node_atom_identity_optional(node: kind_node) {
Present { value: kind } =>
if kind == ^bash_fold_word_kind_lit {
bash_fold_serialize_leaf_node(
emitted: word,
Expand Down Expand Up @@ -297,7 +299,7 @@ fn bash_fold_serialize_word_node(word: Node) -> Outcome<String> {
} else {
bash_fold_serialize_refused(variant: ^bash_fold_serialize_word_kind_unsupported)
}
_ => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
}
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_positional_child_absent)
}
Expand Down Expand Up @@ -344,8 +346,8 @@ fn bash_fold_serialize_command_node(stmt: Node) -> Outcome<String> {
fn bash_fold_serialize_assign_node(stmt: Node) -> Outcome<String> {
match list_at_optional(xs: node_positional_child_targets(node: stmt), index: 1) {
Present { value: name_node } =>
match name_node.kind {
TypeNode { connective: Atom { identity: name } } =>
match node_atom_identity_optional(node: name_node) {
Present { value: name } =>
match list_at_optional(xs: node_positional_child_targets(node: stmt), index: 2) {
Present { value: value } =>
bind_outcome(
Expand All @@ -362,7 +364,7 @@ fn bash_fold_serialize_assign_node(stmt: Node) -> Outcome<String> {
)
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_positional_child_absent)
}
_ => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
}
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_positional_child_absent)
}
Expand All @@ -371,13 +373,13 @@ fn bash_fold_serialize_assign_node(stmt: Node) -> Outcome<String> {
fn bash_fold_serialize_exit_node(stmt: Node) -> Outcome<String> {
match list_at_optional(xs: node_positional_child_targets(node: stmt), index: 1) {
Present { value: code_node } =>
match code_node.kind {
TypeNode { connective: Atom { identity: code } } =>
match node_atom_identity_optional(node: code_node) {
Present { value: code } =>
bash_fold_serialize_emit_from_node(
emitted: bash_stmt_exit_emitted,
target: bash_stmt_exit_target_model(code: code)
)
_ => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_node_shape_refused)
}
Absent => bash_fold_serialize_refused(variant: ^bash_fold_serialize_positional_child_absent)
}
Expand Down
Loading