From 089b9e0ca77f75a725ec0f460b8b109e5aab00cd Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Tue, 8 Oct 2024 22:39:53 -0500 Subject: [PATCH 1/5] Added ability to declare enums as public --- src/ast/enumeration.rs | 3 ++- src/interpreter_env/mod.rs | 1 + src/parser/parse_enum.rs | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ast/enumeration.rs b/src/ast/enumeration.rs index 5f81c48..f384b0e 100644 --- a/src/ast/enumeration.rs +++ b/src/ast/enumeration.rs @@ -1,4 +1,4 @@ -use super::Type; +use super::{Privacy, Type}; use crate::source_files::Source; use indexmap::IndexMap; use num::BigInt; @@ -8,6 +8,7 @@ pub struct Enum { pub backing_type: Option, pub source: Source, pub members: IndexMap, + pub privacy: Privacy, } #[derive(Clone, Debug, PartialEq)] diff --git a/src/interpreter_env/mod.rs b/src/interpreter_env/mod.rs index 56eec2e..dfc25c1 100644 --- a/src/interpreter_env/mod.rs +++ b/src/interpreter_env/mod.rs @@ -127,6 +127,7 @@ pub fn setup_build_system_interpreter_symbols(file: &mut AstFile) { }, ), ]), + privacy: Privacy::Private, }, ); diff --git a/src/parser/parse_enum.rs b/src/parser/parse_enum.rs index 48bb07b..a558e45 100644 --- a/src/parser/parse_enum.rs +++ b/src/parser/parse_enum.rs @@ -1,6 +1,6 @@ use super::{annotation::Annotation, error::ParseError, Parser}; use crate::{ - ast::{Enum, EnumMember, Named}, + ast::{Enum, EnumMember, Named, Privacy}, inflow::Inflow, name::Name, parser::annotation::AnnotationKind, @@ -14,14 +14,15 @@ impl<'a, I: Inflow> Parser<'a, I> { let source = self.source_here(); assert!(self.input.advance().is_enum_keyword()); + let mut privacy = Privacy::Private; let mut namespace = None; let name = self.parse_identifier(Some("for enum name after 'enum' keyword"))?; self.ignore_newlines(); - #[allow(clippy::never_loop, clippy::match_single_binding)] for annotation in annotations { match annotation.kind { AnnotationKind::Namespace(new_namespace) => namespace = Some(new_namespace), + AnnotationKind::Public => privacy = Privacy::Public, _ => return Err(self.unexpected_annotation(&annotation, Some("for enum"))), } } @@ -63,6 +64,7 @@ impl<'a, I: Inflow> Parser<'a, I> { backing_type: None, members, source, + privacy, }, }) } From f672a5d534dcc15e5b1e728aa33c422f9e82e4c6 Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Wed, 9 Oct 2024 20:37:03 -0500 Subject: [PATCH 2/5] Added ability to make type aliases and expression definitions public --- src/ast/helper_expr.rs | 3 ++- src/ast/type_alias.rs | 3 ++- src/c/translation/mod.rs | 3 ++- src/c/translation/types/enumeration.rs | 3 ++- src/parser/parse_helper_expr.rs | 5 ++++- src/parser/parse_type_alias.rs | 5 ++++- src/workspace/mod.rs | 3 ++- 7 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ast/helper_expr.rs b/src/ast/helper_expr.rs index ccf74c2..c988ca7 100644 --- a/src/ast/helper_expr.rs +++ b/src/ast/helper_expr.rs @@ -1,4 +1,4 @@ -use super::Expr; +use super::{Expr, Privacy}; use crate::source_files::Source; #[derive(Debug, Clone)] @@ -6,4 +6,5 @@ pub struct HelperExpr { pub value: Expr, pub source: Source, pub is_file_local_only: bool, + pub privacy: Privacy, } diff --git a/src/ast/type_alias.rs b/src/ast/type_alias.rs index bd9eede..4f28e74 100644 --- a/src/ast/type_alias.rs +++ b/src/ast/type_alias.rs @@ -1,8 +1,9 @@ -use super::Type; +use super::{Privacy, Type}; use crate::source_files::Source; #[derive(Clone, Debug)] pub struct TypeAlias { pub value: Type, pub source: Source, + pub privacy: Privacy, } diff --git a/src/c/translation/mod.rs b/src/c/translation/mod.rs index 9fd7eae..4b3a7b7 100644 --- a/src/c/translation/mod.rs +++ b/src/c/translation/mod.rs @@ -7,7 +7,7 @@ mod types; use self::types::get_name_and_type; pub use self::{expr::translate_expr, function::declare_function}; use crate::{ - ast::{self, AstFile}, + ast::{self, AstFile, Privacy}, c::parser::{CTypedef, DeclarationSpecifiers, Declarator, ParseError}, diagnostics::Diagnostics, name::Name, @@ -37,6 +37,7 @@ pub fn declare_named_declaration( ast::TypeAlias { value: ast_type.clone(), source: declarator.source, + privacy: Privacy::Public, }, ); diff --git a/src/c/translation/types/enumeration.rs b/src/c/translation/types/enumeration.rs index b472b26..05f3de7 100644 --- a/src/c/translation/types/enumeration.rs +++ b/src/c/translation/types/enumeration.rs @@ -1,5 +1,5 @@ use crate::{ - ast::{self, AnonymousEnum, AstFile, EnumMember, TypeKind}, + ast::{self, AnonymousEnum, AstFile, EnumMember, Privacy, TypeKind}, c::{ parser::{error::ParseErrorKind, Enumeration, ParseError}, translation::eval::evaluate_to_const_integer, @@ -67,6 +67,7 @@ pub fn make_anonymous_enum( value: aka_value, source: enumerator.source, is_file_local_only: false, + privacy: Privacy::Public, }, |name| { ParseErrorKind::EnumMemberNameConflictsWithExistingSymbol { diff --git a/src/parser/parse_helper_expr.rs b/src/parser/parse_helper_expr.rs index e8bdbae..c2b6da1 100644 --- a/src/parser/parse_helper_expr.rs +++ b/src/parser/parse_helper_expr.rs @@ -4,7 +4,7 @@ use super::{ Parser, }; use crate::{ - ast::{HelperExpr, Named}, + ast::{HelperExpr, Named, Privacy}, inflow::Inflow, name::Name, token::{Token, TokenKind}, @@ -19,6 +19,7 @@ impl<'a, I: Inflow> Parser<'a, I> { self.input.advance(); let mut namespace = None; + let mut privacy = Privacy::Private; let name = self.parse_identifier(Some("for define name after 'define' keyword"))?; self.ignore_newlines(); @@ -28,6 +29,7 @@ impl<'a, I: Inflow> Parser<'a, I> { for annotation in annotations { match annotation.kind { AnnotationKind::Namespace(new_namespace) => namespace = Some(new_namespace), + AnnotationKind::Public => privacy = Privacy::Public, _ => return Err(self.unexpected_annotation(&annotation, Some("for define"))), } } @@ -40,6 +42,7 @@ impl<'a, I: Inflow> Parser<'a, I> { value, source, is_file_local_only: false, + privacy, }, }) } diff --git a/src/parser/parse_type_alias.rs b/src/parser/parse_type_alias.rs index 05b411d..2acc779 100644 --- a/src/parser/parse_type_alias.rs +++ b/src/parser/parse_type_alias.rs @@ -1,6 +1,6 @@ use super::{annotation::Annotation, error::ParseError, Parser}; use crate::{ - ast::{Named, TypeAlias}, + ast::{Named, Privacy, TypeAlias}, inflow::Inflow, name::Name, parser::annotation::AnnotationKind, @@ -16,6 +16,7 @@ impl<'a, I: Inflow> Parser<'a, I> { assert!(self.input.advance().is_type_alias_keyword()); let mut namespace = None; + let mut privacy = Privacy::Private; let name = self.parse_identifier(Some("for alias name after 'typealias' keyword"))?; self.ignore_newlines(); @@ -23,6 +24,7 @@ impl<'a, I: Inflow> Parser<'a, I> { for annotation in annotations { match annotation.kind { AnnotationKind::Namespace(new_namespace) => namespace = Some(new_namespace), + AnnotationKind::Public => privacy = Privacy::Public, _ => return Err(self.unexpected_annotation(&annotation, Some("for type alias"))), } } @@ -36,6 +38,7 @@ impl<'a, I: Inflow> Parser<'a, I> { value: TypeAlias { value: becomes_type, source, + privacy, }, }) } diff --git a/src/workspace/mod.rs b/src/workspace/mod.rs index ec777de..cc23a62 100644 --- a/src/workspace/mod.rs +++ b/src/workspace/mod.rs @@ -11,7 +11,7 @@ mod module_file; mod normal_file; use crate::{ - ast::{self, AstFile, AstWorkspace, Settings}, + ast::{self, AstFile, AstWorkspace, Privacy, Settings}, c::{ self, lexer::lex_c_code, @@ -451,6 +451,7 @@ fn header( value, source: define.source, is_file_local_only: define.is_file_local_only, + privacy: Privacy::Public, }, ); } From 232ad1df19e54851277f7e5a7e51e9fb523c2d82 Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Thu, 10 Oct 2024 21:04:58 -0500 Subject: [PATCH 3/5] Updated automated builds to use pinned LLVM 18 for macOS --- .github/workflows/remoteBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/remoteBuild.yml b/.github/workflows/remoteBuild.yml index fd9eb75..8c2ec69 100644 --- a/.github/workflows/remoteBuild.yml +++ b/.github/workflows/remoteBuild.yml @@ -96,7 +96,7 @@ jobs: cargo build --release env: CC: /opt/homebrew/opt/llvm/bin/clang - LLVM_SYS_181_PREFIX: /opt/homebrew/opt/llvm + LLVM_SYS_181_PREFIX: /opt/homebrew/opt/llvm@18 zstd_DIR: /usr/local/opt/zstd CFLAGS: -static-libstdc++ CXXFLAGS: -static-libstdc++ From f222d48db30dab873b4ee153d1a67c2a126209c0 Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Thu, 10 Oct 2024 22:21:41 -0500 Subject: [PATCH 4/5] Added clang to path during automated macOS builds --- .github/workflows/remoteBuild.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/remoteBuild.yml b/.github/workflows/remoteBuild.yml index 8c2ec69..6c62e10 100644 --- a/.github/workflows/remoteBuild.yml +++ b/.github/workflows/remoteBuild.yml @@ -68,6 +68,7 @@ jobs: - name: Install LLVM and dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} run: | + export PATH=/opt/homebrew/opt/llvm@18/bin:$PATH brew install llvm@18 brew install zstd - name: Install LLVM and dependencies (Ubuntu) From 356a48ee72dcd099dbf192235bc21f71cb996268 Mon Sep 17 00:00:00 2001 From: IsaacShelton Date: Thu, 10 Oct 2024 22:34:04 -0500 Subject: [PATCH 5/5] Fixed automated macOS builds to work with updated GitHub actions runners --- .github/workflows/remoteBuild.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/remoteBuild.yml b/.github/workflows/remoteBuild.yml index 6c62e10..0c1c7e0 100644 --- a/.github/workflows/remoteBuild.yml +++ b/.github/workflows/remoteBuild.yml @@ -68,7 +68,7 @@ jobs: - name: Install LLVM and dependencies (macOS) if: ${{ matrix.os == 'macos-latest' }} run: | - export PATH=/opt/homebrew/opt/llvm@18/bin:$PATH + brew install llvm # For clang brew install llvm@18 brew install zstd - name: Install LLVM and dependencies (Ubuntu)