Skip to content

Commit

Permalink
Merge pull request #81 from mrodz/80-move-away-from-nightly-builds
Browse files Browse the repository at this point in the history
remove all feature flags
  • Loading branch information
mrodz authored Jun 29, 2023
2 parents 86f4186 + 0766a1a commit 7067887
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 67 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ jobs:
steps:
- name: Set up rust
uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
components: rustfmt, clippy
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Build
run: cargo +nightly build --verbose
run: cargo build --verbose
- name: Unit Tests
run: cargo +nightly test --verbose --all
run: cargo test --verbose --all
- name: Clippy
run: cargo clippy --verbose -- -D warnings
- name: Audit
Expand Down
1 change: 0 additions & 1 deletion bytecode/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! This is the API for all-things-bytecode.
#![feature(box_patterns)]
#![allow(dead_code)]

pub(crate) mod context;
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ impl<'a> Dependency<'a> {
let other_ty: &TypeLayout = other.ident.ty()?.as_ref();
let self_ty: &TypeLayout = self.ident.ty()?.as_ref();

if let TypeLayout::CallbackVariable(box ptr_ty) = other_ty {
if let TypeLayout::CallbackVariable(ptr_ty) = other_ty {
if other.cycles_needed > 0 {
return Ok(self_ty == ptr_ty)
return Ok(self_ty == ptr_ty.as_ref())
}
}

Expand Down
39 changes: 4 additions & 35 deletions compiler/src/ast/assignment_no_type.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use std::borrow::Cow;

use anyhow::Result;

use crate::parser::{Node, Parser};

use super::{map_err_messages, r#type::IntoType, Assignment, Value};
use super::{map_err_messages, Assignment};

impl Parser {
pub fn assignment_no_type(input: Node, is_const: bool) -> Result<(Assignment, bool)> {
Expand All @@ -16,7 +14,7 @@ impl Parser {
let mut ident = Self::ident(ident)?;

let did_exist_before = input.user_data().has_name_been_mapped_local(ident.name());

if is_const {
ident.mark_const();
}
Expand All @@ -25,37 +23,8 @@ impl Parser {

let user_data = input.user_data();

let maybe_error: Result<()> = try {
match value {
Value::Function(ref f) => {
ident.link_force_no_inherit(user_data, Cow::Owned(f.for_type()?))?;
}
Value::Ident(..) => {
ident.link_from_pointed_type_with_lookup(user_data)?;
}
Value::Number(ref number) => {
let ty = number.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Value::String(ref string) => {
let ty = string.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Value::MathExpr(ref math_expr) => {
let ty = math_expr.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Value::Callable(ref callback) => {
let ty = callback.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Value::Boolean(ref boolean) => {
let ty = boolean.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
}
};

let maybe_error = value.associate_with_ident(&mut ident, user_data);

map_err_messages(
maybe_error,
input.as_span(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/ast/callable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl IntoType for Callable {
let ident = self.ident.ty()?;
let ident = ident.get_type_recursively();

let (box ScopeReturnStatus::Should(ref return_type) | box ScopeReturnStatus::Did(ref return_type)) = ident.is_function().context("not a function")?.return_type else {
let (ScopeReturnStatus::Should(ref return_type) | ScopeReturnStatus::Did(ref return_type)) = ident.is_function().context("not a function")?.return_type.as_ref() else {
bail!("function returns void")
};

Expand Down
13 changes: 6 additions & 7 deletions compiler/src/ast/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ impl FunctionType {

impl Display for FunctionType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let return_type: Cow<'static, str> = if let box ScopeReturnStatus::Should(return_type)
| box ScopeReturnStatus::Did(return_type) =
&self.return_type
let return_type: Cow<'static, str> = if let ScopeReturnStatus::Should(return_type)
| ScopeReturnStatus::Did(return_type) =
&self.return_type.as_ref()
{
let actual_type = match return_type.as_ref() {
TypeLayout::Function(..) => {
Expand Down Expand Up @@ -154,10 +154,9 @@ impl Function {

arguments.push(format!("{x}#{id}"));

dependencies
.iter()
.map(|ident| ident.name().clone())
.collect_into(&mut arguments);
for dependency in dependencies {
arguments.push(dependency.name().clone());
}

let arguments = arguments.into_boxed_slice();

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/ast/math_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fn compile_depth(
match expr {
Expr::Value(val) => val.compile(function_buffer),
Expr::UnaryMinus(expr) => {
if let box Expr::Value(value) = expr {
if let Expr::Value(value) = expr.as_ref() {
match value {
Value::Ident(ident) => {
let x = ident.ty().context("no type data")?;
Expand Down
54 changes: 49 additions & 5 deletions compiler/src/ast/value.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::{borrow::Cow, ops::Deref};

use anyhow::Result;

use crate::parser::{Node, Parser, Rule};
use crate::parser::{AssocFileData, Node, Parser, Rule};

use super::{
math_expr::Expr, r#type::IntoType, string::AstString, Compile, CompiledItem, Dependencies,
Dependency, Function, Ident, Number, TypeLayout, Callable,
math_expr::Expr, r#type::IntoType, string::AstString, Callable, Compile, CompiledItem,
Dependencies, Dependency, Function, Ident, Number, TypeLayout,
};

#[derive(Debug)]
Expand All @@ -15,12 +17,54 @@ pub(crate) enum Value {
String(AstString),
MathExpr(Box<Expr>),
Callable(Callable),
Boolean(bool)
Boolean(bool),
}

impl Value {
pub fn is_callable(&self) -> bool {
matches!(self, Value::Callable(..) | Value::MathExpr(box Expr::Value(Value::Callable(..))))
match self {
Value::Callable(..) => true,
Value::MathExpr(maybe_value)
if matches!(maybe_value.deref(), Expr::Value(Value::Callable(..))) =>
{
true
}
_ => false,
}
}

pub fn associate_with_ident(&self, ident: &mut Ident, user_data: &AssocFileData) -> Result<()> {
match self {
Self::Function(ref f) => {
let ty = f.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Self::Ident(..) => {
ident.link_from_pointed_type_with_lookup(user_data)?;
}
Self::Number(ref number) => {
let ty = number.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Self::String(ref string) => {
let ty = string.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Self::MathExpr(ref math_expr) => {
let ty = math_expr.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Self::Callable(ref callback) => {
let ty = callback.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
Self::Boolean(ref boolean) => {
let ty = boolean.for_type()?;
ident.link_force_no_inherit(user_data, Cow::Owned(ty))?;
}
}

Ok(())
}
}

Expand Down
5 changes: 0 additions & 5 deletions compiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
#![feature(box_patterns)]
#![feature(iter_intersperse)]
#![feature(iter_collect_into)]
#![feature(try_blocks)]

/// for #[derive()] macro in `parser.rs`
extern crate alloc;

Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(box_patterns)]

mod cli;

use anyhow::{bail, Context, Result};
Expand Down

0 comments on commit 7067887

Please sign in to comment.