Compare commits

..

No commits in common. "abdc97f9de35f8cb6ff3474f54e6115c0a864844" and "ada12600b3a1f5cc7bb228f03b8d5779beaa6039" have entirely different histories.

5 changed files with 86 additions and 87 deletions

67
Cargo.lock generated
View File

@ -4,9 +4,9 @@ version = 3
[[package]]
name = "ab_glyph"
version = "0.2.29"
version = "0.2.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3672c180e71eeaaac3a541fbbc5f5ad4def8b747c595ad30d674e43049f7b0"
checksum = "79faae4620f45232f599d9bc7b290f88247a0834162c4495ab2f02d60004adfb"
dependencies = [
"ab_glyph_rasterizer",
"owned_ttf_parser",
@ -323,9 +323,9 @@ dependencies = [
[[package]]
name = "async-once-cell"
version = "0.5.4"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288f83726785267c6f2ef073a3d83dc3f9b81464e9f99898240cced85fce35a"
checksum = "9338790e78aa95a416786ec8389546c4b6a1dfc3dc36071ed9518a9413a542eb"
[[package]]
name = "async-process"
@ -599,9 +599,9 @@ dependencies = [
[[package]]
name = "bytemuck_derive"
version = "1.8.0"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec"
checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26"
dependencies = [
"proc-macro2",
"quote",
@ -680,9 +680,9 @@ dependencies = [
[[package]]
name = "cc"
version = "1.1.28"
version = "1.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1"
checksum = "e8d9e0b4957f635b8d3da819d0db5603620467ecf1f692d22a8c2717ce27e6d8"
dependencies = [
"jobserver",
"libc",
@ -1390,15 +1390,15 @@ dependencies = [
[[package]]
name = "futures-core"
version = "0.3.31"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]]
name = "futures-io"
version = "0.3.31"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1"
[[package]]
name = "futures-lite"
@ -1430,21 +1430,21 @@ dependencies = [
[[package]]
name = "futures-sink"
version = "0.3.31"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5"
[[package]]
name = "futures-task"
version = "0.3.31"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]]
name = "futures-util"
version = "0.3.31"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [
"futures-core",
"futures-io",
@ -2098,7 +2098,7 @@ dependencies = [
[[package]]
name = "nac3ast"
version = "0.1.0"
source = "git+https://git.m-labs.hk/M-Labs/nac3?rev=5839badadd732262dc24af2971a94dde60f7103e#5839badadd732262dc24af2971a94dde60f7103e"
source = "git+https://git.m-labs.hk/M-Labs/nac3?rev=581b2f7bb283e74f73450012206846bacf52b19c#581b2f7bb283e74f73450012206846bacf52b19c"
dependencies = [
"fxhash",
"lazy_static",
@ -2109,7 +2109,7 @@ dependencies = [
[[package]]
name = "nac3core"
version = "0.1.0"
source = "git+https://git.m-labs.hk/M-Labs/nac3?rev=5839badadd732262dc24af2971a94dde60f7103e#5839badadd732262dc24af2971a94dde60f7103e"
source = "git+https://git.m-labs.hk/M-Labs/nac3?rev=581b2f7bb283e74f73450012206846bacf52b19c#581b2f7bb283e74f73450012206846bacf52b19c"
dependencies = [
"crossbeam",
"indexmap",
@ -2126,7 +2126,7 @@ dependencies = [
[[package]]
name = "nac3parser"
version = "0.1.2"
source = "git+https://git.m-labs.hk/M-Labs/nac3?rev=5839badadd732262dc24af2971a94dde60f7103e#5839badadd732262dc24af2971a94dde60f7103e"
source = "git+https://git.m-labs.hk/M-Labs/nac3?rev=581b2f7bb283e74f73450012206846bacf52b19c#581b2f7bb283e74f73450012206846bacf52b19c"
dependencies = [
"ahash",
"lalrpop",
@ -2421,9 +2421,12 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.20.2"
version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
dependencies = [
"portable-atomic",
]
[[package]]
name = "orbclient"
@ -2446,9 +2449,9 @@ dependencies = [
[[package]]
name = "owned_ttf_parser"
version = "0.25.0"
version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ec719bbf3b2a81c109a4e20b1f129b5566b7dce654bc3872f6a05abf82b2c4"
checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90"
dependencies = [
"ttf-parser",
]
@ -2657,6 +2660,12 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "portable-atomic"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
[[package]]
name = "powerfmt"
version = "0.2.0"
@ -2714,9 +2723,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.87"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
dependencies = [
"unicode-ident",
]
@ -3481,9 +3490,9 @@ dependencies = [
[[package]]
name = "ttf-parser"
version = "0.25.0"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5902c5d130972a0000f60860bfbf46f7ca3db5391eddfedd1b8728bd9dc96c0e"
checksum = "5be21190ff5d38e8b4a2d3b6a3ae57f612cc39c96e83cedeaf7abc338a8bac4a"
[[package]]
name = "type-map"

View File

@ -15,4 +15,4 @@ rustfft = "6.2"
[dependencies.nac3core]
git = "https://git.m-labs.hk/M-Labs/nac3"
rev = "5839badadd732262dc24af2971a94dde60f7103e"
rev = "581b2f7bb283e74f73450012206846bacf52b19c"

View File

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1728193676,
"narHash": "sha256-PbDWAIjKJdlVg+qQRhzdSor04bAPApDqIv2DofTyynk=",
"lastModified": 1727907660,
"narHash": "sha256-QftbyPoieM5M50WKUMzQmWtBWib/ZJbHo7mhj5riQec=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ecbc1ca8ffd6aea8372ad16be9ebbb39889e55b6",
"rev": "5966581aa04be7eff830b9e1457d56dc70a0b798",
"type": "github"
},
"original": {

View File

@ -20,7 +20,7 @@
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"nac3ast-0.1.0" = "sha256-38HCzhXPl3RG6hMs+Aq0iuuN58eK2cioAXWOzAGk4qU=";
"nac3ast-0.1.0" = "sha256-3+e6JTlhepXyD/BfSqq8pgjakLCjiBZAhvOiCNMqe5c=";
};
};
nativeBuildInputs = [

View File

@ -121,52 +121,48 @@ fn handle_typevar_definition(
fn handle_assignment_pattern(
targets: &[nac3parser::ast::Expr],
value: &nac3parser::ast::Expr,
resolver: Arc<dyn nac3core::symbol_resolver::SymbolResolver + Send + Sync>,
resolver: &(dyn nac3core::symbol_resolver::SymbolResolver + Send + Sync),
internal_resolver: &ResolverInternal,
composer: &mut composer::TopLevelComposer,
def_list: &[Arc<RwLock<toplevel::TopLevelDef>>],
unifier: &mut nac3core::typecheck::typedef::Unifier,
primitives: &type_inferencer::PrimitiveStore,
) -> Result<(), String> {
if targets.len() == 1 {
let target = &targets[0];
match &target.node {
match &targets[0].node {
nac3parser::ast::ExprKind::Name { id, .. } => {
let def_list = composer.extract_def_list();
let unifier = &mut composer.unifier;
let primitives = &composer.primitives_ty;
if let Ok(var) =
handle_typevar_definition(value, &*resolver, &def_list, unifier, primitives)
handle_typevar_definition(value, resolver, def_list, unifier, primitives)
{
internal_resolver.add_id_type(*id, var);
Ok(())
} else if let Ok(val) = toplevel::helper::parse_parameter_default_value(value, &*resolver) {
} else if let Ok(val) =
toplevel::helper::parse_parameter_default_value(value, resolver)
{
internal_resolver.add_module_global(*id, val);
let (name, def_id, _) = composer
.register_top_level_var(
*id,
None,
Some(resolver.clone()),
"__main__",
target.location,
)
.unwrap();
internal_resolver.add_id_def(name, def_id);
Ok(())
} else {
Err(format!("fails to evaluate this expression `{:?}` as a constant or generic parameter at {}",
target.node,
target.location,
targets[0].node,
targets[0].location,
))
}
}
nac3parser::ast::ExprKind::List { elts, .. }
| nac3parser::ast::ExprKind::Tuple { elts, .. } => {
handle_assignment_pattern(elts, value, resolver, internal_resolver, composer)?;
handle_assignment_pattern(
elts,
value,
resolver,
internal_resolver,
def_list,
unifier,
primitives,
)?;
Ok(())
}
_ => Err(format!(
"assignment to {target:?} is not supported at {}",
target.location
"assignment to {:?} is not supported at {}",
targets[0], targets[0].location
)),
}
} else {
@ -178,9 +174,11 @@ fn handle_assignment_pattern(
handle_assignment_pattern(
std::slice::from_ref(tar),
val,
resolver.clone(),
resolver,
internal_resolver,
composer,
def_list,
unifier,
primitives,
)?;
}
Ok(())
@ -204,9 +202,8 @@ fn handle_assignment_pattern(
fn handle_global_var(
target: &nac3parser::ast::Expr,
value: Option<&nac3parser::ast::Expr>,
resolver: &Arc<dyn nac3core::symbol_resolver::SymbolResolver + Send + Sync>,
resolver: &(dyn nac3core::symbol_resolver::SymbolResolver + Send + Sync),
internal_resolver: &ResolverInternal,
composer: &mut composer::TopLevelComposer,
) -> Result<(), String> {
let nac3parser::ast::ExprKind::Name { id, .. } = target.node else {
return Err(format!(
@ -221,18 +218,8 @@ fn handle_global_var(
));
};
if let Ok(val) = toplevel::helper::parse_parameter_default_value(value, &**resolver) {
if let Ok(val) = toplevel::helper::parse_parameter_default_value(value, resolver) {
internal_resolver.add_module_global(id, val);
let (name, def_id, _) = composer
.register_top_level_var(
id,
None,
Some(resolver.clone()),
"__main__",
target.location,
)
.unwrap();
internal_resolver.add_id_def(name, def_id);
Ok(())
} else {
Err(format!(
@ -395,12 +382,17 @@ fn compile(code: &String, run_symbol: &String, output_filename: &Path) -> Result
for mut stmt in parser_result {
match stmt.node {
nac3parser::ast::StmtKind::Assign { targets, value, .. } => {
let def_list = composer.extract_def_list();
let unifier = &mut composer.unifier;
let primitives = &composer.primitives_ty;
handle_assignment_pattern(
&targets,
&value,
resolver.clone(),
resolver.as_ref(),
internal_resolver.as_ref(),
&mut composer,
&def_list,
unifier,
primitives,
)?;
}
nac3parser::ast::StmtKind::AnnAssign {
@ -411,10 +403,14 @@ fn compile(code: &String, run_symbol: &String, output_filename: &Path) -> Result
handle_global_var(
&target,
value.as_ref().map(Box::as_ref),
&resolver,
resolver.as_ref(),
internal_resolver.as_ref(),
&mut composer,
)?;
let (name, def_id, _) = composer
.register_top_level(stmt, Some(resolver.clone()), "__main__", true)
.unwrap();
internal_resolver.add_id_def(name, def_id);
}
_ => {
if let nac3parser::ast::StmtKind::FunctionDef { name, .. } = &mut stmt.node {
@ -693,17 +689,11 @@ pub extern "C" fn __nac3_cells_fft(reals: *mut List, imags: *mut List) {
let mut planner = rustfft::FftPlanner::<f64>::new();
let fft = planner.plan_fft_forward(reals_slice.len());
let mut buffer = vec![num_complex::Complex { re: 0.0, im: 0.0 }; reals_slice.len()];
for (buf, (re, im)) in buffer
.iter_mut()
.zip(reals_slice.iter().zip(imags_slice.iter()))
{
for (buf, (re, im)) in buffer.iter_mut().zip(reals_slice.iter().zip(imags_slice.iter())) {
*buf = num_complex::Complex { re: *re, im: *im };
}
fft.process(&mut buffer);
for (buf, (re, im)) in buffer
.iter()
.zip(reals_slice.iter_mut().zip(imags_slice.iter_mut()))
{
for (buf, (re, im)) in buffer.iter().zip(reals_slice.iter_mut().zip(imags_slice.iter_mut())) {
*re = buf.re;
*im = buf.im;
}