Skip to content

Commit c652a3b

Browse files
authored
string API extension (+semver: feature) (#224)
* 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
1 parent 691db82 commit c652a3b

42 files changed

Lines changed: 536 additions & 279 deletions

Some content is hidden

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

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110

111111
publish-nuget:
112112
name: Publish as dotnet tool to NuGet
113-
runs-on: ubuntu-latest
113+
runs-on: windows-latest
114114
needs: publish-release
115115
steps:
116116
- name: Checkout
@@ -120,10 +120,10 @@ jobs:
120120
with:
121121
dotnet-version: 10.0.x
122122
- name: Build
123-
run: dotnet build ./src/HydraScript/HydraScript.csproj -c Release -v n \
124-
/p:Version=${{ needs.publish-release.outputs.determined_version }} \
123+
run: dotnet build ./src/HydraScript/HydraScript.csproj -c Release -v n `
124+
/p:Version=${{ needs.publish-release.outputs.determined_version }} `
125125
/p:PublishAot=false /p:PublishSingleFile=false
126126
- name: Publish
127-
run: dotnet nuget push ./src/HydraScript/bin/Release/*.nupkg \
128-
--api-key ${{ secrets.NUGET_API_KEY }} \
127+
run: dotnet nuget push ./src/HydraScript/bin/Release/*.nupkg `
128+
--api-key ${{ secrets.NUGET_API_KEY }} `
129129
--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.

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

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

0 commit comments

Comments
 (0)