Merge pull request '35-accept-variables' (#2) from 35-accept-variables into master
Some checks failed
CI/CD Pipeline / test (push) Successful in 34s
CI/CD Pipeline / build (push) Failing after 1m55s
CI/CD Pipeline / release (push) Has been skipped

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2025-12-21 16:34:26 -07:00
8 changed files with 61 additions and 44 deletions

View File

@@ -4,6 +4,7 @@ name: CI/CD Pipeline
on: on:
push: push:
branches: ["master"] branches: ["master"]
tags: ["*.*.*"]
pull_request: pull_request:
branches: ["master"] branches: ["master"]
@@ -57,6 +58,10 @@ jobs:
slang-builder \ slang-builder \
./build.sh ./build.sh
- name: Zip Workshop Folder
run: |
zip -r release/workshop.zip release/workshop/
# 3. Fix Permissions # 3. Fix Permissions
# Docker writes files as root. We need to own them to upload them. # Docker writes files as root. We need to own them to upload them.
- name: Fix Permissions - name: Fix Permissions
@@ -69,3 +74,32 @@ jobs:
with: with:
name: StationeersSlang-Release name: StationeersSlang-Release
path: release/ path: release/
release:
needs: build
runs-on: self-hosted
# ONLY run this job if we pushed a tag (e.g., v1.0.1)
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
# We download the artifact from the previous 'build' job
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: StationeersSlang-Release
path: ./release-files
- name: Create Gitea Release
uses: https://gitea.com/actions/gitea-release-action@v1
with:
files: |
./release-files/workshop.zip
./release-files/slang
./release-files/slang.exe
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,5 +1,16 @@
# Changelog # Changelog
[0.4.1]
- Update syscalls for `loadSlot` and `setSlot` to support expressions instead of
just variables for the slot index
- Moved the main repository from GitHub to a self-hosted Gitea
- Restructured workflow files to support this change
- GitHub will still remain as a mirrored repository of the new
Gitea instance.
- This is in response to the new upcoming changes to the pricing model
for self-hosted GitHub action runners.
[0.4.0] [0.4.0]
- First pass getting compiled IC10 to output along side the Slang source code - First pass getting compiled IC10 to output along side the Slang source code

View File

@@ -2,7 +2,7 @@
<ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ModMetadata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>Slang</Name> <Name>Slang</Name>
<Author>JoeDiertay</Author> <Author>JoeDiertay</Author>
<Version>0.4.0</Version> <Version>0.4.1</Version>
<Description> <Description>
[h1]Slang: High-Level Programming for Stationeers[/h1] [h1]Slang: High-Level Programming for Stationeers[/h1]

View File

@@ -41,7 +41,7 @@ namespace Slang
{ {
public const string PluginGuid = "com.biddydev.slang"; public const string PluginGuid = "com.biddydev.slang";
public const string PluginName = "Slang"; public const string PluginName = "Slang";
public const string PluginVersion = "0.4.0"; public const string PluginVersion = "0.4.1";
public static Mod MOD = new Mod(PluginName, PluginVersion); public static Mod MOD = new Mod(PluginName, PluginVersion);

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "slang" name = "slang"
version = "0.4.0" version = "0.4.1"
edition = "2021" edition = "2021"
[workspace] [workspace]

View File

@@ -2233,10 +2233,7 @@ impl<'a> Compiler<'a> {
System::LoadSlot(dev_name, slot_index, logic_type) => { System::LoadSlot(dev_name, slot_index, logic_type) => {
let (dev_hash, hash_cleanup) = let (dev_hash, hash_cleanup) =
self.compile_literal_or_variable(dev_name.node, scope)?; self.compile_literal_or_variable(dev_name.node, scope)?;
let (slot_index, slot_cleanup) = self.compile_literal_or_variable( let (slot_index, slot_cleanup) = self.compile_operand(*slot_index, scope)?;
LiteralOrVariable::Literal(slot_index.node),
scope,
)?;
let (logic_type, logic_cleanup) = self.compile_literal_or_variable( let (logic_type, logic_cleanup) = self.compile_literal_or_variable(
LiteralOrVariable::Literal(logic_type.node), LiteralOrVariable::Literal(logic_type.node),
scope, scope,
@@ -2261,10 +2258,7 @@ impl<'a> Compiler<'a> {
System::SetSlot(dev_name, slot_index, logic_type, var) => { System::SetSlot(dev_name, slot_index, logic_type, var) => {
let (dev_name, name_cleanup) = let (dev_name, name_cleanup) =
self.compile_literal_or_variable(dev_name.node, scope)?; self.compile_literal_or_variable(dev_name.node, scope)?;
let (slot_index, index_cleanup) = self.compile_literal_or_variable( let (slot_index, index_cleanup) = self.compile_operand(*slot_index, scope)?;
LiteralOrVariable::Literal(slot_index.node),
scope,
)?;
let (logic_type, type_cleanup) = self.compile_literal_or_variable( let (logic_type, type_cleanup) = self.compile_literal_or_variable(
LiteralOrVariable::Literal(logic_type.node), LiteralOrVariable::Literal(logic_type.node),
scope, scope,

View File

@@ -1834,20 +1834,8 @@ impl<'a> Parser<'a> {
let mut args = args!(3); let mut args = args!(3);
let next = args.next(); let next = args.next();
let dev_name = literal_or_variable!(next); let dev_name = literal_or_variable!(next);
let next = args.next(); let slot_index = args.next().ok_or(Error::UnexpectedEOF)?;
let slot_index = get_arg!(Literal, literal_or_variable!(next));
if !matches!(
slot_index,
Spanned {
node: Literal::Number(_),
..
},
) {
return Err(Error::InvalidSyntax(
slot_index.span,
"Expected a number".to_string(),
));
}
let next = args.next(); let next = args.next();
let slot_logic = get_arg!(Literal, literal_or_variable!(next)); let slot_logic = get_arg!(Literal, literal_or_variable!(next));
if !matches!( if !matches!(
@@ -1864,27 +1852,17 @@ impl<'a> Parser<'a> {
} }
Ok(SysCall::System(System::LoadSlot( Ok(SysCall::System(System::LoadSlot(
dev_name, slot_index, slot_logic, dev_name,
boxed!(slot_index),
slot_logic,
))) )))
} }
"setSlot" | "ss" => { "setSlot" | "ss" => {
let mut args = args!(4); let mut args = args!(4);
let next = args.next(); let next = args.next();
let dev_name = literal_or_variable!(next); let dev_name = literal_or_variable!(next);
let next = args.next(); let slot_index = args.next().ok_or(Error::UnexpectedEOF)?;
let slot_index = get_arg!(Literal, literal_or_variable!(next));
if !matches!(
slot_index,
Spanned {
node: Literal::Number(_),
..
}
) {
return Err(Error::InvalidSyntax(
slot_index.span,
"Expected a number".into(),
));
}
let next = args.next(); let next = args.next();
let slot_logic = get_arg!(Literal, literal_or_variable!(next)); let slot_logic = get_arg!(Literal, literal_or_variable!(next));
if !matches!( if !matches!(
@@ -1904,9 +1882,9 @@ impl<'a> Parser<'a> {
Ok(SysCall::System(System::SetSlot( Ok(SysCall::System(System::SetSlot(
dev_name, dev_name,
slot_index, boxed!(slot_index),
slot_logic, slot_logic,
Box::new(expr), boxed!(expr),
))) )))
} }
"loadReagent" | "lr" => { "loadReagent" | "lr" => {

View File

@@ -223,7 +223,7 @@ documented! {
/// `let isOccupied = ls(deviceHash, 2, "Occupied");` /// `let isOccupied = ls(deviceHash, 2, "Occupied");`
LoadSlot( LoadSlot(
Spanned<LiteralOrVariable<'a>>, Spanned<LiteralOrVariable<'a>>,
Spanned<Literal<'a>>, Box<Spanned<Expression<'a>>>,
Spanned<Literal<'a>> Spanned<Literal<'a>>
), ),
/// Stores a value of LogicType on a device by the index value /// Stores a value of LogicType on a device by the index value
@@ -234,7 +234,7 @@ documented! {
/// `ss(deviceHash, 0, "Open", true);` /// `ss(deviceHash, 0, "Open", true);`
SetSlot( SetSlot(
Spanned<LiteralOrVariable<'a>>, Spanned<LiteralOrVariable<'a>>,
Spanned<Literal<'a>>, Box<Spanned<Expression<'a>>>,
Spanned<Literal<'a>>, Spanned<Literal<'a>>,
Box<Spanned<Expression<'a>>> Box<Spanned<Expression<'a>>>
), ),