Skip to content

Commit dda3f3c

Browse files
authored
string API extension (+semver: feature) (#226)
* fix type comparing * update packages * fix 2 * #203 - backend support * #203 - central type management * #203 - string type * #203 - merge type services * fix test names * #203 - operators * #203 - zlinq to ir * #203 - default types * #203 - operator types refactoring * #203 - operator application to static analysis * #203 - tests * docs * fix release * fix release 2 * fix release 3 * fix release 4
1 parent 691db82 commit dda3f3c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+541
-283
lines changed

.github/workflows/develop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
- name: Restore dependencies
4949
run: dotnet restore
5050
- name: Build
51-
run: dotnet build /p:Version=${{ steps.version_step.outputs.fullSemVer }} --no-restore -c Debug -v n
51+
run: dotnet build -p:Version=${{ steps.version_step.outputs.fullSemVer }} --no-restore -c Debug -v n
5252
- name: Unit Tests
5353
run: dotnet test -c Debug --no-build -v n --filter-trait Category=Unit
5454
- name: Integration Tests

.github/workflows/release.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ jobs:
4747
needs: create-release
4848
outputs:
4949
determined_version: ${{ needs.create-release.outputs.determined_version }}
50+
publish_version: ${{ needs.create-release.outputs.publish_version }}
5051
strategy:
5152
matrix:
5253
config:
@@ -87,7 +88,7 @@ jobs:
8788
runs-on: ubuntu-latest
8889
needs: upload-release-assets
8990
outputs:
90-
determined_version: ${{ needs.upload-release-assets.outputs.determined_version }}
91+
publish_version: ${{ needs.upload-release-assets.outputs.publish_version }}
9192
steps:
9293
- name: Setup .NET
9394
uses: actions/setup-dotnet@v5
@@ -110,7 +111,7 @@ jobs:
110111

111112
publish-nuget:
112113
name: Publish as dotnet tool to NuGet
113-
runs-on: ubuntu-latest
114+
runs-on: windows-latest
114115
needs: publish-release
115116
steps:
116117
- name: Checkout
@@ -120,10 +121,10 @@ jobs:
120121
with:
121122
dotnet-version: 10.0.x
122123
- name: Build
123-
run: dotnet build ./src/HydraScript/HydraScript.csproj -c Release -v n \
124-
/p:Version=${{ needs.publish-release.outputs.determined_version }} \
125-
/p:PublishAot=false /p:PublishSingleFile=false
124+
run: dotnet build ./src/HydraScript/HydraScript.csproj -c Release -v n `
125+
-p:Version=${{ needs.publish-release.outputs.publish_version }} `
126+
-p:PublishAot=false -p:PublishSingleFile=false
126127
- name: Publish
127-
run: dotnet nuget push ./src/HydraScript/bin/Release/*.nupkg \
128-
--api-key ${{ secrets.NUGET_API_KEY }} \
129-
--source https://api.nuget.org/v3/index.json
128+
run: dotnet nuget push (ls "./src/HydraScript/bin/Release/*.nupkg") `
129+
--api-key ${{ secrets.NUGET_API_KEY }} `
130+
--source "https://api.nuget.org/v3/index.json"

Directory.Packages.props

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Project>
22
<ItemGroup>
3-
<PackageVersion Include="BenchmarkDotNet" Version="0.15.6" />
3+
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
44
<PackageVersion Include="EnvironmentAbstractions" Version="5.0.0" />
55
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
66
<PrivateAssets>all</PrivateAssets>
77
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
88
</PackageVersion>
99
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
10-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
11-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0" />
12-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
13-
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.0" />
14-
<PackageVersion Include="System.CommandLine" Version="2.0.0" />
15-
<PackageVersion Include="System.IO.Abstractions" Version="22.0.16" />
10+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
11+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.1" />
12+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.1" />
13+
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.1" />
14+
<PackageVersion Include="System.CommandLine" Version="2.0.1" />
15+
<PackageVersion Include="System.IO.Abstractions" Version="22.1.0" />
1616
<PackageVersion Include="Visitor.NET" Version="4.2.0" />
1717
<PackageVersion Include="Visitor.NET.AutoVisitableGen" Version="1.5.2" />
1818
<PackageVersion Include="ZLinq" Version="1.5.4" />

Readme.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ type composite = {
8484
}
8585
```
8686

87+
#### Strings
88+
89+
Strings support following operations:
90+
- index access, returns `string`:
91+
```
92+
let str = "str"
93+
>>> str[1] // t
94+
```
95+
- length getter:
96+
```
97+
let str = "str"
98+
>>> ~str // 3
99+
```
100+
87101
### Variables
88102

89103
For declaring mutable variables use `let`:
@@ -165,8 +179,8 @@ array = array ++ [5, 7] // concatenation
165179
| ! | unary | boolean | boolean |
166180
| - | unary | number | number |
167181
| ++ | binary | [] | [] |
168-
| :: | binary | [] и number | void |
169-
| ~ | unary | [] | number |
182+
| :: | binary | [] and number | void |
183+
| ~ | unary | [] or string | number |
170184

171185
### Conditionals
172186

src/Application/HydraScript.Application.StaticAnalysis/IDefaultValueForTypeCalculator.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/Application/HydraScript.Application.StaticAnalysis/IExplicitCastValidator.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace HydraScript.Application.StaticAnalysis;
2+
3+
public interface IHydraScriptTypesService
4+
{
5+
public Type Number { get; }
6+
7+
public Type Boolean { get; }
8+
9+
public Type String { get; }
10+
11+
public Type Undefined { get; }
12+
13+
public Type Void { get; }
14+
15+
public IEnumerable<Type> GetDefaultTypes();
16+
17+
public bool Contains(Type type);
18+
19+
public object? GetDefaultValueForType(Type type);
20+
21+
public bool IsExplicitCastAllowed(Type from, Type to);
22+
}

src/Application/HydraScript.Application.StaticAnalysis/IJavaScriptTypesProvider.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Application/HydraScript.Application.StaticAnalysis/ITypeDeclarationsResolver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ public interface ITypeDeclarationsResolver
77
public void Store(TypeDeclaration declaration);
88

99
public void Resolve();
10+
11+
IHydraScriptTypesService TypesService { get; }
1012
}

src/Application/HydraScript.Application.StaticAnalysis/Impl/DefaultValueForTypeCalculator.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)