Fmt all the old code.
This commit is contained in:
parent
b4ebee0c34
commit
19194271aa
@ -1,5 +1,7 @@
|
|||||||
|
use crate::spec::polymorphic_enum_inner_build::{
|
||||||
|
PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind,
|
||||||
|
};
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use crate::spec::polymorphic_enum_inner_build::{PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind};
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|
||||||
@ -8,7 +10,8 @@ pub fn make_polymorphic_enum_inner_build_ast_node_impl(
|
|||||||
) -> TokenStream {
|
) -> TokenStream {
|
||||||
let type_ident = format_ident!("{}", spec.name());
|
let type_ident = format_ident!("{}", spec.name());
|
||||||
|
|
||||||
let match_arms = spec.members()
|
let match_arms = spec
|
||||||
|
.members()
|
||||||
.map(|member| {
|
.map(|member| {
|
||||||
let member_ident = format_ident!("{}", member.name());
|
let member_ident = format_ident!("{}", member.name());
|
||||||
match member.kind() {
|
match member.kind() {
|
||||||
@ -29,7 +32,8 @@ pub fn make_polymorphic_enum_inner_build_ast_node_impl(
|
|||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let mut_match_arms = spec.members()
|
let mut_match_arms = spec
|
||||||
|
.members()
|
||||||
.map(|member| {
|
.map(|member| {
|
||||||
let member_ident = format_ident!("{}", member.name());
|
let member_ident = format_ident!("{}", member.name());
|
||||||
match member.kind() {
|
match member.kind() {
|
||||||
|
|||||||
@ -1,14 +1,15 @@
|
|||||||
|
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
|
||||||
use crate::spec::polymorphic_enum_inner_build::PolymorphicEnumInnerBuild;
|
use crate::spec::polymorphic_enum_inner_build::PolymorphicEnumInnerBuild;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
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 {
|
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 build_fn_ident = format_ident!("{}", make_build_fn_name(spec.name()));
|
||||||
let pair_ident = format_ident!("{}", make_build_pair(spec.name()));
|
let pair_ident = format_ident!("{}", make_build_pair(spec.name()));
|
||||||
let return_type_ident = format_ident!("{}", spec.name());
|
let return_type_ident = format_ident!("{}", spec.name());
|
||||||
|
|
||||||
let rule_branches = spec.rules()
|
let rule_branches = spec
|
||||||
|
.rules()
|
||||||
.map(|rule| {
|
.map(|rule| {
|
||||||
let rule_ident = format_ident!("{}", rule.name());
|
let rule_ident = format_ident!("{}", rule.name());
|
||||||
let rule_build_fn_ident = format_ident!("{}", rule.with());
|
let rule_build_fn_ident = format_ident!("{}", rule.with());
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
|
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
|
||||||
|
use crate::spec::SpecialChildKind;
|
||||||
use crate::spec::polymorphic_enum_loop_spec::{
|
use crate::spec::polymorphic_enum_loop_spec::{
|
||||||
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuild,
|
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuild,
|
||||||
PolymorphicEnumLoopRuleBuildChild, PolymorphicEnumLoopRuleChildOnEach,
|
PolymorphicEnumLoopRuleBuildChild, PolymorphicEnumLoopRuleChildOnEach,
|
||||||
PolymorphicEnumLoopRulePassThrough,
|
PolymorphicEnumLoopRulePassThrough,
|
||||||
};
|
};
|
||||||
use crate::spec::SpecialChildKind;
|
|
||||||
use proc_macro2::{Ident, TokenStream};
|
use proc_macro2::{Ident, TokenStream};
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|
||||||
|
|||||||
@ -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 pair_ident = format_ident!("{}_pair", spec.name().to_case(Case::Snake));
|
||||||
let return_type_ident = format_ident!("{}", spec.kind());
|
let return_type_ident = format_ident!("{}", spec.kind());
|
||||||
|
|
||||||
let child_matchers = spec.rules()
|
let child_matchers = spec
|
||||||
|
.rules()
|
||||||
.map(|rule| {
|
.map(|rule| {
|
||||||
let rule_ident = format_ident!("{}", rule);
|
let rule_ident = format_ident!("{}", rule);
|
||||||
quote! {
|
quote! {
|
||||||
|
|||||||
@ -15,8 +15,7 @@ pub fn make_enum_build_fn(enum_build_spec: &TreeEnumBuildSpec) -> TokenStream {
|
|||||||
if let Some(child) = enum_rule.child() {
|
if let Some(child) = enum_rule.child() {
|
||||||
let inner_builder = match child.kind() {
|
let inner_builder = match child.kind() {
|
||||||
EnumRuleChildKind::Node(node_child) => {
|
EnumRuleChildKind::Node(node_child) => {
|
||||||
let inner_build_fn_ident =
|
let inner_build_fn_ident = format_ident!("{}", node_child.with());
|
||||||
format_ident!("{}", node_child.with());
|
|
||||||
quote! { #inner_build_fn_ident(file_id, inner_pair) }
|
quote! { #inner_build_fn_ident(file_id, inner_pair) }
|
||||||
}
|
}
|
||||||
EnumRuleChildKind::Int(name_and_with) => {
|
EnumRuleChildKind::Int(name_and_with) => {
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
use yaml_rust2::Yaml;
|
|
||||||
use crate::spec::leaf_enum_spec::LeafEnumBuildSpec;
|
use crate::spec::leaf_enum_spec::LeafEnumBuildSpec;
|
||||||
|
use yaml_rust2::Yaml;
|
||||||
|
|
||||||
pub fn deserialize_leaf_enum(name: &str, props: &Yaml) -> LeafEnumBuildSpec {
|
pub fn deserialize_leaf_enum(name: &str, props: &Yaml) -> LeafEnumBuildSpec {
|
||||||
let rules = props["rules"].as_vec()
|
let rules = props["rules"]
|
||||||
|
.as_vec()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|rule_yaml| {
|
.map(|rule_yaml| rule_yaml.as_str().unwrap().to_string())
|
||||||
rule_yaml.as_str().unwrap().to_string()
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
LeafEnumBuildSpec::new(name, rules)
|
LeafEnumBuildSpec::new(name, rules)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
use crate::deserialize::util::unwrap_single_member_hash;
|
use crate::deserialize::util::unwrap_single_member_hash;
|
||||||
use yaml_rust2::Yaml;
|
|
||||||
use crate::spec::leaf_struct_spec::{LeafStructBuildSpec, LeafStructMember, LeafStructMemberKind};
|
use crate::spec::leaf_struct_spec::{LeafStructBuildSpec, LeafStructMember, LeafStructMemberKind};
|
||||||
|
use yaml_rust2::Yaml;
|
||||||
|
|
||||||
fn deserialize_member(member_name: &str, member_props: &Yaml) -> LeafStructMember {
|
fn deserialize_member(member_name: &str, member_props: &Yaml) -> LeafStructMember {
|
||||||
let kind = match member_props["kind"].as_str().unwrap() {
|
let kind = match member_props["kind"].as_str().unwrap() {
|
||||||
"string" => LeafStructMemberKind::String,
|
"string" => LeafStructMemberKind::String,
|
||||||
"file_id" => LeafStructMemberKind::FileId,
|
"file_id" => LeafStructMemberKind::FileId,
|
||||||
"range" => LeafStructMemberKind::Range,
|
"range" => LeafStructMemberKind::Range,
|
||||||
_ => panic!()
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
LeafStructMember::new(member_name, kind)
|
LeafStructMember::new(member_name, kind)
|
||||||
}
|
}
|
||||||
@ -26,10 +26,10 @@ pub fn deserialize_leaf_struct(name: &str, props: &Yaml) -> LeafStructBuildSpec
|
|||||||
let derive = props["derive"]
|
let derive = props["derive"]
|
||||||
.as_vec()
|
.as_vec()
|
||||||
.map(|derive_yaml| {
|
.map(|derive_yaml| {
|
||||||
derive_yaml.iter()
|
derive_yaml
|
||||||
.map(|trait_yaml| {
|
.iter()
|
||||||
trait_yaml.as_str().unwrap().to_string()
|
.map(|trait_yaml| trait_yaml.as_str().unwrap().to_string())
|
||||||
}).collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
||||||
|
|||||||
@ -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_enum_loop_spec::deserialize_polymorphic_enum_loop;
|
||||||
use crate::deserialize::polymorphic_leaf_enum::deserialize_polymorphic_leaf_enum;
|
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_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::polymorphic_type_spec::deserialize_polymorphic_type;
|
||||||
use crate::deserialize::production_spec::deserialize_production;
|
use crate::deserialize::production_spec::deserialize_production;
|
||||||
use crate::deserialize::struct_spec::deserialize_struct_spec;
|
use crate::deserialize::struct_spec::deserialize_struct_spec;
|
||||||
use crate::deserialize::tree_enum_spec::deserialize_tree_enum;
|
use crate::deserialize::tree_enum_spec::deserialize_tree_enum;
|
||||||
use crate::spec::BuildSpec;
|
use crate::spec::BuildSpec;
|
||||||
use yaml_rust2::{Yaml, YamlLoader};
|
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 {
|
fn deserialize_build_spec(build_spec_name: &str, build_spec: &Yaml) -> BuildSpec {
|
||||||
if build_spec["struct"].is_hash() {
|
if build_spec["struct"].is_hash() {
|
||||||
|
|||||||
@ -46,16 +46,12 @@ fn deserialize_build(name: &str, props: &Yaml) -> PolymorphicEnumLoopRuleBuild {
|
|||||||
let fields = props["fields"]
|
let fields = props["fields"]
|
||||||
.as_vec()
|
.as_vec()
|
||||||
.map(|fields| {
|
.map(|fields| {
|
||||||
fields.iter()
|
fields
|
||||||
|
.iter()
|
||||||
.map(|field_yaml| {
|
.map(|field_yaml| {
|
||||||
let (field_name, field_props) = unwrap_single_member_hash(field_yaml);
|
let (field_name, field_props) = unwrap_single_member_hash(field_yaml);
|
||||||
let kind = field_props["kind"].as_str().unwrap();
|
let kind = field_props["kind"].as_str().unwrap();
|
||||||
StructField::new(
|
StructField::new(&field_name, kind, None, false)
|
||||||
&field_name,
|
|
||||||
kind,
|
|
||||||
None,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
use yaml_rust2::Yaml;
|
|
||||||
use crate::spec::polymorphic_leaf_enum::PolymorphicLeafEnum;
|
use crate::spec::polymorphic_leaf_enum::PolymorphicLeafEnum;
|
||||||
|
use yaml_rust2::Yaml;
|
||||||
|
|
||||||
pub fn deserialize_polymorphic_leaf_enum(name: &str, props: &Yaml) -> PolymorphicLeafEnum {
|
pub fn deserialize_polymorphic_leaf_enum(name: &str, props: &Yaml) -> PolymorphicLeafEnum {
|
||||||
let kind = props["kind"].as_str().unwrap();
|
let kind = props["kind"].as_str().unwrap();
|
||||||
let rules = props["rules"].as_vec().unwrap()
|
let rules = props["rules"]
|
||||||
|
.as_vec()
|
||||||
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|rule| {
|
.map(|rule| rule.as_str().unwrap().to_string())
|
||||||
rule.as_str().unwrap().to_string()
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
PolymorphicLeafEnum::new(name, kind, rules)
|
PolymorphicLeafEnum::new(name, kind, rules)
|
||||||
}
|
}
|
||||||
@ -1,10 +1,17 @@
|
|||||||
use crate::deserialize::util::unwrap_single_member_hash;
|
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;
|
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 build_kind = props["build"]["kind"].as_str().unwrap();
|
||||||
let variants = props["variants"].as_vec().unwrap()
|
let variants = props["variants"]
|
||||||
|
.as_vec()
|
||||||
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|variant_yaml| {
|
.map(|variant_yaml| {
|
||||||
let (variant_name, variant_props) = unwrap_single_member_hash(variant_yaml);
|
let (variant_name, variant_props) = unwrap_single_member_hash(variant_yaml);
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
use yaml_rust2::Yaml;
|
|
||||||
use crate::spec::polymorphic_tree_enum_spec::PolymorphicTreeEnumSpec;
|
use crate::spec::polymorphic_tree_enum_spec::PolymorphicTreeEnumSpec;
|
||||||
|
use yaml_rust2::Yaml;
|
||||||
|
|
||||||
pub fn deserialize_polymorphic_tree_enum(name: &str, props: &Yaml) -> PolymorphicTreeEnumSpec {
|
pub fn deserialize_polymorphic_tree_enum(name: &str, props: &Yaml) -> PolymorphicTreeEnumSpec {
|
||||||
let kind = props["kind"].as_str().unwrap();
|
let kind = props["kind"].as_str().unwrap();
|
||||||
let rules = props["rules"].as_vec().unwrap()
|
let rules = props["rules"]
|
||||||
|
.as_vec()
|
||||||
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|rule| rule.as_str().unwrap())
|
.map(|rule| rule.as_str().unwrap())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|||||||
@ -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;
|
use yaml_rust2::Yaml;
|
||||||
|
|
||||||
pub fn deserialize_production(name: &str, props: &Yaml) -> ProductionBuildSpec {
|
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() {
|
let from = match props["from"].as_str().unwrap() {
|
||||||
"string_inner" => ProductionStringFrom::StringInner,
|
"string_inner" => ProductionStringFrom::StringInner,
|
||||||
"whole_pair" => ProductionStringFrom::WholePair,
|
"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)
|
ProductionKind::String(from)
|
||||||
},
|
}
|
||||||
"boolean" => ProductionKind::Boolean(ProductionBooleanFrom::ParseWholePair),
|
"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)
|
ProductionBuildSpec::new(name, kind)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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::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;
|
use yaml_rust2::Yaml;
|
||||||
|
|
||||||
fn deserialize_hash_enum_rule(rule: &str, props: &Yaml) -> TreeEnumRule {
|
fn deserialize_hash_enum_rule(rule: &str, props: &Yaml) -> TreeEnumRule {
|
||||||
if get_as_bool_or(&props["child"], true) {
|
if get_as_bool_or(&props["child"], true) {
|
||||||
let name_and_with = NameAndWith::new(
|
let name_and_with = NameAndWith::new(&rule.to_case(Case::Snake), &make_build_fn_name(rule));
|
||||||
&rule.to_case(Case::Snake),
|
|
||||||
&make_build_fn_name(rule)
|
|
||||||
);
|
|
||||||
let kind = match props["kind"].as_str().unwrap() {
|
let kind = match props["kind"].as_str().unwrap() {
|
||||||
"int" => EnumRuleChildKind::Int(name_and_with),
|
"int" => EnumRuleChildKind::Int(name_and_with),
|
||||||
"long" => EnumRuleChildKind::Long(name_and_with),
|
"long" => EnumRuleChildKind::Long(name_and_with),
|
||||||
@ -28,10 +28,7 @@ fn deserialize_string_enum_rule(rule: &str) -> TreeEnumRule {
|
|||||||
TreeEnumRule::new(
|
TreeEnumRule::new(
|
||||||
rule,
|
rule,
|
||||||
Some(Box::new(EnumRuleChild::new(Box::new(
|
Some(Box::new(EnumRuleChild::new(Box::new(
|
||||||
EnumRuleChildKind::Node(EnumRuleChildNodeKind::new(
|
EnumRuleChildKind::Node(EnumRuleChildNodeKind::new(rule, &make_build_fn_name(rule))),
|
||||||
rule,
|
|
||||||
&make_build_fn_name(rule)
|
|
||||||
)),
|
|
||||||
)))),
|
)))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
use crate::spec::BuildSpec;
|
||||||
use crate::spec::leaf_enum_spec::LeafEnumBuildSpec;
|
use crate::spec::leaf_enum_spec::LeafEnumBuildSpec;
|
||||||
use crate::spec::leaf_struct_spec::{LeafStructBuildSpec, LeafStructMemberKind};
|
use crate::spec::leaf_struct_spec::{LeafStructBuildSpec, LeafStructMemberKind};
|
||||||
use crate::spec::polymorphic_enum_inner_build::{
|
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::polymorphic_type_spec::PolymorphicTypeBuildSpec;
|
||||||
use crate::spec::struct_spec::{MemberChildBuild, StructChild, StructSpec, VecChildBuild};
|
use crate::spec::struct_spec::{MemberChildBuild, StructChild, StructSpec, VecChildBuild};
|
||||||
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
|
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
|
||||||
use crate::spec::BuildSpec;
|
|
||||||
use convert_case::{Case, Casing};
|
use convert_case::{Case, Casing};
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|||||||
@ -51,5 +51,5 @@ impl LeafStructMember {
|
|||||||
pub enum LeafStructMemberKind {
|
pub enum LeafStructMemberKind {
|
||||||
String,
|
String,
|
||||||
FileId,
|
FileId,
|
||||||
Range
|
Range,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
pub struct NodeProductionBuildSpec {
|
pub struct NodeProductionBuildSpec {
|
||||||
name: String,
|
name: String,
|
||||||
kind: String,
|
kind: String,
|
||||||
with: String
|
with: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NodeProductionBuildSpec {
|
impl NodeProductionBuildSpec {
|
||||||
@ -9,7 +9,7 @@ impl NodeProductionBuildSpec {
|
|||||||
Self {
|
Self {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
kind: kind.to_string(),
|
kind: kind.to_string(),
|
||||||
with: with.to_string()
|
with: with.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,11 @@ pub struct PolymorphicEnumInnerBuild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
Self {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
members,
|
members,
|
||||||
@ -28,14 +32,14 @@ impl PolymorphicEnumInnerBuild {
|
|||||||
|
|
||||||
pub struct PolymorphicEnumInnerBuildMember {
|
pub struct PolymorphicEnumInnerBuildMember {
|
||||||
name: String,
|
name: String,
|
||||||
kind: PolymorphicEnumInnerBuildMemberKind
|
kind: PolymorphicEnumInnerBuildMemberKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PolymorphicEnumInnerBuildMember {
|
impl PolymorphicEnumInnerBuildMember {
|
||||||
pub fn new(name: &str, kind: PolymorphicEnumInnerBuildMemberKind) -> Self {
|
pub fn new(name: &str, kind: PolymorphicEnumInnerBuildMemberKind) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
kind
|
kind,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +54,7 @@ impl PolymorphicEnumInnerBuildMember {
|
|||||||
|
|
||||||
pub enum PolymorphicEnumInnerBuildMemberKind {
|
pub enum PolymorphicEnumInnerBuildMemberKind {
|
||||||
Leaf,
|
Leaf,
|
||||||
Struct
|
Struct,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PolymorphicEnumInnerBuildRule {
|
pub struct PolymorphicEnumInnerBuildRule {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
|
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use crate::spec::tree_enum_spec::{EnumRuleChildKind, TreeEnumBuildSpec};
|
|
||||||
|
|
||||||
pub fn make_enum_type(build_spec: &TreeEnumBuildSpec) -> TokenStream {
|
pub fn make_enum_type(build_spec: &TreeEnumBuildSpec) -> TokenStream {
|
||||||
let children: Vec<TokenStream> = build_spec
|
let children: Vec<TokenStream> = build_spec
|
||||||
|
|||||||
@ -84,9 +84,10 @@ pub fn make_leaf_struct_type(build_spec: &LeafStructBuildSpec) -> TokenStream {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let struct_stream = if build_spec.derive().count() > 0 {
|
let struct_stream = if build_spec.derive().count() > 0 {
|
||||||
let derives = build_spec.derive().map(|derive| {
|
let derives = build_spec
|
||||||
format_ident!("{}", derive)
|
.derive()
|
||||||
}).collect::<Vec<_>>();
|
.map(|derive| format_ident!("{}", derive))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#[derive(#(#derives),*)]
|
#[derive(#(#derives),*)]
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
|
use crate::spec::polymorphic_enum_inner_build::{
|
||||||
|
PolymorphicEnumInnerBuild, PolymorphicEnumInnerBuildMemberKind,
|
||||||
|
};
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
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 {
|
pub fn make_polymorphic_enum_inner_build_type(spec: &PolymorphicEnumInnerBuild) -> TokenStream {
|
||||||
let members = spec.members()
|
let members = spec
|
||||||
|
.members()
|
||||||
.map(|member| {
|
.map(|member| {
|
||||||
let name_ident = format_ident!("{}", member.name());
|
let name_ident = format_ident!("{}", member.name());
|
||||||
match member.kind() {
|
match member.kind() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
use crate::spec::SpecialChildKind;
|
||||||
use crate::spec::polymorphic_enum_loop_spec::{
|
use crate::spec::polymorphic_enum_loop_spec::{
|
||||||
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuildChild,
|
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuildChild,
|
||||||
};
|
};
|
||||||
use crate::spec::SpecialChildKind;
|
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
|
|
||||||
|
|||||||
2
build.rs
2
build.rs
@ -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 cst_test_generator::generate_test_files;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|||||||
@ -191,14 +191,12 @@ fn assemble_ir_call(ir_call: &IrCall, context: &mut AssemblyContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assemble_ir_return(ir_return: &IrReturn, context: &mut AssemblyContext) {
|
fn assemble_ir_return(ir_return: &IrReturn, context: &mut AssemblyContext) {
|
||||||
let operand = ir_return.expression().map(|expression| {
|
let operand = ir_return.expression().map(|expression| match expression {
|
||||||
match expression {
|
IrExpression::Variable(ir_variable) => {
|
||||||
IrExpression::Variable(ir_variable) => {
|
let variable_virtual_register_id = context.get_virtual_register(ir_variable.name());
|
||||||
let variable_virtual_register_id = context.get_virtual_register(ir_variable.name());
|
AsmOperand::VirtualRegister(variable_virtual_register_id)
|
||||||
AsmOperand::VirtualRegister(variable_virtual_register_id)
|
|
||||||
}
|
|
||||||
IrExpression::Literal(ir_literal) => ir_literal_to_asm_operand(ir_literal),
|
|
||||||
}
|
}
|
||||||
|
IrExpression::Literal(ir_literal) => ir_literal_to_asm_operand(ir_literal),
|
||||||
});
|
});
|
||||||
context
|
context
|
||||||
.current_control_unit_mut()
|
.current_control_unit_mut()
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use deimos::parser::{DeimosParser, Rule};
|
use deimos::parser::{DeimosParser, Rule};
|
||||||
use std::path::PathBuf;
|
|
||||||
use pest::iterators::{Pair, Pairs};
|
use pest::iterators::{Pair, Pairs};
|
||||||
use pest::Parser;
|
use pest::Parser;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn print_pair(pair: Pair<Rule>) {
|
fn print_pair(pair: Pair<Rule>) {
|
||||||
println!("{:?}", pair.as_rule());
|
println!("{:?}", pair.as_rule());
|
||||||
|
|||||||
@ -2,6 +2,7 @@ use codespan_reporting::files::SimpleFiles;
|
|||||||
use codespan_reporting::term;
|
use codespan_reporting::term;
|
||||||
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
|
use codespan_reporting::term::termcolor::{ColorChoice, StandardStream};
|
||||||
use deimos::ast::build::build_ast;
|
use deimos::ast::build::build_ast;
|
||||||
|
use deimos::ast::node::CompilationUnit;
|
||||||
use deimos::name_analysis::analyze_names;
|
use deimos::name_analysis::analyze_names;
|
||||||
use deimos::name_analysis::symbol_table::SymbolTable;
|
use deimos::name_analysis::symbol_table::SymbolTable;
|
||||||
use deimos::parser::{DeimosParser, Rule};
|
use deimos::parser::{DeimosParser, Rule};
|
||||||
@ -10,7 +11,6 @@ use pest::Parser;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::{Debug, Display, Formatter};
|
use std::fmt::{Debug, Display, Formatter};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use deimos::ast::node::CompilationUnit;
|
|
||||||
|
|
||||||
struct ParseErrors {
|
struct ParseErrors {
|
||||||
errors: Vec<pest::error::Error<Rule>>,
|
errors: Vec<pest::error::Error<Rule>>,
|
||||||
@ -34,7 +34,9 @@ impl Display for ParseErrors {
|
|||||||
|
|
||||||
impl std::error::Error 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();
|
let mut paths_and_sources: HashMap<String, String> = HashMap::new();
|
||||||
for path in paths {
|
for path in paths {
|
||||||
let src = std::fs::read_to_string(path).unwrap();
|
let src = std::fs::read_to_string(path).unwrap();
|
||||||
|
|||||||
@ -8,10 +8,10 @@ use crate::ir::{
|
|||||||
IrPrimitiveKind, IrReturn, IrStatement, IrStructKind, IrVariable,
|
IrPrimitiveKind, IrReturn, IrStatement, IrStructKind, IrVariable,
|
||||||
};
|
};
|
||||||
use crate::name_analysis::symbol::{ClassSymbol, ParameterSymbol, PrimitiveTypeSymbol, TypeSymbol};
|
use crate::name_analysis::symbol::{ClassSymbol, ParameterSymbol, PrimitiveTypeSymbol, TypeSymbol};
|
||||||
|
use crate::type_analysis::kinds::Kind;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use crate::type_analysis::kinds::Kind;
|
|
||||||
|
|
||||||
struct CuContext {
|
struct CuContext {
|
||||||
irs: Vec<Ir>,
|
irs: Vec<Ir>,
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
use crate::ast::node::{
|
use crate::ast::node::{
|
||||||
AssignmentStatement, BacktickString, Call, Closure, ClosureParameters,
|
AssignmentStatement, BacktickString, Call, Closure, ClosureParameters, CompilationUnit,
|
||||||
CompilationUnit, ConcreteUseStatement, ConcreteUseStatementSuffix, DString, Expression,
|
ConcreteUseStatement, ConcreteUseStatementSuffix, DString, Expression, ExpressionList,
|
||||||
ExpressionList, ExpressionStatement, Function, FunctionAliasBody, FunctionBlockBody,
|
ExpressionStatement, Function, FunctionAliasBody, FunctionBlockBody, FunctionBody,
|
||||||
FunctionBody, FunctionEqualsBody, GenericParameters, Identifier, IdentifierExpression,
|
FunctionEqualsBody, GenericParameters, Identifier, IdentifierExpression, IdentifierOrFqn,
|
||||||
IdentifierOrFqn, LValue, LValueSuffix, Literal, ModuleLevelDeclaration
|
LValue, LValueSuffix, Literal, ModuleLevelDeclaration, ObjectIndex, Parameter, Parameters,
|
||||||
, ObjectIndex, Parameter, Parameters, PlatformFunction, PrimitiveType,
|
PlatformFunction, PrimitiveType, ReturnType, StarUseStatement, Statement, SuffixExpression,
|
||||||
ReturnType, StarUseStatement, Statement, SuffixExpression, SuffixOperator, TypeUse, TypedArray,
|
SuffixOperator, TypeUse, TypedArray, UseStatement, UseStatementIdentifier, UseStatementPrefix,
|
||||||
UseStatement, UseStatementIdentifier, UseStatementPrefix, VariableDeclaration,
|
VariableDeclaration,
|
||||||
};
|
};
|
||||||
use crate::diagnostic::DmDiagnostic;
|
use crate::diagnostic::DmDiagnostic;
|
||||||
use crate::name_analysis::symbol::source_definition::SourceDefinition;
|
use crate::name_analysis::symbol::source_definition::SourceDefinition;
|
||||||
@ -529,7 +529,11 @@ fn na_p2_variable_declaration(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initializer
|
// 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(
|
fn na_p2_assignment_statement(
|
||||||
@ -628,7 +632,11 @@ fn na_p2_expression(
|
|||||||
}
|
}
|
||||||
Expression::Additive(additive) => {
|
Expression::Additive(additive) => {
|
||||||
na_p2_expression(additive.left_mut(), symbol_table, diagnostics);
|
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) => {
|
Expression::Multiplicative(multiplicative) => {
|
||||||
todo!()
|
todo!()
|
||||||
|
|||||||
@ -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::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
@ -13,9 +15,7 @@ pub enum ExpressibleSymbol {
|
|||||||
impl ExpressibleSymbol {
|
impl ExpressibleSymbol {
|
||||||
pub fn to_symbol(self) -> Rc<RefCell<dyn Symbol>> {
|
pub fn to_symbol(self) -> Rc<RefCell<dyn Symbol>> {
|
||||||
match self {
|
match self {
|
||||||
ExpressibleSymbol::Class(class_symbol) => {
|
ExpressibleSymbol::Class(class_symbol) => class_symbol as Rc<RefCell<dyn Symbol>>,
|
||||||
class_symbol as Rc<RefCell<dyn Symbol>>
|
|
||||||
}
|
|
||||||
ExpressibleSymbol::Function(function_symbol) => {
|
ExpressibleSymbol::Function(function_symbol) => {
|
||||||
function_symbol as Rc<RefCell<dyn Symbol>>
|
function_symbol as Rc<RefCell<dyn Symbol>>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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::class_member_symbol::ClassMemberSymbol;
|
||||||
use crate::name_analysis::symbol::parameter_symbol::ParameterSymbol;
|
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::variable_symbol::VariableSymbol;
|
||||||
|
use crate::name_analysis::symbol::Symbol;
|
||||||
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
pub enum LVSymbol {
|
pub enum LVSymbol {
|
||||||
ClassMember(Rc<RefCell<ClassMemberSymbol>>),
|
ClassMember(Rc<RefCell<ClassMemberSymbol>>),
|
||||||
@ -17,12 +17,8 @@ impl LVSymbol {
|
|||||||
LVSymbol::ClassMember(class_member_symbol) => {
|
LVSymbol::ClassMember(class_member_symbol) => {
|
||||||
class_member_symbol as Rc<RefCell<dyn Symbol>>
|
class_member_symbol as Rc<RefCell<dyn Symbol>>
|
||||||
}
|
}
|
||||||
LVSymbol::Parameter(parameter_symbol) => {
|
LVSymbol::Parameter(parameter_symbol) => parameter_symbol as Rc<RefCell<dyn Symbol>>,
|
||||||
parameter_symbol as Rc<RefCell<dyn Symbol>>
|
LVSymbol::Variable(variable_symbol) => variable_symbol as Rc<RefCell<dyn Symbol>>,
|
||||||
}
|
|
||||||
LVSymbol::Variable(variable_symbol) => {
|
|
||||||
variable_symbol as Rc<RefCell<dyn Symbol>>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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::generic_type_symbol::GenericTypeSymbol;
|
||||||
use crate::name_analysis::symbol::interface_symbol::InterfaceSymbol;
|
use crate::name_analysis::symbol::interface_symbol::InterfaceSymbol;
|
||||||
use crate::name_analysis::symbol::primitive_type_symbol::PrimitiveTypeSymbol;
|
use crate::name_analysis::symbol::primitive_type_symbol::PrimitiveTypeSymbol;
|
||||||
|
use crate::name_analysis::symbol::Symbol;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use crate::name_analysis::symbol::Symbol;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum TypeSymbol {
|
pub enum TypeSymbol {
|
||||||
@ -21,15 +21,9 @@ impl TypeSymbol {
|
|||||||
TypeSymbol::Primitive(primitive_type_symbol) => {
|
TypeSymbol::Primitive(primitive_type_symbol) => {
|
||||||
Rc::new(RefCell::new(primitive_type_symbol))
|
Rc::new(RefCell::new(primitive_type_symbol))
|
||||||
}
|
}
|
||||||
TypeSymbol::Class(class_symbol) => {
|
TypeSymbol::Class(class_symbol) => class_symbol as Rc<RefCell<dyn 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::Interface(interface_symbol) => {
|
|
||||||
interface_symbol as Rc<RefCell<dyn Symbol>>
|
|
||||||
}
|
|
||||||
TypeSymbol::Generic(generic_symbol) => {
|
|
||||||
generic_symbol as Rc<RefCell<dyn Symbol>>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
use crate::name_analysis::symbol::source_definition::SourceDefinition;
|
use crate::name_analysis::symbol::source_definition::SourceDefinition;
|
||||||
use crate::name_analysis::symbol::Symbol;
|
use crate::name_analysis::symbol::Symbol;
|
||||||
|
use crate::type_analysis::kinds::Kind;
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use crate::type_analysis::kinds::Kind;
|
|
||||||
|
|
||||||
pub struct VariableSymbol {
|
pub struct VariableSymbol {
|
||||||
declared_name: Rc<str>,
|
declared_name: Rc<str>,
|
||||||
|
|||||||
@ -141,7 +141,9 @@ impl SymbolTable {
|
|||||||
.find_usable_symbol(concrete_use_symbol.borrow().fqn_parts())
|
.find_usable_symbol(concrete_use_symbol.borrow().fqn_parts())
|
||||||
{
|
{
|
||||||
Ok(usable_symbol) => {
|
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) => {
|
Err(symbol_lookup_error) => {
|
||||||
// panic because this is definitely a compiler/configuration 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() {
|
for star_use_symbol in global_scope.star_use_symbols() {
|
||||||
let mut star_use_symbol_ref_mut = star_use_symbol.borrow_mut();
|
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) => {
|
Ok(usable_symbols) => {
|
||||||
star_use_symbol_ref_mut.set_resolved_symbols(usable_symbols);
|
star_use_symbol_ref_mut.set_resolved_symbols(usable_symbols);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -255,16 +255,14 @@ impl Scope {
|
|||||||
.or_else(|| {
|
.or_else(|| {
|
||||||
if let Some(concrete_use_symbol) = self.concrete_use_symbols.get(declared_name) {
|
if let Some(concrete_use_symbol) = self.concrete_use_symbols.get(declared_name) {
|
||||||
return match concrete_use_symbol.borrow().resolved_symbol().unwrap() {
|
return match concrete_use_symbol.borrow().resolved_symbol().unwrap() {
|
||||||
UsableSymbol::Interface(_) => {
|
UsableSymbol::Interface(_) => None,
|
||||||
None
|
|
||||||
}
|
|
||||||
UsableSymbol::Class(class_symbol) => {
|
UsableSymbol::Class(class_symbol) => {
|
||||||
Some(ExpressibleSymbol::Class(class_symbol.clone()))
|
Some(ExpressibleSymbol::Class(class_symbol.clone()))
|
||||||
}
|
}
|
||||||
UsableSymbol::Function(function_symbol) => {
|
UsableSymbol::Function(function_symbol) => {
|
||||||
Some(ExpressibleSymbol::Function(function_symbol.clone()))
|
Some(ExpressibleSymbol::Function(function_symbol.clone()))
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
@ -279,7 +277,9 @@ impl Scope {
|
|||||||
}
|
}
|
||||||
UsableSymbol::Function(function_symbol) => {
|
UsableSymbol::Function(function_symbol) => {
|
||||||
if function_symbol.borrow().declared_name() == declared_name {
|
if function_symbol.borrow().declared_name() == declared_name {
|
||||||
return Some(ExpressibleSymbol::Function(function_symbol.clone()));
|
return Some(ExpressibleSymbol::Function(
|
||||||
|
function_symbol.clone(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ use std::rc::Rc;
|
|||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
pub struct ClassKind {
|
pub struct ClassKind {
|
||||||
fqn: Rc<str>
|
fqn: Rc<str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClassKind {
|
impl ClassKind {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use std::fmt::Display;
|
|
||||||
use crate::type_analysis::kinds::Kind;
|
use crate::type_analysis::kinds::Kind;
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Clone)]
|
#[derive(Debug, Eq, PartialEq, Clone)]
|
||||||
pub enum PrimitiveKind {
|
pub enum PrimitiveKind {
|
||||||
|
|||||||
@ -200,11 +200,10 @@ fn ta_additive_expression(
|
|||||||
"Incompatible types for additive expression: {} vs. {}",
|
"Incompatible types for additive expression: {} vs. {}",
|
||||||
left_kind, right_kind
|
left_kind, right_kind
|
||||||
))
|
))
|
||||||
.with_label(Label::primary(
|
.with_label(
|
||||||
*additive_expression.file_id(),
|
Label::primary(*additive_expression.file_id(), *additive_expression.range())
|
||||||
*additive_expression.range(),
|
.with_message("Incompatible types here."),
|
||||||
)
|
),
|
||||||
.with_message("Incompatible types here.")),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
additive_expression.set_analyzed_kind(left_kind);
|
additive_expression.set_analyzed_kind(left_kind);
|
||||||
|
|||||||
@ -394,7 +394,9 @@ impl Drop for GcHeap {
|
|||||||
let mut current = self.head().take();
|
let mut current = self.head().take();
|
||||||
while let Some(gc_any) = &mut current {
|
while let Some(gc_any) = &mut current {
|
||||||
let next = gc_any.next();
|
let next = gc_any.next();
|
||||||
unsafe { gc_any.dealloc(); }
|
unsafe {
|
||||||
|
gc_any.dealloc();
|
||||||
|
}
|
||||||
current = next;
|
current = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -464,7 +466,9 @@ fn collect_garbage(stack: &Vec<DvmValue>, heap: &mut GcHeap) {
|
|||||||
}
|
}
|
||||||
heap.subtract_current_size(current_gc.allocated_size());
|
heap.subtract_current_size(current_gc.allocated_size());
|
||||||
collected_size += current_gc.dynamic_size();
|
collected_size += current_gc.dynamic_size();
|
||||||
unsafe { current_gc.dealloc(); }
|
unsafe {
|
||||||
|
current_gc.dealloc();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
current_gc.set_color(GcColor::White);
|
current_gc.set_color(GcColor::White);
|
||||||
previous = Some(current_gc.clone());
|
previous = Some(current_gc.clone());
|
||||||
|
|||||||
@ -344,7 +344,7 @@ fn constant_to_value(constant: &DvmConstant) -> DvmValue {
|
|||||||
|
|
||||||
fn immediate_to_value(immediate: &Immediate) -> DvmValue {
|
fn immediate_to_value(immediate: &Immediate) -> DvmValue {
|
||||||
match immediate {
|
match immediate {
|
||||||
_ => todo!()
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user