Fmt all the old code.

This commit is contained in:
Jesse Brault 2026-03-04 22:15:39 -06:00
parent b4ebee0c34
commit 19194271aa
53 changed files with 228 additions and 200 deletions

View File

@ -1,5 +1,7 @@
use crate::spec::polymorphic_enum_inner_build::{
PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind,
};
use convert_case::{Case, Casing};
use crate::spec::polymorphic_enum_inner_build::{PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
@ -8,7 +10,8 @@ pub fn make_polymorphic_enum_inner_build_ast_node_impl(
) -> TokenStream {
let type_ident = format_ident!("{}", spec.name());
let match_arms = spec.members()
let match_arms = spec
.members()
.map(|member| {
let member_ident = format_ident!("{}", member.name());
match member.kind() {
@ -29,7 +32,8 @@ pub fn make_polymorphic_enum_inner_build_ast_node_impl(
})
.collect::<Vec<_>>();
let mut_match_arms = spec.members()
let mut_match_arms = spec
.members()
.map(|member| {
let member_ident = format_ident!("{}", member.name());
match member.kind() {

View File

@ -1,14 +1,15 @@
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
use crate::spec::polymorphic_enum_inner_build::PolymorphicEnumInnerBuild;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
pub fn make_polymorphic_enum_inner_build_build_fn(spec: &PolymorphicEnumInnerBuild) -> TokenStream {
let build_fn_ident = format_ident!("{}", make_build_fn_name(spec.name()));
let pair_ident = format_ident!("{}", make_build_pair(spec.name()));
let return_type_ident = format_ident!("{}", spec.name());
let rule_branches = spec.rules()
let rule_branches = spec
.rules()
.map(|rule| {
let rule_ident = format_ident!("{}", rule.name());
let rule_build_fn_ident = format_ident!("{}", rule.with());

View File

@ -1,10 +1,10 @@
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
use crate::spec::SpecialChildKind;
use crate::spec::polymorphic_enum_loop_spec::{
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuild,
PolymorphicEnumLoopRuleBuildChild, PolymorphicEnumLoopRuleChildOnEach,
PolymorphicEnumLoopRulePassThrough,
};
use crate::spec::SpecialChildKind;
use proc_macro2::{Ident, TokenStream};
use quote::{format_ident, quote};

View File

@ -8,7 +8,8 @@ pub fn make_polymorphic_leaf_enum_build_fn(spec: &PolymorphicLeafEnum) -> TokenS
let pair_ident = format_ident!("{}_pair", spec.name().to_case(Case::Snake));
let return_type_ident = format_ident!("{}", spec.kind());
let child_matchers = spec.rules()
let child_matchers = spec
.rules()
.map(|rule| {
let rule_ident = format_ident!("{}", rule);
quote! {

View File

@ -15,8 +15,7 @@ pub fn make_enum_build_fn(enum_build_spec: &TreeEnumBuildSpec) -> TokenStream {
if let Some(child) = enum_rule.child() {
let inner_builder = match child.kind() {
EnumRuleChildKind::Node(node_child) => {
let inner_build_fn_ident =
format_ident!("{}", node_child.with());
let inner_build_fn_ident = format_ident!("{}", node_child.with());
quote! { #inner_build_fn_ident(file_id, inner_pair) }
}
EnumRuleChildKind::Int(name_and_with) => {

View File

@ -1,13 +1,12 @@
use yaml_rust2::Yaml;
use crate::spec::leaf_enum_spec::LeafEnumBuildSpec;
use yaml_rust2::Yaml;
pub fn deserialize_leaf_enum(name: &str, props: &Yaml) -> LeafEnumBuildSpec {
let rules = props["rules"].as_vec()
let rules = props["rules"]
.as_vec()
.unwrap()
.iter()
.map(|rule_yaml| {
rule_yaml.as_str().unwrap().to_string()
})
.map(|rule_yaml| rule_yaml.as_str().unwrap().to_string())
.collect();
LeafEnumBuildSpec::new(name, rules)
}

View File

@ -1,13 +1,13 @@
use crate::deserialize::util::unwrap_single_member_hash;
use yaml_rust2::Yaml;
use crate::spec::leaf_struct_spec::{LeafStructBuildSpec, LeafStructMember, LeafStructMemberKind};
use yaml_rust2::Yaml;
fn deserialize_member(member_name: &str, member_props: &Yaml) -> LeafStructMember {
let kind = match member_props["kind"].as_str().unwrap() {
"string" => LeafStructMemberKind::String,
"file_id" => LeafStructMemberKind::FileId,
"range" => LeafStructMemberKind::Range,
_ => panic!()
_ => panic!(),
};
LeafStructMember::new(member_name, kind)
}
@ -26,10 +26,10 @@ pub fn deserialize_leaf_struct(name: &str, props: &Yaml) -> LeafStructBuildSpec
let derive = props["derive"]
.as_vec()
.map(|derive_yaml| {
derive_yaml.iter()
.map(|trait_yaml| {
trait_yaml.as_str().unwrap().to_string()
}).collect::<Vec<_>>()
derive_yaml
.iter()
.map(|trait_yaml| trait_yaml.as_str().unwrap().to_string())
.collect::<Vec<_>>()
})
.unwrap_or_default();

View File

@ -19,13 +19,13 @@ use crate::deserialize::polymorphic_enum_build_inner::deserialize_polymorphic_en
use crate::deserialize::polymorphic_enum_loop_spec::deserialize_polymorphic_enum_loop;
use crate::deserialize::polymorphic_leaf_enum::deserialize_polymorphic_leaf_enum;
use crate::deserialize::polymorphic_pass_through_spec::deserialize_polymorphic_pass_through;
use crate::deserialize::polymorphic_tree_enum::deserialize_polymorphic_tree_enum;
use crate::deserialize::polymorphic_type_spec::deserialize_polymorphic_type;
use crate::deserialize::production_spec::deserialize_production;
use crate::deserialize::struct_spec::deserialize_struct_spec;
use crate::deserialize::tree_enum_spec::deserialize_tree_enum;
use crate::spec::BuildSpec;
use yaml_rust2::{Yaml, YamlLoader};
use crate::deserialize::polymorphic_tree_enum::deserialize_polymorphic_tree_enum;
fn deserialize_build_spec(build_spec_name: &str, build_spec: &Yaml) -> BuildSpec {
if build_spec["struct"].is_hash() {

View File

@ -46,16 +46,12 @@ fn deserialize_build(name: &str, props: &Yaml) -> PolymorphicEnumLoopRuleBuild {
let fields = props["fields"]
.as_vec()
.map(|fields| {
fields.iter()
fields
.iter()
.map(|field_yaml| {
let (field_name, field_props) = unwrap_single_member_hash(field_yaml);
let kind = field_props["kind"].as_str().unwrap();
StructField::new(
&field_name,
kind,
None,
false
)
StructField::new(&field_name, kind, None, false)
})
.collect::<Vec<_>>()
})

View File

@ -1,13 +1,13 @@
use yaml_rust2::Yaml;
use crate::spec::polymorphic_leaf_enum::PolymorphicLeafEnum;
use yaml_rust2::Yaml;
pub fn deserialize_polymorphic_leaf_enum(name: &str, props: &Yaml) -> PolymorphicLeafEnum {
let kind = props["kind"].as_str().unwrap();
let rules = props["rules"].as_vec().unwrap()
let rules = props["rules"]
.as_vec()
.unwrap()
.iter()
.map(|rule| {
rule.as_str().unwrap().to_string()
})
.map(|rule| rule.as_str().unwrap().to_string())
.collect::<Vec<_>>();
PolymorphicLeafEnum::new(name, kind, rules)
}

View File

@ -1,10 +1,17 @@
use crate::deserialize::util::unwrap_single_member_hash;
use crate::spec::polymorphic_pass_through_spec::{PolymorphicPassThroughBuildSpec, PolymorphicPassThroughVariant};
use crate::spec::polymorphic_pass_through_spec::{
PolymorphicPassThroughBuildSpec, PolymorphicPassThroughVariant,
};
use yaml_rust2::Yaml;
pub fn deserialize_polymorphic_pass_through(name: &str, props: &Yaml) -> PolymorphicPassThroughBuildSpec {
pub fn deserialize_polymorphic_pass_through(
name: &str,
props: &Yaml,
) -> PolymorphicPassThroughBuildSpec {
let build_kind = props["build"]["kind"].as_str().unwrap();
let variants = props["variants"].as_vec().unwrap()
let variants = props["variants"]
.as_vec()
.unwrap()
.iter()
.map(|variant_yaml| {
let (variant_name, variant_props) = unwrap_single_member_hash(variant_yaml);

View File

@ -1,9 +1,11 @@
use yaml_rust2::Yaml;
use crate::spec::polymorphic_tree_enum_spec::PolymorphicTreeEnumSpec;
use yaml_rust2::Yaml;
pub fn deserialize_polymorphic_tree_enum(name: &str, props: &Yaml) -> PolymorphicTreeEnumSpec {
let kind = props["kind"].as_str().unwrap();
let rules = props["rules"].as_vec().unwrap()
let rules = props["rules"]
.as_vec()
.unwrap()
.iter()
.map(|rule| rule.as_str().unwrap())
.collect::<Vec<_>>();

View File

@ -1,4 +1,6 @@
use crate::spec::production_spec::{ProductionBooleanFrom, ProductionBuildSpec, ProductionKind, ProductionStringFrom};
use crate::spec::production_spec::{
ProductionBooleanFrom, ProductionBuildSpec, ProductionKind, ProductionStringFrom,
};
use yaml_rust2::Yaml;
pub fn deserialize_production(name: &str, props: &Yaml) -> ProductionBuildSpec {
@ -10,12 +12,18 @@ pub fn deserialize_production(name: &str, props: &Yaml) -> ProductionBuildSpec {
let from = match props["from"].as_str().unwrap() {
"string_inner" => ProductionStringFrom::StringInner,
"whole_pair" => ProductionStringFrom::WholePair,
_ => panic!("Unknown string production from: {}", props["from"].as_str().unwrap())
_ => panic!(
"Unknown string production from: {}",
props["from"].as_str().unwrap()
),
};
ProductionKind::String(from)
},
}
"boolean" => ProductionKind::Boolean(ProductionBooleanFrom::ParseWholePair),
_ => panic!("Unknown production kind: {}", props["kind"].as_str().unwrap()),
_ => panic!(
"Unknown production kind: {}",
props["kind"].as_str().unwrap()
),
};
ProductionBuildSpec::new(name, kind)
}

View File

@ -1,14 +1,14 @@
use convert_case::{Case, Casing};
use crate::deserialize::util::{get_as_bool_or, make_build_fn_name, unwrap_single_member_hash};
use crate::spec::tree_enum_spec::{EnumRuleChild, EnumRuleChildKind, EnumRuleChildNodeKind, NameAndWith, TreeEnumBuildSpec, TreeEnumRule};
use crate::spec::tree_enum_spec::{
EnumRuleChild, EnumRuleChildKind, EnumRuleChildNodeKind, NameAndWith, TreeEnumBuildSpec,
TreeEnumRule,
};
use convert_case::{Case, Casing};
use yaml_rust2::Yaml;
fn deserialize_hash_enum_rule(rule: &str, props: &Yaml) -> TreeEnumRule {
if get_as_bool_or(&props["child"], true) {
let name_and_with = NameAndWith::new(
&rule.to_case(Case::Snake),
&make_build_fn_name(rule)
);
let name_and_with = NameAndWith::new(&rule.to_case(Case::Snake), &make_build_fn_name(rule));
let kind = match props["kind"].as_str().unwrap() {
"int" => EnumRuleChildKind::Int(name_and_with),
"long" => EnumRuleChildKind::Long(name_and_with),
@ -28,10 +28,7 @@ fn deserialize_string_enum_rule(rule: &str) -> TreeEnumRule {
TreeEnumRule::new(
rule,
Some(Box::new(EnumRuleChild::new(Box::new(
EnumRuleChildKind::Node(EnumRuleChildNodeKind::new(
rule,
&make_build_fn_name(rule)
)),
EnumRuleChildKind::Node(EnumRuleChildNodeKind::new(rule, &make_build_fn_name(rule))),
)))),
)
}

View File

@ -1,3 +1,4 @@
use crate::spec::BuildSpec;
use crate::spec::leaf_enum_spec::LeafEnumBuildSpec;
use crate::spec::leaf_struct_spec::{LeafStructBuildSpec, LeafStructMemberKind};
use crate::spec::polymorphic_enum_inner_build::{
@ -9,7 +10,6 @@ use crate::spec::polymorphic_enum_loop_spec::{
use crate::spec::polymorphic_type_spec::PolymorphicTypeBuildSpec;
use crate::spec::struct_spec::{MemberChildBuild, StructChild, StructSpec, VecChildBuild};
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
use crate::spec::BuildSpec;
use convert_case::{Case, Casing};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};

View File

@ -51,5 +51,5 @@ impl LeafStructMember {
pub enum LeafStructMemberKind {
String,
FileId,
Range
Range,
}

View File

@ -1,7 +1,7 @@
pub struct NodeProductionBuildSpec {
name: String,
kind: String,
with: String
with: String,
}
impl NodeProductionBuildSpec {
@ -9,7 +9,7 @@ impl NodeProductionBuildSpec {
Self {
name: name.to_string(),
kind: kind.to_string(),
with: with.to_string()
with: with.to_string(),
}
}

View File

@ -5,7 +5,11 @@ pub struct PolymorphicEnumInnerBuild {
}
impl PolymorphicEnumInnerBuild {
pub fn new(name: &str, members: Vec<PolymorphicEnumInnerBuildMember>, rules: Vec<PolymorphicEnumInnerBuildRule>) -> Self {
pub fn new(
name: &str,
members: Vec<PolymorphicEnumInnerBuildMember>,
rules: Vec<PolymorphicEnumInnerBuildRule>,
) -> Self {
Self {
name: name.to_string(),
members,
@ -28,14 +32,14 @@ impl PolymorphicEnumInnerBuild {
pub struct PolymorphicEnumInnerBuildMember {
name: String,
kind: PolymorphicEnumInnerBuildMemberKind
kind: PolymorphicEnumInnerBuildMemberKind,
}
impl PolymorphicEnumInnerBuildMember {
pub fn new(name: &str, kind: PolymorphicEnumInnerBuildMemberKind) -> Self {
Self {
name: name.to_string(),
kind
kind,
}
}
@ -50,7 +54,7 @@ impl PolymorphicEnumInnerBuildMember {
pub enum PolymorphicEnumInnerBuildMemberKind {
Leaf,
Struct
Struct,
}
pub struct PolymorphicEnumInnerBuildRule {

View File

@ -1,6 +1,6 @@
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
pub fn make_enum_type(build_spec: &TreeEnumBuildSpec) -> TokenStream {
let children: Vec<TokenStream> = build_spec

View File

@ -84,9 +84,10 @@ pub fn make_leaf_struct_type(build_spec: &LeafStructBuildSpec) -> TokenStream {
.collect::<Vec<_>>();
let struct_stream = if build_spec.derive().count() > 0 {
let derives = build_spec.derive().map(|derive| {
format_ident!("{}", derive)
}).collect::<Vec<_>>();
let derives = build_spec
.derive()
.map(|derive| format_ident!("{}", derive))
.collect::<Vec<_>>();
quote! {
#[derive(#(#derives),*)]

View File

@ -1,9 +1,12 @@
use crate::spec::polymorphic_enum_inner_build::{
PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind,
};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use crate::spec::polymorphic_enum_inner_build::{PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind};
pub fn make_polymorphic_enum_inner_build_type(spec: &PolymorphicEnumInnerBuild) -> TokenStream {
let members = spec.members()
let members = spec
.members()
.map(|member| {
let name_ident = format_ident!("{}", member.name());
match member.kind() {

View File

@ -1,7 +1,7 @@
use crate::spec::SpecialChildKind;
use crate::spec::polymorphic_enum_loop_spec::{
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuildChild,
};
use crate::spec::SpecialChildKind;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};

View File

@ -1,4 +1,4 @@
use ast_generator::{get_build_specs, generate_files};
use ast_generator::{generate_files, get_build_specs};
use cst_test_generator::generate_test_files;
use std::env;
use std::fs;

View File

@ -191,14 +191,12 @@ fn assemble_ir_call(ir_call: &IrCall, context: &mut AssemblyContext) {
}
fn assemble_ir_return(ir_return: &IrReturn, context: &mut AssemblyContext) {
let operand = ir_return.expression().map(|expression| {
match expression {
let operand = ir_return.expression().map(|expression| match expression {
IrExpression::Variable(ir_variable) => {
let variable_virtual_register_id = context.get_virtual_register(ir_variable.name());
AsmOperand::VirtualRegister(variable_virtual_register_id)
}
IrExpression::Literal(ir_literal) => ir_literal_to_asm_operand(ir_literal),
}
});
context
.current_control_unit_mut()

View File

@ -1,7 +1,7 @@
use deimos::parser::{DeimosParser, Rule};
use std::path::PathBuf;
use pest::iterators::{Pair, Pairs};
use pest::Parser;
use std::path::PathBuf;
fn print_pair(pair: Pair<Rule>) {
println!("{:?}", pair.as_rule());

View File

@ -2,6 +2,7 @@ use codespan_reporting::files::SimpleFiles;
use codespan_reporting::term;
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
use deimos::ast::build::build_ast;
use deimos::ast::node::CompilationUnit;
use deimos::name_analysis::analyze_names;
use deimos::name_analysis::symbol_table::SymbolTable;
use deimos::parser::{DeimosParser, Rule};
@ -10,7 +11,6 @@ use pest::Parser;
use std::collections::HashMap;
use std::fmt::{Debug, Display, Formatter};
use std::path::PathBuf;
use deimos::ast::node::CompilationUnit;
struct ParseErrors {
errors: Vec<pest::error::Error<Rule>>,
@ -34,7 +34,9 @@ impl Display for ParseErrors {
impl std::error::Error for ParseErrors {}
pub fn name_analysis(paths: &[PathBuf]) -> Result<Vec<CompilationUnit>, Box<dyn std::error::Error>> {
pub fn name_analysis(
paths: &[PathBuf],
) -> Result<Vec<CompilationUnit>, Box<dyn std::error::Error>> {
let mut paths_and_sources: HashMap<String, String> = HashMap::new();
for path in paths {
let src = std::fs::read_to_string(path).unwrap();

View File

@ -8,10 +8,10 @@ use crate::ir::{
IrPrimitiveKind, IrReturn, IrStatement, IrStructKind, IrVariable,
};
use crate::name_analysis::symbol::{ClassSymbol, ParameterSymbol, PrimitiveTypeSymbol, TypeSymbol};
use crate::type_analysis::kinds::Kind;
use std::cell::RefCell;
use std::ops::Deref;
use std::rc::Rc;
use crate::type_analysis::kinds::Kind;
struct CuContext {
irs: Vec<Ir>,

View File

@ -1,12 +1,12 @@
use crate::ast::node::{
AssignmentStatement, BacktickString, Call, Closure, ClosureParameters,
CompilationUnit, ConcreteUseStatement, ConcreteUseStatementSuffix, DString, Expression,
ExpressionList, ExpressionStatement, Function, FunctionAliasBody, FunctionBlockBody,
FunctionBody, FunctionEqualsBody, GenericParameters, Identifier, IdentifierExpression,
IdentifierOrFqn, LValue, LValueSuffix, Literal, ModuleLevelDeclaration
, ObjectIndex, Parameter, Parameters, PlatformFunction, PrimitiveType,
ReturnType, StarUseStatement, Statement, SuffixExpression, SuffixOperator, TypeUse, TypedArray,
UseStatement, UseStatementIdentifier, UseStatementPrefix, VariableDeclaration,
AssignmentStatement, BacktickString, Call, Closure, ClosureParameters, CompilationUnit,
ConcreteUseStatement, ConcreteUseStatementSuffix, DString, Expression, ExpressionList,
ExpressionStatement, Function, FunctionAliasBody, FunctionBlockBody, FunctionBody,
FunctionEqualsBody, GenericParameters, Identifier, IdentifierExpression, IdentifierOrFqn,
LValue, LValueSuffix, Literal, ModuleLevelDeclaration, ObjectIndex, Parameter, Parameters,
PlatformFunction, PrimitiveType, ReturnType, StarUseStatement, Statement, SuffixExpression,
SuffixOperator, TypeUse, TypedArray, UseStatement, UseStatementIdentifier, UseStatementPrefix,
VariableDeclaration,
};
use crate::diagnostic::DmDiagnostic;
use crate::name_analysis::symbol::source_definition::SourceDefinition;
@ -529,7 +529,11 @@ fn na_p2_variable_declaration(
}
// initializer
na_p2_expression(variable_declaration.expression_mut(), symbol_table, diagnostics);
na_p2_expression(
variable_declaration.expression_mut(),
symbol_table,
diagnostics,
);
}
fn na_p2_assignment_statement(
@ -628,7 +632,11 @@ fn na_p2_expression(
}
Expression::Additive(additive) => {
na_p2_expression(additive.left_mut(), symbol_table, diagnostics);
na_p2_expression(additive.rhs_mut().expression_mut(), symbol_table, diagnostics);
na_p2_expression(
additive.rhs_mut().expression_mut(),
symbol_table,
diagnostics,
);
}
Expression::Multiplicative(multiplicative) => {
todo!()

View File

@ -1,4 +1,6 @@
use crate::name_analysis::symbol::{ClassMemberSymbol, ClassSymbol, FunctionSymbol, ParameterSymbol, Symbol, VariableSymbol};
use crate::name_analysis::symbol::{
ClassMemberSymbol, ClassSymbol, FunctionSymbol, ParameterSymbol, Symbol, VariableSymbol,
};
use std::cell::RefCell;
use std::rc::Rc;
@ -13,9 +15,7 @@ pub enum ExpressibleSymbol {
impl ExpressibleSymbol {
pub fn to_symbol(self) -> Rc<RefCell<dyn Symbol>> {
match self {
ExpressibleSymbol::Class(class_symbol) => {
class_symbol as Rc<RefCell<dyn Symbol>>
}
ExpressibleSymbol::Class(class_symbol) => class_symbol as Rc<RefCell<dyn Symbol>>,
ExpressibleSymbol::Function(function_symbol) => {
function_symbol as Rc<RefCell<dyn Symbol>>
}

View File

@ -1,9 +1,9 @@
use std::cell::RefCell;
use std::rc::Rc;
use crate::name_analysis::symbol::class_member_symbol::ClassMemberSymbol;
use crate::name_analysis::symbol::parameter_symbol::ParameterSymbol;
use crate::name_analysis::symbol::Symbol;
use crate::name_analysis::symbol::variable_symbol::VariableSymbol;
use crate::name_analysis::symbol::Symbol;
use std::cell::RefCell;
use std::rc::Rc;
pub enum LVSymbol {
ClassMember(Rc<RefCell<ClassMemberSymbol>>),
@ -17,12 +17,8 @@ impl LVSymbol {
LVSymbol::ClassMember(class_member_symbol) => {
class_member_symbol as Rc<RefCell<dyn Symbol>>
}
LVSymbol::Parameter(parameter_symbol) => {
parameter_symbol as Rc<RefCell<dyn Symbol>>
}
LVSymbol::Variable(variable_symbol) => {
variable_symbol as Rc<RefCell<dyn Symbol>>
}
LVSymbol::Parameter(parameter_symbol) => parameter_symbol as Rc<RefCell<dyn Symbol>>,
LVSymbol::Variable(variable_symbol) => variable_symbol as Rc<RefCell<dyn Symbol>>,
}
}
}

View File

@ -2,10 +2,10 @@ use crate::name_analysis::symbol::class_symbol::ClassSymbol;
use crate::name_analysis::symbol::generic_type_symbol::GenericTypeSymbol;
use crate::name_analysis::symbol::interface_symbol::InterfaceSymbol;
use crate::name_analysis::symbol::primitive_type_symbol::PrimitiveTypeSymbol;
use crate::name_analysis::symbol::Symbol;
use std::cell::RefCell;
use std::fmt::Debug;
use std::rc::Rc;
use crate::name_analysis::symbol::Symbol;
#[derive(Debug, Clone)]
pub enum TypeSymbol {
@ -21,15 +21,9 @@ impl TypeSymbol {
TypeSymbol::Primitive(primitive_type_symbol) => {
Rc::new(RefCell::new(primitive_type_symbol))
}
TypeSymbol::Class(class_symbol) => {
class_symbol as Rc<RefCell<dyn Symbol>>
}
TypeSymbol::Interface(interface_symbol) => {
interface_symbol as Rc<RefCell<dyn Symbol>>
}
TypeSymbol::Generic(generic_symbol) => {
generic_symbol as Rc<RefCell<dyn Symbol>>
}
TypeSymbol::Class(class_symbol) => class_symbol as Rc<RefCell<dyn Symbol>>,
TypeSymbol::Interface(interface_symbol) => interface_symbol as Rc<RefCell<dyn Symbol>>,
TypeSymbol::Generic(generic_symbol) => generic_symbol as Rc<RefCell<dyn Symbol>>,
}
}
}

View File

@ -1,8 +1,8 @@
use crate::name_analysis::symbol::source_definition::SourceDefinition;
use crate::name_analysis::symbol::Symbol;
use crate::type_analysis::kinds::Kind;
use std::fmt::{Debug, Formatter};
use std::rc::Rc;
use crate::type_analysis::kinds::Kind;
pub struct VariableSymbol {
declared_name: Rc<str>,

View File

@ -141,7 +141,9 @@ impl SymbolTable {
.find_usable_symbol(concrete_use_symbol.borrow().fqn_parts())
{
Ok(usable_symbol) => {
concrete_use_symbol.borrow_mut().set_resolved_symbol(usable_symbol);
concrete_use_symbol
.borrow_mut()
.set_resolved_symbol(usable_symbol);
}
Err(symbol_lookup_error) => {
// panic because this is definitely a compiler/configuration error
@ -156,7 +158,10 @@ impl SymbolTable {
for star_use_symbol in global_scope.star_use_symbols() {
let mut star_use_symbol_ref_mut = star_use_symbol.borrow_mut();
match self.symbol_tree.find_all_by_base_fqn(star_use_symbol_ref_mut.fqn_parts()) {
match self
.symbol_tree
.find_all_by_base_fqn(star_use_symbol_ref_mut.fqn_parts())
{
Ok(usable_symbols) => {
star_use_symbol_ref_mut.set_resolved_symbols(usable_symbols);
}

View File

@ -255,16 +255,14 @@ impl Scope {
.or_else(|| {
if let Some(concrete_use_symbol) = self.concrete_use_symbols.get(declared_name) {
return match concrete_use_symbol.borrow().resolved_symbol().unwrap() {
UsableSymbol::Interface(_) => {
None
}
UsableSymbol::Interface(_) => None,
UsableSymbol::Class(class_symbol) => {
Some(ExpressibleSymbol::Class(class_symbol.clone()))
}
UsableSymbol::Function(function_symbol) => {
Some(ExpressibleSymbol::Function(function_symbol.clone()))
}
}
};
}
None
})
@ -279,7 +277,9 @@ impl Scope {
}
UsableSymbol::Function(function_symbol) => {
if function_symbol.borrow().declared_name() == declared_name {
return Some(ExpressibleSymbol::Function(function_symbol.clone()));
return Some(ExpressibleSymbol::Function(
function_symbol.clone(),
));
}
}
_ => continue,

View File

@ -3,7 +3,7 @@ use std::rc::Rc;
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct ClassKind {
fqn: Rc<str>
fqn: Rc<str>,
}
impl ClassKind {

View File

@ -1,5 +1,5 @@
use std::fmt::Display;
use crate::type_analysis::kinds::Kind;
use std::fmt::Display;
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum PrimitiveKind {

View File

@ -200,11 +200,10 @@ fn ta_additive_expression(
"Incompatible types for additive expression: {} vs. {}",
left_kind, right_kind
))
.with_label(Label::primary(
*additive_expression.file_id(),
*additive_expression.range(),
)
.with_message("Incompatible types here.")),
.with_label(
Label::primary(*additive_expression.file_id(), *additive_expression.range())
.with_message("Incompatible types here."),
),
);
}
additive_expression.set_analyzed_kind(left_kind);

View File

@ -394,7 +394,9 @@ impl Drop for GcHeap {
let mut current = self.head().take();
while let Some(gc_any) = &mut current {
let next = gc_any.next();
unsafe { gc_any.dealloc(); }
unsafe {
gc_any.dealloc();
}
current = next;
}
}
@ -464,7 +466,9 @@ fn collect_garbage(stack: &Vec<DvmValue>, heap: &mut GcHeap) {
}
heap.subtract_current_size(current_gc.allocated_size());
collected_size += current_gc.dynamic_size();
unsafe { current_gc.dealloc(); }
unsafe {
current_gc.dealloc();
}
} else {
current_gc.set_color(GcColor::White);
previous = Some(current_gc.clone());

View File

@ -344,7 +344,7 @@ fn constant_to_value(constant: &DvmConstant) -> DvmValue {
fn immediate_to_value(immediate: &Immediate) -> DvmValue {
match immediate {
_ => todo!()
_ => todo!(),
}
}