Skip to content

Commit

Permalink
Rename the Typed nodes to Ty nodes (FuelLabs#2954)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyaherbert authored Oct 6, 2022
1 parent 6f1a59f commit 4740fb2
Show file tree
Hide file tree
Showing 69 changed files with 1,455 additions and 1,542 deletions.
6 changes: 3 additions & 3 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use std::{
};
use sway_core::{
semantic_analysis::namespace, source_map::SourceMap, BytecodeOrLib, CompileError,
CompileResult, ParseProgram, TreeType, TypedProgram,
CompileResult, ParseProgram, TreeType, TyProgram,
};
use sway_types::{Ident, JsonABIProgram, JsonTypeApplication, JsonTypeDeclaration};
use sway_utils::constants;
Expand Down Expand Up @@ -1800,7 +1800,7 @@ pub fn compile_ast(
manifest: &ManifestFile,
build_profile: &BuildProfile,
namespace: namespace::Module,
) -> Result<CompileResult<TypedProgram>> {
) -> Result<CompileResult<TyProgram>> {
let source = manifest.entry_string()?;
let sway_build_config =
sway_build_config(manifest.dir(), &manifest.entry_path(), build_profile)?;
Expand Down Expand Up @@ -2338,7 +2338,7 @@ fn update_json_type_declaration(
pub fn check(
plan: &BuildPlan,
terse_mode: bool,
) -> anyhow::Result<CompileResult<(ParseProgram, Option<TypedProgram>)>> {
) -> anyhow::Result<CompileResult<(ParseProgram, Option<TyProgram>)>> {
//TODO remove once type engine isn't global anymore.
sway_core::clear_lazy_statics();
let mut namespace_map = Default::default();
Expand Down
2 changes: 1 addition & 1 deletion forc/src/ops/forc_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use forc_pkg::{self as pkg, ManifestFile};
use std::path::PathBuf;
use sway_core::CompileResult;

pub fn check(command: CheckCommand) -> Result<CompileResult<sway_core::TypedProgram>> {
pub fn check(command: CheckCommand) -> Result<CompileResult<sway_core::TyProgram>> {
let CheckCommand {
path,
offline_mode: offline,
Expand Down
34 changes: 17 additions & 17 deletions sway-core/src/control_flow_analysis/analyze_return_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sway_types::{ident::Ident, span::Span, Spanned};

impl ControlFlowGraph {
pub(crate) fn construct_return_path_graph(
module_nodes: &[TypedAstNode],
module_nodes: &[TyAstNode],
) -> Result<Self, CompileError> {
let mut graph = ControlFlowGraph::default();
// do a depth first traversal and cover individual inner ast nodes
Expand Down Expand Up @@ -120,25 +120,25 @@ enum NodeConnection {
}

fn connect_node(
node: &TypedAstNode,
node: &TyAstNode,
graph: &mut ControlFlowGraph,
leaves: &[NodeIndex],
) -> Result<(NodeConnection, ReturnStatementNodes), CompileError> {
let span = node.span.clone();
match &node.content {
TypedAstNodeContent::Expression(TypedExpression {
expression: TypedExpressionVariant::Return(..),
TyAstNodeContent::Expression(TyExpression {
expression: TyExpressionVariant::Return(..),
..
})
| TypedAstNodeContent::ImplicitReturnExpression(_) => {
| TyAstNodeContent::ImplicitReturnExpression(_) => {
let this_index = graph.add_node(node.into());
for leaf_ix in leaves {
graph.add_edge(*leaf_ix, this_index, "".into());
}
Ok((NodeConnection::Return(this_index), vec![]))
}
TypedAstNodeContent::Expression(TypedExpression {
expression: TypedExpressionVariant::WhileLoop { body, .. },
TyAstNodeContent::Expression(TyExpression {
expression: TyExpressionVariant::WhileLoop { body, .. },
..
}) => {
// This is very similar to the dead code analysis for a while loop.
Expand Down Expand Up @@ -175,7 +175,7 @@ fn connect_node(
inner_returns,
))
}
TypedAstNodeContent::Expression(TypedExpression { .. }) => {
TyAstNodeContent::Expression(TyExpression { .. }) => {
let entry = graph.add_node(node.into());
// insert organizational dominator node
// connected to all current leaves
Expand All @@ -184,22 +184,22 @@ fn connect_node(
}
Ok((NodeConnection::NextStep(vec![entry]), vec![]))
}
TypedAstNodeContent::SideEffect => Ok((NodeConnection::NextStep(leaves.to_vec()), vec![])),
TypedAstNodeContent::Declaration(decl) => Ok((
TyAstNodeContent::SideEffect => Ok((NodeConnection::NextStep(leaves.to_vec()), vec![])),
TyAstNodeContent::Declaration(decl) => Ok((
NodeConnection::NextStep(connect_declaration(node, decl, graph, span, leaves)?),
vec![],
)),
}
}

fn connect_declaration(
node: &TypedAstNode,
decl: &TypedDeclaration,
node: &TyAstNode,
decl: &TyDeclaration,
graph: &mut ControlFlowGraph,
span: Span,
leaves: &[NodeIndex],
) -> Result<Vec<NodeIndex>, CompileError> {
use TypedDeclaration::*;
use TyDeclaration::*;
match decl {
TraitDeclaration(_)
| AbiDeclaration(_)
Expand All @@ -224,7 +224,7 @@ fn connect_declaration(
Ok(leaves.to_vec())
}
ImplTrait(decl_id) => {
let TypedImplTrait {
let TyImplTrait {
trait_name,
methods,
..
Expand All @@ -248,7 +248,7 @@ fn connect_declaration(
fn connect_impl_trait(
trait_name: &CallPath,
graph: &mut ControlFlowGraph,
methods: &[TypedFunctionDeclaration],
methods: &[TyFunctionDeclaration],
entry_node: NodeIndex,
) -> Result<(), CompileError> {
let mut methods_and_indexes = vec![];
Expand Down Expand Up @@ -285,7 +285,7 @@ fn connect_impl_trait(
/// has no entry points, since it is just a declaration.
/// When something eventually calls it, it gets connected to the declaration.
fn connect_typed_fn_decl(
fn_decl: &TypedFunctionDeclaration,
fn_decl: &TyFunctionDeclaration,
graph: &mut ControlFlowGraph,
entry_node: NodeIndex,
_span: Span,
Expand All @@ -311,7 +311,7 @@ fn connect_typed_fn_decl(
type ReturnStatementNodes = Vec<NodeIndex>;

fn depth_first_insertion_code_block(
node_content: &TypedCodeBlock,
node_content: &TyCodeBlock,
graph: &mut ControlFlowGraph,
leaves: &[NodeIndex],
) -> Result<(ReturnStatementNodes, Vec<NodeIndex>), CompileError> {
Expand Down
Loading

0 comments on commit 4740fb2

Please sign in to comment.