Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 2021 edition #743

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "dyon"
version = "0.49.1"
edition = "2015"
edition = "2021"
authors = ["Sven Nilsen <[email protected]>"]
keywords = ["script", "scripting", "game", "language", "piston"]
description = "A rusty dynamically typed scripting language"
Expand Down
2 changes: 1 addition & 1 deletion src/ast/infer_len.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use super::{AssignOp, Block, Call, CallClosure, CallInfo, Expression, ForN, Id, Item};
use FnIndex;
use crate::FnIndex;

pub fn infer(block: &Block, name: &str) -> Option<Expression> {
let mut decls: Vec<Arc<String>> = vec![];
Expand Down
53 changes: 29 additions & 24 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
//! Dyon Abstract Syntax Tree (AST).

use piston_meta::bootstrap::Convert;
use piston_meta::MetaData;
use piston_meta::{Convert, MetaData};
use range::Range;
use std::cell::Cell;
use std::collections::HashMap;
use std::sync::{self, Arc};

use FnIndex;
use Module;
use Prelude;
use Type;
use Variable;
use crate::{
FnIndex,
Module,
Prelude,
Type,
Variable
};

mod infer_len;
mod replace;
Expand Down Expand Up @@ -1760,7 +1761,7 @@ impl Link {
}

fn precompute(&self) -> Option<Variable> {
let mut link = ::link::Link::new();
let mut link = crate::link::Link::new();
for it in &self.items {
if let Some(v) = it.precompute() {
if link.push(&v).is_err() {
Expand Down Expand Up @@ -2351,7 +2352,7 @@ pub struct Item {
/// Whether the item is a current object.
pub current: bool,
/// Whether there is a `?` after the item.
pub try: bool,
pub try_flag: bool,
/// Item ids.
pub ids: Vec<Id>,
/// Stores indices of ids that should propagate errors.
Expand All @@ -2368,7 +2369,7 @@ impl Item {
current: false,
stack_id: Cell::new(None),
static_stack_id: Cell::new(None),
try: false,
try_flag: false,
ids: vec![],
try_ids: vec![],
source_range,
Expand All @@ -2382,7 +2383,7 @@ impl Item {
current: self.current,
stack_id: Cell::new(None),
static_stack_id: Cell::new(None),
try: self.try,
try_flag: self.try_flag,
ids: self.ids.iter().take(n).cloned().collect(),
try_ids: {
let mut try_ids = vec![];
Expand Down Expand Up @@ -2414,7 +2415,7 @@ impl Item {
let mut current = false;
let mut ids = vec![];
let mut try_ids = vec![];
let mut try = false;
let mut try_flag = false;
loop {
if let Ok(range) = convert.end_node(node) {
convert.update(range);
Expand All @@ -2427,7 +2428,7 @@ impl Item {
current = true;
} else if let Ok((range, _)) = convert.meta_bool("try_item") {
convert.update(range);
try = true;
try_flag = true;
// Ignore item extra node, which is there to help the type checker.
} else if let Ok(range) = convert.start_node("item_extra") {
convert.update(range);
Expand Down Expand Up @@ -2465,7 +2466,7 @@ impl Item {
stack_id: Cell::new(None),
static_stack_id: Cell::new(None),
current,
try,
try_flag,
ids,
try_ids,
source_range: convert.source(start).unwrap(),
Expand Down Expand Up @@ -2865,11 +2866,13 @@ impl Call {
module: &Module,
use_lookup: &UseLookup,
) {
use FnBinOpRef;
use FnExt;
use FnReturnRef;
use FnUnOpRef;
use FnVoidRef;
use crate::{
FnBinOpRef,
FnExt,
FnReturnRef,
FnUnOpRef,
FnVoidRef,
};

let st = stack.len();
let f_index = if let Some(ref alias) = self.info.alias {
Expand Down Expand Up @@ -4674,11 +4677,13 @@ impl In {

#[cfg(all(not(target_family = "wasm"), feature = "threading"))]
fn resolve_locals(&mut self, relative: usize, module: &Module, use_lookup: &UseLookup) {
use FnBinOpRef;
use FnExt;
use FnReturnRef;
use FnUnOpRef;
use FnVoidRef;
use crate::{
FnBinOpRef,
FnExt,
FnReturnRef,
FnUnOpRef,
FnVoidRef,
};

let f_index = if let Some(ref alias) = self.alias {
if let Some(&i) = use_lookup
Expand Down
4 changes: 2 additions & 2 deletions src/ast/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::{
};
#[cfg(all(not(target_family = "wasm"), feature = "threading"))]
use super::{ForIn, Go};
use Variable;
use crate::Variable;

/// Replaces an item with a number.
/// Returns `(true, new_expression)` if item found declared with same name.
Expand Down Expand Up @@ -43,7 +43,7 @@ pub fn number(expr: &Expression, name: &Arc<String>, val: f64) -> Expression {
current: item.current,
stack_id: item.stack_id.clone(),
static_stack_id: item.static_stack_id.clone(),
try: item.try,
try_flag: item.try_flag,
ids: new_ids,
try_ids: item.try_ids.clone(),
source_range: item.source_range,
Expand Down
4 changes: 2 additions & 2 deletions src/dyon_std/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use read_token::{NumberSettings, ReadToken};
#[cfg(feature = "file")]
use super::io::io_error;

use Variable;
use crate::Variable;

type Strings = HashSet<Arc<String>>;

Expand Down Expand Up @@ -234,7 +234,7 @@ fn array(read: &mut ReadToken, strings: &mut Strings, data: &str) -> Result<Vari
}

fn link(read: &mut ReadToken, strings: &mut Strings, data: &str) -> Result<Variable, String> {
use Link;
use crate::Link;

opt_w(read);

Expand Down
4 changes: 1 addition & 3 deletions src/dyon_std/functions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::collections::HashMap;
use std::sync::Arc;

use Lt;
use Module;
use Variable;
use crate::{Lt, Module, Variable};

/// Lists all functions available in a module.
pub fn list_functions(module: &Module) -> Vec<Variable> {
Expand Down
4 changes: 1 addition & 3 deletions src/dyon_std/lifetimechk.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use ast;
use std::collections::HashMap;
use std::sync::Arc;
use Array;
use Variable;
use crate::{ast, Array, Variable};

/// Performs a runtime lifetime check on arguments.
pub fn check(f: &ast::Function, args: &Array) -> Result<(), String> {
Expand Down
2 changes: 1 addition & 1 deletion src/dyon_std/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::io;
use std::io::Read;
use std::sync::Arc;

use Variable;
use crate::Variable;

pub fn parse_syntax_data(rules: &Syntax, file: &str, d: &str) -> Result<Vec<Variable>, String> {
let mut tokens = vec![];
Expand Down
8 changes: 4 additions & 4 deletions src/dyon_std/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(non_snake_case)]

use *;
use crate::*;

mod data;
mod functions;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ pub(crate) fn load(rt: &mut Runtime) -> Result<Variable, String> {

#[cfg(feature = "dynload")]
pub(crate) fn load__source_imports(rt: &mut Runtime) -> Result<Variable, String> {
use load;
use crate::load;

let modules = rt.stack.pop().expect(TINVOTS);
let source = rt.stack.pop().expect(TINVOTS);
Expand Down Expand Up @@ -1276,7 +1276,7 @@ pub(crate) fn check__in_string_imports(rt: &mut Runtime) -> Result<Variable, Str
);
obj.insert(ALIAS.clone(), n.alias.push_var());
obj.insert(MUTABLE.clone(), n.mutable.push_var());
obj.insert(TRY.clone(), n.try.push_var());
obj.insert(TRY.clone(), n.try_flag.push_var());
obj.insert(GRAB_LEVEL.clone(), (n.grab_level as u32).push_var());
obj.insert(SOURCE_OFFSET.clone(), n.source.offset.push_var());
obj.insert(SOURCE_LENGTH.clone(), n.source.length.push_var());
Expand Down Expand Up @@ -1861,7 +1861,7 @@ pub(crate) fn save__data_file(rt: &mut Runtime) -> Result<Variable, String> {
};
let res = match write_variable(&mut f, rt, &data, EscapeString::Json, 0) {
Ok(()) => Ok(Box::new(Variable::Str(file))),
Err(err) => Err(Box::new(::Error {
Err(err) => Err(Box::new(Error {
message: Variable::Str(Arc::new(format!(
"Error when writing to file `{}`:\n{}",
file,
Expand Down
12 changes: 7 additions & 5 deletions src/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

use std::sync::Arc;

use Error;
use Object;
use Runtime;
use RustObject;
use Variable;
use crate::{
Error,
Object,
Runtime,
RustObject,
Variable,
};

/// Gets value of object field.
pub fn obj_field<T: PopVariable>(rt: &Runtime, obj: &Object, name: &str) -> Result<T, String> {
Expand Down
7 changes: 3 additions & 4 deletions src/grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ Evaluate grab expressions and return closure where grab expressions
are constants.
*/

use ast;
use runtime::{Flow, Runtime, Side};
use std::sync::Arc;
use Variable;
use crate::{ast, Variable};
use crate::runtime::{Flow, Runtime, Side};

#[derive(Debug)]
pub enum Grabbed {
Expand Down Expand Up @@ -730,7 +729,7 @@ fn grab_item(
stack_id: item.stack_id.clone(),
static_stack_id: item.static_stack_id.clone(),
current: item.current,
try: item.try,
try_flag: item.try_flag,
ids: {
let mut new_ids = vec![];
for id in &item.ids {
Expand Down
16 changes: 8 additions & 8 deletions src/lifetime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ use self::range::Range;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;

use ast::{AssignOp, UseLookup};
use prelude::{Lt, Prelude};
use crate::ast::{AssignOp, UseLookup};
use crate::prelude::{Lt, Prelude};

use Type;
use crate::Type;

mod kind;
mod lt;
Expand Down Expand Up @@ -66,7 +66,7 @@ pub(crate) fn check_core(
declaration: None,
alias: None,
mutable: false,
try: false,
try_flag: false,
grab_level: 0,
source: nodes[i].source,
start: nodes[i].start,
Expand Down Expand Up @@ -110,7 +110,7 @@ pub(crate) fn check_core(
_ => {}
}
} else if nodes[i].binops.len() == 1 && nodes[i].children.len() == 2 {
use ast::BinOp::*;
use crate::ast::BinOp::*;

Node::rewrite_binop(
i,
Expand Down Expand Up @@ -621,7 +621,7 @@ pub(crate) fn check_core(
let mut use_lookup: UseLookup = UseLookup::new();
for node in nodes.iter() {
if node.kind == Kind::Uses {
use ast::Uses;
use crate::ast::Uses;
use piston_meta::bootstrap::Convert;

let convert = Convert::new(&data[node.start..node.end]);
Expand Down Expand Up @@ -659,7 +659,7 @@ pub(crate) fn check_core(
let node = &mut nodes[c];
let name = node.name().expect("Expected name").clone();
if let Some(ref alias) = node.alias {
use ast::FnAlias;
use crate::ast::FnAlias;

// External functions are treated as loaded in prelude.
if let Some(&FnAlias::Loaded(i)) =
Expand Down Expand Up @@ -712,7 +712,7 @@ pub(crate) fn check_core(
let node = &mut nodes[c];
let name = node.name().expect("Expected name").clone();
if let Some(ref alias) = node.alias {
use ast::FnAlias;
use crate::ast::FnAlias;

// External functions are treated as loaded in prelude.
if let Some(&FnAlias::Loaded(i)) =
Expand Down
Loading