fixes
This commit is contained in:
parent
622893ebf0
commit
781e8ba3a3
13 changed files with 20 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
use core::fmt;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::chunk::{Arg24, Catch, Chunk, Instruction as I};
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
symbol::{Symbol, SYM_MSG, SYM_TRACE, SYM_TYPE},
|
||||
value::Value,
|
||||
};
|
||||
use std::{fmt::Display, rc::Rc};
|
||||
use std::{error::Error, fmt::Display, rc::Rc};
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Exception>;
|
||||
|
||||
|
@ -114,6 +114,8 @@ impl Display for Exception {
|
|||
}
|
||||
}
|
||||
|
||||
impl Error for Exception {}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exception {
|
||||
($exc_ty:expr, $($t:tt)*) => {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use core::{f64, panic};
|
||||
use std::{borrow::Cow, cmp::Ordering, fmt, hash::Hash, mem::ManuallyDrop, ops, rc::Rc};
|
||||
|
||||
use num::{
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use core::panic;
|
||||
|
||||
use crate::{
|
||||
parser::ast::{CatchBlock, Expr, ExprKind, LValue, LValueKind, ListItem, TableItem},
|
||||
value::Value,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use core::fmt;
|
||||
use std::fmt;
|
||||
|
||||
use crate::{
|
||||
ops::{BinaryOp, UnaryOp},
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use core::fmt;
|
||||
use std::num::ParseFloatError;
|
||||
use std::{fmt, num::ParseFloatError};
|
||||
|
||||
use num::{bigint::ParseBigIntError, Num};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use core::fmt;
|
||||
use std::fmt;
|
||||
use std::io::{self, Write};
|
||||
|
||||
use num::{bigint::Sign, BigInt};
|
||||
|
|
|
@ -16,6 +16,7 @@ regex = { version = "1.11", optional = true }
|
|||
rand = { version = "0.8", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["rand", "regex"]
|
||||
default = ["rand", "regex", "file"]
|
||||
rand = ["dep:rand", "dep:num-bigint"]
|
||||
regex = ["dep:regex"]
|
||||
file = []
|
||||
|
|
|
@ -678,6 +678,7 @@ fn spawn_inner(fname: &str, proc: &mut Command, opts: Value) -> Result<Value> {
|
|||
Ok(c) => c,
|
||||
Err(e) => throw!(*SYM_IO_ERROR, "{e}"),
|
||||
};
|
||||
#[expect(clippy::mutable_key_type)]
|
||||
let mut table = HashMap::new();
|
||||
if let Some(stdin) = child.stdin.take() {
|
||||
let bf = match BufFile::from_raw_fd(stdin.into_raw_fd(), true) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::{
|
||||
io::{BufRead, Write},
|
||||
os::unix::ffi::OsStrExt,
|
||||
sync::Mutex,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
@ -127,7 +126,7 @@ pub fn env(_: &mut Vm, args: Vec<Value>) -> Result<Value> {
|
|||
}
|
||||
let val = std::env::var_os(key.to_os_str());
|
||||
match val {
|
||||
Some(val) => Ok(LString::from(val.as_bytes()).into()),
|
||||
Some(val) => Ok(LString::from(val.as_encoded_bytes()).into()),
|
||||
None => Ok(Value::Nil),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -619,6 +619,7 @@ pub fn list(vm: &mut Vm, args: Vec<Value>) -> Result<Value> {
|
|||
pub fn table(vm: &mut Vm, args: Vec<Value>) -> Result<Value> {
|
||||
let [_, iter] = unpack_args!(args);
|
||||
let iter = iter.to_iter_function()?;
|
||||
#[expect(clippy::mutable_key_type)]
|
||||
let mut result = HashMap::new();
|
||||
while let Some(value) = vmcalliter!(vm; iter.clone())? {
|
||||
let Value::List(l) = value else {
|
||||
|
@ -851,6 +852,7 @@ pub fn count(vm: &mut Vm, args: Vec<Value>) -> Result<Value> {
|
|||
let [_, iter] = unpack_args!(args);
|
||||
let iter = iter.to_iter_function()?;
|
||||
|
||||
#[expect(clippy::mutable_key_type)]
|
||||
let mut map = HashMap::new();
|
||||
|
||||
while let Some(v) = vmcalliter!(vm; iter.clone())? {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![allow(clippy::mutable_key_type)]
|
||||
|
||||
use talc_lang::{
|
||||
symbol::{symbol, Symbol},
|
||||
vm::Vm,
|
||||
|
@ -7,7 +5,6 @@ use talc_lang::{
|
|||
|
||||
pub mod collection;
|
||||
pub mod exception;
|
||||
pub mod file;
|
||||
pub mod format;
|
||||
pub mod ints;
|
||||
pub mod io;
|
||||
|
@ -16,6 +13,8 @@ pub mod math;
|
|||
pub mod string;
|
||||
pub mod value;
|
||||
|
||||
#[cfg(feature = "file")]
|
||||
pub mod file;
|
||||
#[cfg(feature = "rand")]
|
||||
pub mod random;
|
||||
#[cfg(feature = "regex")]
|
||||
|
@ -24,7 +23,6 @@ pub mod regex;
|
|||
pub fn load_all(vm: &mut Vm) {
|
||||
collection::load(vm);
|
||||
exception::load(vm);
|
||||
file::load(vm);
|
||||
format::load(vm);
|
||||
io::load(vm);
|
||||
iter::load(vm);
|
||||
|
@ -33,6 +31,8 @@ pub fn load_all(vm: &mut Vm) {
|
|||
string::load(vm);
|
||||
value::load(vm);
|
||||
|
||||
#[cfg(feature = "file")]
|
||||
file::load(vm);
|
||||
#[cfg(feature = "rand")]
|
||||
random::load(vm);
|
||||
#[cfg(feature = "regex")]
|
||||
|
|
|
@ -130,11 +130,14 @@ pub fn copy_inner(value: Value) -> Result<Value> {
|
|||
Ok(v?.into())
|
||||
}
|
||||
Value::Table(t) => {
|
||||
#[expect(clippy::mutable_key_type)]
|
||||
let t = Rc::unwrap_or_clone(t).take();
|
||||
|
||||
let v: Result<HashMap<HashValue, Value>> = t
|
||||
.into_iter()
|
||||
.map(|(k, v)| copy_inner(v).map(|v| (k, v)))
|
||||
.collect();
|
||||
|
||||
Ok(v?.into())
|
||||
}
|
||||
Value::Native(ref n) => match n.copy_value()? {
|
||||
|
|
Loading…
Add table
Reference in a new issue